From 7ca19ca1b863fe2cfd9aaaeedaa5c0eaae81821f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Mon, 10 Mar 2014 10:01:38 +0100 Subject: [PATCH] use subprocess to call curl --- ocrloader.py | 28 +++++++++++----------------- 1 file 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)