Skip to content
Snippets Groups Projects
Commit eb98d679 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

up

parent cbdbc85a
Branches
Tags
No related merge requests found
...@@ -48,8 +48,8 @@ def get_file(eid): ...@@ -48,8 +48,8 @@ def get_file(eid):
fi = db.File(id=eid) fi = db.File(id=eid)
fi.retrieve() fi.retrieve()
except db.exceptions.EntityDoesNotExistError: except db.exceptions.EntityDoesNotExistError:
return ("Cannot create preview for Entity with ID={}, because it seems" print("Cannot create preview for Entity with ID={}, because it seems"
"not to exist.".format(eid)) "not to exist.".format(eid), file=sys.stderr)
sys.exit(1) sys.exit(1)
return fi return fi
...@@ -76,6 +76,7 @@ def ending_is_valid(fipath): ...@@ -76,6 +76,7 @@ def ending_is_valid(fipath):
return get_ending(fipath) is not None return get_ending(fipath) is not None
def read_file(fipath, ftype): def read_file(fipath, ftype):
""" tries to read the provided file """ """ tries to read the provided file """
...@@ -98,28 +99,29 @@ def read_file(fipath, ftype): ...@@ -98,28 +99,29 @@ def read_file(fipath, ftype):
def create_table_preview(fi): def create_table_preview(fi):
if not ending_is_valid(fi.path): if not ending_is_valid(fi.path):
print("Cannot create preview for Entity with ID={}, because download" print("Cannot create preview for Entity with ID={}, because download"
"failed.".format(entity_id)) "failed.".format(entity_id), file=sys.stderr)
sys.exit(1) sys.exit(5)
ending = get_ending(fi.path) ending = get_ending(fi.path)
if not size_is_ok(fi): if not size_is_ok(fi):
print("Skipped creating a preview for Entity with ID={}, because the" print("Skipped creating a preview for Entity with ID={}, because the"
"file is large!".format(entity_id)) "file is large!".format(entity_id), file=sys.stderr)
sys.exit(2) sys.exit(2)
try: try:
tmpfile = fi.download() tmpfile = fi.download()
except Exception: except Exception:
print("Cannot create preview for Entity with ID={}, because download" print("Cannot create preview for Entity with ID={}, because download"
"failed.".format(entity_id)) "failed.".format(entity_id), file=sys.stderr)
sys.exit(3) sys.exit(3)
try: try:
df = read_file(tmpfile, ending) df = read_file(tmpfile, ending)
except ValueError: except ValueError:
print("Cannot read File Entity with ID={}.".format(entity_id)) print("Cannot read File Entity with ID={}.".format(entity_id),
file=sys.stderr)
sys.exit(4) sys.exit(4)
print(df.to_html(max_cols=10, max_rows=10)) print(df.to_html(max_cols=10, max_rows=10))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment