Skip to content

Commit

Permalink
fix(server): download command list for running and queued dynamics
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo committed Apr 20, 2023
1 parent 40668fa commit 3a84a83
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
36 changes: 31 additions & 5 deletions apps/server/server/resources/downloads/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,38 @@ def get(self):

task = AbortableAsyncResult(args["taskId"], app=celery)

folder_dynamic_path = os.path.abspath(task.args[0])
file_commands_path = os.path.abspath(
os.path.join(folder_dynamic_path, "commands.txt")
)
if task.ready():
folder_dynamic_path = os.path.abspath(task.args[0])
file_commands_path = os.path.abspath(
os.path.join(folder_dynamic_path, "commands.txt")
)

dynamic_data = task.args[0].split("/")
else:
active_tasks = celery.control.inspect(["worker@visualdynamics"]).active()[
"worker@visualdynamics"
]
task = [
active_task
for active_task in active_tasks
if active_task["id"] == args["taskId"]
][0]

if task == None:
reserved_tasks = celery.control.inspect(
["worker@visualdynamics"]
).reserved()["worker@visualdynamics"]
task = [
reserved_task
for reserved_task in reserved_tasks
if reserved_task["id"] == args["taskId"]
][0]

dynamic_data = task.args[0].split("/")
folder_dynamic_path = os.path.abspath(task["args"][0])
file_commands_path = os.path.abspath(
os.path.join(folder_dynamic_path, "commands.txt")
)
dynamic_data = task["args"][0].split("/")

stripped_timestamp_folder = dynamic_data[9].replace("\n", "")
download_filename = (
Expand Down
20 changes: 9 additions & 11 deletions apps/server/server/resources/downloads/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@ def get(self):
file = os.path.join(folder_run_path, file)
shutil.move(file, folder_figures_path)

zf = zipfile.ZipFile(file_figures_zip, "w")

for folder, _, files in os.walk(folder_figures_path):
for file in files:
if not file.endswith(".zip"):
zf.write(
os.path.join(folder, file),
file,
compress_type=zipfile.ZIP_DEFLATED,
)
zf.close()
with zipfile.ZipFile(file_figures_zip, "w") as z:
for folder, _, files in os.walk(folder_figures_path):
for file in files:
if not file.endswith(".zip"):
z.write(
os.path.join(folder, file),
file,
compress_type=zipfile.ZIP_DEFLATED,
)

dynamic_data = task.args[0].split("/")

Expand Down

0 comments on commit 3a84a83

Please sign in to comment.