mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-30 05:29:47 +00:00
Better error handling in ISO image creation (#379)
This commit is contained in:
parent
79c5da9432
commit
3546764722
@ -190,10 +190,9 @@ def download_file_to_iso(scsi_id, url):
|
||||
["genisoimage", "-hfs", "-o", iso_filename, tmp_full_path], capture_output=True
|
||||
)
|
||||
if iso_proc.returncode != 0:
|
||||
return {"status": False, "msg": str(iso_proc)}
|
||||
return {"status": False, "msg": iso_proc.stderr.decode("utf-8")}
|
||||
|
||||
process = attach_image(scsi_id, type="SCCD", image=iso_filename)
|
||||
return {"status": process["status"], "msg": process["msg"]}
|
||||
return {"status": True, "msg": iso_proc.stdout.decode("utf-8"), "file_name": iso_filename}
|
||||
|
||||
|
||||
def download_to_dir(url, save_dir):
|
||||
|
@ -489,18 +489,26 @@ def shutdown():
|
||||
|
||||
|
||||
@app.route("/files/download_to_iso", methods=["POST"])
|
||||
def download_file():
|
||||
def download_to_iso():
|
||||
scsi_id = request.form.get("scsi_id")
|
||||
|
||||
url = request.form.get("url")
|
||||
process = download_file_to_iso(scsi_id, url)
|
||||
if process["status"] == True:
|
||||
flash(f"File Downloaded and Attached to SCSI ID {scsi_id}")
|
||||
flash(f"Created CD-ROM image {process['file_name']}")
|
||||
flash(process["msg"])
|
||||
else:
|
||||
flash(f"Failed to create CD-ROM image from {url}", "error")
|
||||
flash(process["msg"], "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
process_attach = attach_image(scsi_id, type="SCCD", image=process["file_name"])
|
||||
if process_attach["status"] == True:
|
||||
flash(f"Attached to SCSI ID {scsi_id}")
|
||||
return redirect(url_for("index"))
|
||||
else:
|
||||
flash(f"Failed to download and/or attach file {url}", "error")
|
||||
flash(process["msg"], "error")
|
||||
flash(f"Failed to attach to SCSI ID {scsi_id}. Try attaching it manually.", "error")
|
||||
flash(process_attach["msg"], "error")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user