summaryrefslogtreecommitdiff
path: root/chimere/tasks.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/tasks.py')
-rw-r--r--chimere/tasks.py37
1 files changed, 20 insertions, 17 deletions
diff --git a/chimere/tasks.py b/chimere/tasks.py
index 9c94f43..9eff7f5 100644
--- a/chimere/tasks.py
+++ b/chimere/tasks.py
@@ -60,19 +60,20 @@ else:
return task_exc
IMPORT_MESSAGES = {
- 'import_pending':[_(u"Import pending")],
- 'import_process':[_(u"Import processing")],
- 'import_done':[_(u"Import successfuly done"),
+ 'import_pending': [_(u"Import pending")],
+ 'import_process': [_(u"Import processing")],
+ 'import_done': [_(u"Import successfuly done"),
_(u" %(new)d new item(s), %(updated)d updated item(s)")],
- 'import_failed':[_(u"Import failed"), "%s"],
- 'import_cancel':[_(u"Import canceled")],
- 'export_pending':[_(u"Export pending")],
- 'export_process':[_(u"Export processing")],
- 'export_done':[_(u"Export successfuly done"),
+ 'import_failed': [_(u"Import failed"), "%s"],
+ 'import_cancel': [_(u"Import canceled")],
+ 'export_pending': [_(u"Export pending")],
+ 'export_process': [_(u"Export processing")],
+ 'export_done': [_(u"Export successfuly done"),
_(u" %(updated)d updated item(s)")],
- 'export_failed':[_(u"Export failed"), "%s"],
- 'export_cancel':[_(u"Export canceled")]
- }
+ 'export_failed': [_(u"Export failed"), "%s"],
+ 'export_cancel': [_(u"Export canceled")]
+}
+
@task()
def importing(importer_pk):
@@ -89,15 +90,16 @@ def importing(importer_pk):
new_item, updated_item, error = importer.manager.get()
importer.state = error + '\n' if error else ''
importer.state += unicode(IMPORT_MESSAGES['import_done'][0])
- importer.state += u" - " \
- + unicode(IMPORT_MESSAGES['import_done'][1]) % {'new':new_item,
- 'updated':updated_item}
+ importer.state += \
+ u" - " + unicode(IMPORT_MESSAGES['import_done'][1]) % {
+ 'new': new_item, 'updated': updated_item}
importer.state = importer.state
importer.save()
return True
+
@task()
-@single_instance_task(60*10)
+@single_instance_task(60 * 10)
def exporting(importer_pk, extra_args=[]):
try:
importer = Importer.objects.get(pk=importer_pk)
@@ -116,10 +118,11 @@ def exporting(importer_pk, extra_args=[]):
pass
if error:
importer.state = unicode(IMPORT_MESSAGES['export_failed'][0]) \
- + u" - " + unicode(IMPORT_MESSAGES['export_failed'][1]) % error
+ + u" - " + unicode(IMPORT_MESSAGES['export_failed'][1]) % error
importer.save()
return
importer.state = unicode(IMPORT_MESSAGES['export_done'][0]) + u" - " \
- + unicode(IMPORT_MESSAGES['export_done'][1]) % {'updated':updated_item}
+ + unicode(IMPORT_MESSAGES['export_done'][1]) % {
+ 'updated': updated_item}
importer.save()
return True