give a proper title to scanned documents (#2848)
parent
aa342ff79d
commit
65be07e6c4
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Reference in New Issue