mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-25 14:26:28 +00:00
Inquire the backend for device capabilities instead of Web UI assumptions (#688)
* Add capabilities to RaCtlCmds.get_device_types() to return the image file support boolean, and list of supported block sizes. * Inquire rascsi backend about the min block size rather than hard coding values in the web UI. * Add class methods for getting lists of certain device types. * Use the new class methods to get lists of device types in the web ui. * Make use of the new class methods in the oled script. * Remove now unused constants, and simplify logic in common_settings * Improve device name mapping to extend the existing dictionary rather than creating a new data structure. * Use jinja2 sort filters instead of sorting in python code. Removing redundant variables. * Introduce the get_device_name() utility method which returns the translated name for a device acronym. Use the new method to display device name when attaching devices. * Fix typo * Rename Support Device to Periperal Device. General tweaks to UI strings. * Tweak UI string. * Fix error.
This commit is contained in:
@@ -43,12 +43,6 @@ from pi_cmds import get_ip_and_host
|
||||
from rascsi.ractl_cmds import RaCtlCmds
|
||||
from rascsi.socket_cmds import SocketCmds
|
||||
|
||||
from rascsi.common_settings import (
|
||||
REMOVABLE_DEVICE_TYPES,
|
||||
NETWORK_DEVICE_TYPES,
|
||||
SUPPORT_DEVICE_TYPES,
|
||||
)
|
||||
|
||||
parser = argparse.ArgumentParser(description="RaSCSI OLED Monitor script")
|
||||
parser.add_argument(
|
||||
"--rotation",
|
||||
@@ -166,7 +160,8 @@ LINE_SPACING = 8
|
||||
FONT = ImageFont.truetype('resources/type_writer.ttf', FONT_SIZE)
|
||||
|
||||
IP_ADDR, HOSTNAME = get_ip_and_host()
|
||||
|
||||
REMOVABLE_DEVICE_TYPES = ractl_cmd.get_removable_device_types()
|
||||
SUPPORT_DEVICE_TYPES = ractl_cmd.get_support_device_types()
|
||||
|
||||
def formatted_output():
|
||||
"""
|
||||
@@ -188,11 +183,12 @@ def formatted_output():
|
||||
else:
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['status']}")
|
||||
# Special handling of devices that don't use image files
|
||||
elif line["device_type"] in (NETWORK_DEVICE_TYPES):
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['vendor']} "
|
||||
f"{line['product']}")
|
||||
elif line["device_type"] in (SUPPORT_DEVICE_TYPES):
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['product']}")
|
||||
if line["vendor"] == "RaSCSI":
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['product']}")
|
||||
else:
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['vendor']} "
|
||||
f"{line['product']}")
|
||||
# Print only the Vendor/Product info if it's not generic RaSCSI
|
||||
elif line["vendor"] not in "RaSCSI":
|
||||
output.append(f"{line['id']} {line['device_type'][2:4]} {line['file']} "
|
||||
|
||||
Reference in New Issue
Block a user