summaryrefslogtreecommitdiffstats
path: root/ocrloader.py
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-03-10 09:01:38 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-03-10 09:01:38 (GMT)
commit7ca19ca1b863fe2cfd9aaaeedaa5c0eaae81821f (patch)
treef3dddb8f8db08cc691f1f487a946b917714b72eb /ocrloader.py
parent3e07346755ff1733c2036c2cf28c5dc682bb1fb3 (diff)
downloadpfwbged.ocrloader-7ca19ca1b863fe2cfd9aaaeedaa5c0eaae81821f.zip
pfwbged.ocrloader-7ca19ca1b863fe2cfd9aaaeedaa5c0eaae81821f.tar.gz
pfwbged.ocrloader-7ca19ca1b863fe2cfd9aaaeedaa5c0eaae81821f.tar.bz2
use subprocess to call curl
Diffstat (limited to 'ocrloader.py')
-rw-r--r--ocrloader.py28
1 files changed, 11 insertions, 17 deletions
diff --git a/ocrloader.py b/ocrloader.py
index e0b571f..af239ac 100644
--- a/ocrloader.py
+++ b/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)