mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-22 16:33:17 +00:00
Merge pull request #293 from akuker/fix_hardcoded_filetypes
Query rascsi for the supported file endings to be used in the Web UI
This commit is contained in:
commit
d34c85d103
@ -13,6 +13,7 @@ def get_server_info():
|
||||
- list of str log_levels (the log levels RaSCSI supports)
|
||||
- str current_log_level
|
||||
- list of int reserved_ids
|
||||
- 5 distinct lists of strs with file endings recognized by RaSCSI
|
||||
"""
|
||||
command = proto.PbCommand()
|
||||
command.operation = proto.PbOperation.SERVER_INFO
|
||||
@ -26,12 +27,37 @@ def get_server_info():
|
||||
log_levels = result.server_info.log_levels
|
||||
current_log_level = result.server_info.current_log_level
|
||||
reserved_ids = list(result.server_info.reserved_ids)
|
||||
|
||||
# Creates lists of file endings recognized by RaSCSI
|
||||
mappings = result.server_info.mapping_info.mapping
|
||||
sahd = []
|
||||
schd = []
|
||||
scrm = []
|
||||
scmo = []
|
||||
sccd = []
|
||||
for m in mappings:
|
||||
if mappings[m] == proto.PbDeviceType.SAHD:
|
||||
sahd.append(m)
|
||||
elif mappings[m] == proto.PbDeviceType.SCHD:
|
||||
schd.append(m)
|
||||
elif mappings[m] == proto.PbDeviceType.SCRM:
|
||||
scrm.append(m)
|
||||
elif mappings[m] == proto.PbDeviceType.SCMO:
|
||||
scmo.append(m)
|
||||
elif mappings[m] == proto.PbDeviceType.SCCD:
|
||||
sccd.append(m)
|
||||
|
||||
return {
|
||||
"status": result.status,
|
||||
"version": version,
|
||||
"log_levels": log_levels,
|
||||
"current_log_level": current_log_level,
|
||||
"reserved_ids": reserved_ids
|
||||
"reserved_ids": reserved_ids,
|
||||
"sahd": sahd,
|
||||
"schd": schd,
|
||||
"scrm": scrm,
|
||||
"scmo": scmo,
|
||||
"sccd": sccd,
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,15 +6,7 @@ home_dir = getcwd()
|
||||
DEFAULT_CONFIG = "default.json"
|
||||
MAX_FILE_SIZE = getenv("MAX_FILE_SIZE", 1024 * 1024 * 1024 * 4) # 4gb
|
||||
|
||||
HARDDRIVE_FILE_SUFFIX = ("hda", "hdn", "hdi", "nhd", "hdf", "hds")
|
||||
SASI_FILE_SUFFIX = ("hdf",)
|
||||
REMOVABLE_FILE_SUFFIX = ("hdr",)
|
||||
CDROM_FILE_SUFFIX = ("iso",)
|
||||
MO_FILE_SUFFIX = ("mos",)
|
||||
ARCHIVE_FILE_SUFFIX = ("zip",)
|
||||
VALID_FILE_SUFFIX = HARDDRIVE_FILE_SUFFIX + SASI_FILE_SUFFIX + \
|
||||
REMOVABLE_FILE_SUFFIX + CDROM_FILE_SUFFIX + \
|
||||
MO_FILE_SUFFIX + ARCHIVE_FILE_SUFFIX
|
||||
|
||||
# File containing canonical drive properties
|
||||
DRIVE_PROPERTIES_FILE = home_dir + "/drive_properties.json"
|
||||
|
@ -53,7 +53,7 @@
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
<div class="footer">
|
||||
<center><tt>RaSCSI version: <strong>{{server_info["version"]}} <a href="https://github.com/akuker/RASCSI/commit/{{running_env["git"]}}">{{running_env["git"][:7]}}</a></strong></tt></center>
|
||||
<center><tt>RaSCSI version: <strong>{{version}} <a href="https://github.com/akuker/RASCSI/commit/{{running_env["git"]}}">{{running_env["git"][:7]}}</a></strong></tt></center>
|
||||
<center><tt>Pi environment: {{running_env["env"]}}</tt></center>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -355,8 +355,8 @@
|
||||
<form action="/logs/level" method="post">
|
||||
<label for="level">Log Level:</label>
|
||||
<select name="level">
|
||||
{% for level in server_info["log_levels"] %}
|
||||
<option value="{{level}}"{% if level == server_info["current_log_level"] %} selected{% endif %}>{{level}}</option>
|
||||
{% for level in log_levels %}
|
||||
<option value="{{level}}"{% if level == current_log_level %} selected{% endif %}>{{level}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<input type="submit" value="Set Log Level" />
|
||||
|
@ -67,6 +67,16 @@ def index():
|
||||
formatted_devices = sort_and_format_devices(devices["device_list"])
|
||||
scsi_ids = get_valid_scsi_ids(devices["device_list"], reserved_scsi_ids)
|
||||
|
||||
valid_file_suffix = "."+", .".join(
|
||||
server_info["sahd"] +
|
||||
server_info["schd"] +
|
||||
server_info["scrm"] +
|
||||
server_info["scmo"] +
|
||||
server_info["sccd"] +
|
||||
list(ARCHIVE_FILE_SUFFIX)
|
||||
)
|
||||
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
bridge_configured=is_bridge_setup(),
|
||||
@ -78,16 +88,14 @@ def index():
|
||||
reserved_scsi_ids=reserved_scsi_ids,
|
||||
max_file_size=int(MAX_FILE_SIZE / 1024 / 1024),
|
||||
running_env=running_env(),
|
||||
server_info=server_info,
|
||||
version=server_info["version"],
|
||||
log_levels=server_info["log_levels"],
|
||||
current_log_level=server_info["current_log_level"],
|
||||
netinfo=get_network_info(),
|
||||
device_types=device_types["device_types"],
|
||||
free_disk=int(disk["free"] / 1024 / 1024),
|
||||
valid_file_suffix="."+", .".join(VALID_FILE_SUFFIX),
|
||||
valid_file_suffix=valid_file_suffix,
|
||||
removable_device_types=REMOVABLE_DEVICE_TYPES,
|
||||
harddrive_file_suffix=HARDDRIVE_FILE_SUFFIX,
|
||||
cdrom_file_suffix=CDROM_FILE_SUFFIX,
|
||||
removable_file_suffix=REMOVABLE_FILE_SUFFIX,
|
||||
archive_file_suffix=ARCHIVE_FILE_SUFFIX,
|
||||
)
|
||||
|
||||
|
||||
@ -145,9 +153,9 @@ def drive_list():
|
||||
cd_conf=cd_conf,
|
||||
rm_conf=rm_conf,
|
||||
running_env=running_env(),
|
||||
server_info=server_info,
|
||||
version=server_info["version"],
|
||||
free_disk=int(disk["free"] / 1024 / 1024),
|
||||
cdrom_file_suffix=CDROM_FILE_SUFFIX,
|
||||
cdrom_file_suffix=tuple(server_info["sccd"]),
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user