mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-25 20:33:35 +00:00
Merge pull request #883 from akuker/rdmark-generalize-properties
Allow for generating properties files in the Create Image UI
This commit is contained in:
commit
2dae021cdd
@ -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,17 +876,33 @@ 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"])
|
||||
|
||||
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"])
|
||||
|
Loading…
Reference in New Issue
Block a user