summaryrefslogtreecommitdiffstats
path: root/ocrloader.py
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2013-11-05 12:06:33 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2013-11-05 12:06:33 (GMT)
commit65be07e6c4aedc99a636ce4e6a1b93cdd34d0b94 (patch)
treeed2db69a14d61c4514406da4855c380be92c2094 /ocrloader.py
parentaa342ff79d69d9d17611baecd8edd472de59af12 (diff)
downloadpfwbged.ocrloader-65be07e6c4aedc99a636ce4e6a1b93cdd34d0b94.zip
pfwbged.ocrloader-65be07e6c4aedc99a636ce4e6a1b93cdd34d0b94.tar.gz
pfwbged.ocrloader-65be07e6c4aedc99a636ce4e6a1b93cdd34d0b94.tar.bz2
give a proper title to scanned documents (#2848)
Diffstat (limited to 'ocrloader.py')
-rw-r--r--ocrloader.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/ocrloader.py b/ocrloader.py
index 160a71e..e71c849 100644
--- a/ocrloader.py
+++ b/ocrloader.py
@@ -1,6 +1,7 @@
#! /usr/bin/env python
import ConfigParser
+import datetime
import email
import email.parser
import imaplib
@@ -50,18 +51,22 @@ def process(cfg, filename, payload, enable_ocr=True):
return True
else:
print ' uploading file'
+ now = datetime.datetime.now()
+ title = cfg.get('title') % {'date': now.strftime('%d/%m/%Y'), 'time': now.strftime('%H:%M')}
t = os.system('curl -v --insecure -X POST '\
'--form "form.widgets.file=@%s;filename=%s;type=application/pdf" '\
'-F "form.buttons.import=Import" '\
'-F "form.widgets.portal_type=%s" '\
'-F "form.widgets.location=%s" '\
'-F "form.widgets.owner=%s" '\
+ '-F "form.widgets.title=%s" '\
'-u admin:admin '\
'%s/@@fileimport' % (
ocr_filename, filename,
cfg.get('default_type'),
cfg.get('default_directory'),
cfg.get('user'),
+ urllib.quote(title),
cfg.get('ged_base_url')))
return (t == 0)