Skip to content
Snippets Groups Projects

Fix zip file export

Merged Daniel Hornung requested to merge f-fix-zip-files into dev
All threads resolved!
8 files
+ 57
22
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -32,7 +32,7 @@ from zipfile import ZipFile
import linkahead as db
import pandas as pd
from linkaheadadvancedtools.serverside import helper
from caosadvancedtools.serverside import helper
from linkahead import LinkAheadException, ConsistencyError, EntityDoesNotExistError
@@ -71,9 +71,7 @@ def collect_files_in_zip(ids, table):
# download and add all files
for file_id in ids:
try:
tmp = db.execute_query("FIND FILE WITH ID={a:}".format(
a=file_id),
unique=True)
tmp = db.get_entity_by_id(file_id, role="FILE")
except EntityDoesNotExistError as e:
# TODO
# Current behavior: script terminates with error if just one
@@ -81,14 +79,14 @@ def collect_files_in_zip(ids, table):
# Desired behavior: The script should go on with the other
# ids, but the user should be informed about the missing files.
# How should we do this?
logger = logging.getLogger("linkaheadadvancedtools")
logger.error("Did not find Entity with ID={}.".format(
logger = logging.getLogger("caosadvancedtools")
logger.error("Did not find File with ID={}.".format(
file_id))
raise e
savename = nc.get_unique_savename(os.path.basename(tmp.path))
val_file = helper.get_file_via_download(
tmp, logger=logging.getLogger("linkaheadadvancedtools"))
tmp, logger=logging.getLogger("caosadvancedtools"))
zf.write(val_file, savename)
Loading