mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-20 11:17:58 +00:00
Allow generating ISO image from local file (#1046)
- Break out generate_iso() into its own class method in file_cmds - Add form and handling of using local file to generate iso image - Reorder index page sections to group actions that create new image files
This commit is contained in:
@@ -635,30 +635,48 @@ class FileCmds:
|
||||
)
|
||||
tmp_full_path.unlink(True)
|
||||
|
||||
try:
|
||||
run(
|
||||
[
|
||||
"genisoimage",
|
||||
*iso_args,
|
||||
"-o",
|
||||
str(iso_filename),
|
||||
tmp_dir,
|
||||
],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
except CalledProcessError as error:
|
||||
logging.warning(SHELL_ERROR, " ".join(error.cmd), error.stderr.decode("utf-8"))
|
||||
return {"status": False, "msg": error.stderr.decode("utf-8")}
|
||||
process = self.generate_iso(iso_filename, Path(tmp_dir), *iso_args)
|
||||
|
||||
if not process["status"]:
|
||||
return {"status": False, "msg": process["msg"]}
|
||||
|
||||
parameters = {"value": " ".join(iso_args)}
|
||||
return {
|
||||
"status": True,
|
||||
"return_code": ReturnCodes.DOWNLOADFILETOISO_SUCCESS,
|
||||
"parameters": parameters,
|
||||
"file_name": iso_filename.name,
|
||||
"return_code": process["return_code"],
|
||||
"parameters": process["parameters"],
|
||||
"file_name": process["file_name"],
|
||||
}
|
||||
|
||||
def generate_iso(self, iso_file, target_path, *iso_args):
|
||||
"""
|
||||
Takes
|
||||
- (Path) iso_file - the path to the file to create
|
||||
- (Path) target_path - the path to the file or dir to generate the iso from
|
||||
- (*str) iso_args - the tuple of arguments to pass to genisoimage
|
||||
"""
|
||||
try:
|
||||
run(
|
||||
[
|
||||
"genisoimage",
|
||||
*iso_args,
|
||||
"-o",
|
||||
str(iso_file),
|
||||
str(target_path),
|
||||
],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
except CalledProcessError as error:
|
||||
logging.warning(SHELL_ERROR, " ".join(error.cmd), error.stderr.decode("utf-8"))
|
||||
return {"status": False, "msg": error.stderr.decode("utf-8")}
|
||||
|
||||
return {
|
||||
"status": True,
|
||||
"return_code": ReturnCodes.DOWNLOADFILETOISO_SUCCESS,
|
||||
"parameters": {"value": " ".join(iso_args)},
|
||||
"file_name": iso_file.name,
|
||||
}
|
||||
|
||||
# noinspection PyMethodMayBeStatic
|
||||
def download_to_dir(self, url, save_dir, file_name):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user