Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
4297be67bbe4
Commit
2c74aa16
authored
Apr 04, 2011
by
Sylvain Thénault
Browse files
[dataimport] tell more and nicely about transaction status
--HG-- branch : stable
parent
32b5d9d43a7e
Changes
1
Hide whitespace changes
Inline
Side-by-side
dataimport.py
View file @
4297be67
...
...
@@ -79,6 +79,7 @@ from logilab.common.date import strptime
from
logilab.common.decorators
import
cached
from
logilab.common.deprecation
import
deprecated
from
cubicweb
import
QueryError
from
cubicweb.schema
import
META_RTYPES
,
VIRTUAL_RTYPES
from
cubicweb.server.utils
import
eschema_eid
from
cubicweb.server.edition
import
EditedEntity
...
...
@@ -540,6 +541,10 @@ class CWImportController(object):
def
run
(
self
):
self
.
errors
=
{}
if
self
.
commitevery
is
None
:
self
.
tell
(
'Will commit all or nothing.'
)
else
:
self
.
tell
(
'Will commit every %s iterations'
%
self
.
commitevery
)
for
func
,
checks
in
self
.
generators
:
self
.
_checks
=
{}
func_name
=
func
.
__name__
...
...
@@ -558,7 +563,12 @@ class CWImportController(object):
err
=
func
(
buckets
)
if
err
:
self
.
errors
[
title
]
=
(
help
,
err
)
txuuid
=
self
.
store
.
commit
()
try
:
txuuid
=
self
.
store
.
commit
()
if
txuuid
is
not
None
:
self
.
tell
(
'Transaction commited (txuuid: %s)'
%
txuuid
)
except
QueryError
,
ex
:
self
.
tell
(
'Transaction aborted: %s'
%
ex
)
self
.
_print_stats
()
if
self
.
errors
:
if
self
.
askerror
==
2
or
(
self
.
askerror
and
confirm
(
'Display errors ?'
)):
...
...
@@ -566,8 +576,7 @@ class CWImportController(object):
for
errkey
,
error
in
self
.
errors
.
items
():
self
.
tell
(
"
\n
%s (%s): %d
\n
"
%
(
error
[
0
],
errkey
,
len
(
error
[
1
])))
self
.
tell
(
pformat
(
sorted
(
error
[
1
])))
if
txuuid
is
not
None
:
print
'transaction id:'
,
txuuid
def
_print_stats
(
self
):
nberrors
=
sum
(
len
(
err
[
1
])
for
err
in
self
.
errors
.
values
())
self
.
tell
(
'
\n
Import statistics: %i entities, %i types, %i relations and %i errors'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment