give a proper title to scanned documents (#2848)

This commit is contained in:
Frédéric Péters 2013-11-05 13:06:33 +01:00
parent aa342ff79d
commit 65be07e6c4
2 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@ ged_base_url = http://test.ged.pfwb.be
ged_username = admin
ged_password = xxxxx
ocrized_directory = /root/tests
title = Document scanned on %(date)s at %(time)s
[xxxx-test-greffe@pfwb.be]
password = xxxxxx

View File

@ -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)