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:
Daniel Markstedt
2022-12-23 16:13:52 -08:00
committed by GitHub
parent bf2b210c4c
commit cde4866844
5 changed files with 248 additions and 140 deletions
+37 -19
View File
@@ -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):
"""