use subprocess to call curl
This commit is contained in:
parent
3e07346755
commit
7ca19ca1b8
28
ocrloader.py
28
ocrloader.py
|
@ -10,6 +10,7 @@ import os
|
|||
import os.path
|
||||
import requests
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
|
@ -57,23 +58,16 @@ def process(cfg, filename, payload, enable_ocr=True):
|
|||
title = string.Template(cfg.get('title')).substitute(
|
||||
{'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.treating_group=%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'),
|
||||
cfg.get('treating_group'),
|
||||
title,
|
||||
cfg.get('ged_base_url')))
|
||||
t = subprocess.call(['curl', '-v', '--insecure', '-X', 'POST',
|
||||
'-F', 'form.widgets.file=@%s;filename=%s;type=application/pdf' % (ocr_filename, filename),
|
||||
'-F', 'form.buttons.import=Import',
|
||||
'-F', 'form.widgets.portal_type=%s' % cfg.get('default_type'),
|
||||
'-F', 'form.widgets.location=%s' % cfg.get('default_directory'),
|
||||
'-F', 'form.widgets.owner=%s' % cfg.get('user'),
|
||||
'-F', 'form.widgets.treating_group=%s' % cfg.get('treating_group'),
|
||||
'-F', 'form.widgets.title=%s' % title,
|
||||
'-u', 'admin:admin',
|
||||
'%s/@@fileimport' % cfg.get('ged_base_url'),]
|
||||
return (t == 0)
|
||||
|
||||
|
||||
|
|
Reference in New Issue