mirror of
https://github.com/akuker/RASCSI.git
synced 2024-08-20 13:29:27 +00:00
Allow for generating properties files in the Create Image UI
This commit is contained in:
parent
d969fbdcce
commit
c07e1a8ede
@ -589,6 +589,17 @@
|
||||
</select>
|
||||
<label for="size">{{ _("Size:") }}</label>
|
||||
<input name="size" type="number" placeholder="{{ _("MiB") }}" min="1" max="262144" required>
|
||||
<label for="drive_name">{{ _("Masquerade as:") }}</label>
|
||||
<select name="drive_name">
|
||||
<option value="">
|
||||
{{ _("None") }}
|
||||
</option>
|
||||
{% for drive in drive_properties["hd_conf"] | sort(attribute='name') %}
|
||||
<option value="{{ drive.name }}">
|
||||
{{ drive.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="{{ _("Create") }}">
|
||||
</form>
|
||||
</td>
|
||||
|
@ -876,18 +876,34 @@ def create_file():
|
||||
file_name = request.form.get("file_name")
|
||||
size = (int(request.form.get("size")) * 1024 * 1024)
|
||||
file_type = request.form.get("type")
|
||||
drive_name = request.form.get("drive_name")
|
||||
|
||||
full_file_name = file_name + "." + file_type
|
||||
|
||||
process = file_cmd.create_new_image(file_name, file_type, size)
|
||||
if process["status"]:
|
||||
return response(
|
||||
status_code=201,
|
||||
message=_("Image file created: %(file_name)s", file_name=full_file_name),
|
||||
image=full_file_name,
|
||||
)
|
||||
|
||||
if not process["status"]:
|
||||
return response(error=True, message=process["msg"])
|
||||
|
||||
# Creating the drive properties file, if one is chosen
|
||||
if drive_name:
|
||||
drive_props = None
|
||||
for drive in APP.config["RASCSI_DRIVE_PROPERTIES"]:
|
||||
if drive["name"] == drive_name:
|
||||
drive_props = drive
|
||||
break
|
||||
properties = {
|
||||
"vendor": drive_props["vendor"],
|
||||
"product": drive_props["product"],
|
||||
"revision": drive_props["revision"],
|
||||
"block_size": drive_props["block_size"],
|
||||
}
|
||||
prop_file_name = f"{full_file_name}.{PROPERTIES_SUFFIX}"
|
||||
process = file_cmd.write_drive_properties(prop_file_name, properties)
|
||||
process = ReturnCodeMapper.add_msg(process)
|
||||
if not process["status"]:
|
||||
return response(error=True, message=process["msg"])
|
||||
|
||||
return response(message=_("Image file created: %(file_name)s", file_name=full_file_name))
|
||||
|
||||
|
||||
@APP.route("/files/download", methods=["POST"])
|
||||
@login_required
|
||||
|
Loading…
Reference in New Issue
Block a user