Commit 6e5c23ef authored by Merlijn Wajer's avatar Merlijn Wajer
Browse files

scandata: use python zipfile rather than unzip

parent 8734747e
import tempfile
import zipfile
from subprocess import check_call
from pathlib import Path
# TODO: currently depends on unzip package. Maybe just use Python unzip?
import xmltodict
from .const import PB_ITEM, PB_TMP
......@@ -39,14 +38,22 @@ def get_scandata_xml(identifier, source_file):
# XXX: We don't clean up the temporary directory when we're done,
# since the Docker container will remove all files upon completion.
directory = tempfile.mkdtemp(dir=PB_TMP)
check_call(['unzip', '-qq', '-o', str(zip_path), 'scandata.xml',
'-d', directory])
xml_path = Path(directory)/'scandata.xml'
zf = zipfile.ZipFile(zip_path)
sf ='scandata.xml')
f = open(xml_path, 'wb+')
except Exception as e:
logger.warning('Unable to extract scandata.xml from')
return None
return str(xml_path)
logger.warning(f'Unable to find scandata file')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment