Skip to content

Commit

Permalink
Prepare for more refactored code
Browse files Browse the repository at this point in the history
[Information.py]
- Prepare for updated "InputDevice.py" where the remote control indexes are moved from global variables to class variables.
- Prepare for the new "MountManager.py" screen by adopting matching names for disk labels where the word "Capacity" is now "Size" and the word "Mountpoint" is now "Mount".

[InputDevice.py]
- Move the global remote control index values to become class based values.
  • Loading branch information
IanSav committed Oct 31, 2024
1 parent dfe5625 commit f81035a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions lib/python/Components/InputDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@

MODULE_NAME = __name__.split(".")[-1]

REMOTE_MODEL = 0
REMOTE_RCTYPE = 1
REMOTE_NAME = 2
REMOTE_DISPLAY_NAME = 3

config.inputDevices = ConfigSubsection()


Expand Down Expand Up @@ -197,6 +192,11 @@ def loadKeyboard(self, index):


class RemoteControl:
REMOTE_MODEL = 0
REMOTE_RCTYPE = 1
REMOTE_NAME = 2
REMOTE_DISPLAY_NAME = 3

knownCompatibleRemotes = [
("gb0", "gb1", "gb2", "gb3", "gb4"),
("ini0", "ini1", "ini2", "ini3", "ini4", "ini5", "ini6", "ini7", "ini8"),
Expand Down Expand Up @@ -226,9 +226,9 @@ def __init__(self):
default = "0"
for index, remote in enumerate(self.remotes):
index = str(index)
rcChoices.append((index, remote[REMOTE_DISPLAY_NAME]))
if self.model == remote[REMOTE_MODEL] and self.rcType == remote[REMOTE_RCTYPE] and self.rcName in [x.strip() for x in remote[REMOTE_NAME].split(",")]:
print(f"[InputDevice] Default remote control identified as '{remote[REMOTE_DISPLAY_NAME]}'. (model='{self.model}', rcName='{self.rcName}', rcType='{self.rcType}')")
rcChoices.append((index, remote[self.REMOTE_DISPLAY_NAME]))
if self.model == remote[self.REMOTE_MODEL] and self.rcType == remote[self.REMOTE_RCTYPE] and self.rcName in [x.strip() for x in remote[self.REMOTE_NAME].split(",")]:
print(f"[InputDevice] Default remote control identified as '{remote[self.REMOTE_DISPLAY_NAME]}'. (model='{self.model}', rcName='{self.rcName}', rcType='{self.rcType}')")
default = index
config.inputDevices.remotesIndex = ConfigSelection(choices=rcChoices, default=default)
self.remote = self.loadRemoteControl(BoxInfo.getItem("RCMapping"))
Expand Down
24 changes: 12 additions & 12 deletions lib/python/Screens/Information.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from Components.config import config
from Components.Console import Console
from Components.Harddisk import Harddisk, harddiskmanager
from Components.InputDevice import REMOTE_DISPLAY_NAME, REMOTE_NAME, REMOTE_RCTYPE, remoteControl
from Components.InputDevice import remoteControl
from Components.Label import Label
from Components.Network import iNetwork
from Components.NimManager import nimmanager
Expand Down Expand Up @@ -1403,13 +1403,13 @@ def findPackageRevision(package, packageList):
if self.extraSpacing:
info.append("")
rcIndex = int(config.inputDevices.remotesIndex.value)
info.append(formatLine("P1", _("RC identification"), f"{remoteControl.remotes[rcIndex][REMOTE_DISPLAY_NAME]} (Index: {rcIndex})"))
rcName = remoteControl.remotes[rcIndex][REMOTE_NAME]
info.append(formatLine("P1", _("RC identification"), f"{remoteControl.remotes[rcIndex][remoteControl.REMOTE_DISPLAY_NAME]} (Index: {rcIndex})"))
rcName = remoteControl.remotes[rcIndex][remoteControl.REMOTE_NAME]
info.append(formatLine("P1", _("RC selected name"), rcName))
boxName = BoxInfo.getItem("rcname")
if boxName != rcName:
info.append(formatLine("P1", _("RC default name"), boxName))
rcType = remoteControl.remotes[rcIndex][REMOTE_RCTYPE]
rcType = remoteControl.remotes[rcIndex][remoteControl.REMOTE_RCTYPE]
info.append(formatLine("P1", _("RC selected type"), rcType))
boxType = BoxInfo.getItem("rctype")
if boxType != rcType:
Expand Down Expand Up @@ -1499,8 +1499,8 @@ def findPackageRevision(package, packageList):
if hddList:
for hdd in hddList:
hdd = hdd[1]
capacity = hdd.diskSize() * 1000000
info.append(formatLine("P1", hdd.model(), f"{scaleNumber(capacity)} ({scaleNumber(capacity, 'Iec')})"))
diskSize = hdd.diskSize() * 1000000
info.append(formatLine("P1", hdd.model(), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
else:
info.append(formatLine("H", _("No hard disks detected.")))
info.append("")
Expand Down Expand Up @@ -1944,8 +1944,8 @@ def displayInformation(self):
diskSize = stat.f_blocks * stat.f_frsize
diskFree = stat.f_bfree * stat.f_frsize
diskUsed = diskSize - diskFree
info.append(formatLine("P2", _("Mountpoint"), partition.mountpoint))
info.append(formatLine("P2", _("Capacity"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P2", _("Mount"), partition.mountpoint))
info.append(formatLine("P2", _("Size"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P2", _("Used"), f"{scaleNumber(diskUsed)} ({scaleNumber(diskUsed, 'Iec')})"))
info.append(formatLine("P2", _("Free"), f"{scaleNumber(diskFree)} ({scaleNumber(diskFree, 'Iec')})"))
break
Expand All @@ -1958,7 +1958,7 @@ def displayInformation(self):
info.append(formatLine("S1", hdd.getDeviceName(), hdd.bus()))
info.append(formatLine("P2", _("Model"), hdd.model()))
diskSize = hdd.diskSize() * 1000000
info.append(formatLine("P2", _("Capacity"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P2", _("Size"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P2", _("Sleeping"), (_("Yes") if hdd.isSleeping() else _("No"))))
for partition in partitions:
if partition.device and join("/dev", partition.device).startswith(hdd.getDeviceName()):
Expand All @@ -1967,8 +1967,8 @@ def displayInformation(self):
diskSize = stat.f_blocks * stat.f_frsize
diskFree = stat.f_bfree * stat.f_frsize
diskUsed = diskSize - diskFree
info.append(formatLine("P3", _("Mountpoint"), partition.mountpoint))
info.append(formatLine("P3", _("Capacity"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P3", _("Mount"), partition.mountpoint))
info.append(formatLine("P3", _("Size"), f"{scaleNumber(diskSize)} ({scaleNumber(diskSize, 'Iec')})"))
info.append(formatLine("P3", _("Used"), f"{scaleNumber(diskUsed)} ({scaleNumber(diskUsed, 'Iec')})"))
info.append(formatLine("P3", _("Free"), f"{scaleNumber(diskFree)} ({scaleNumber(diskFree, 'Iec')})"))
else:
Expand All @@ -1985,7 +1985,7 @@ def displayInformation(self):
info.append(formatLine("S1", data[5]))
if data[0]:
info.append(formatLine("P2", _("Network address"), data[0]))
info.append(formatLine("P2", _("Capacity"), data[1]))
info.append(formatLine("P2", _("Size"), data[1]))
info.append(formatLine("P2", _("Used"), f"{data[2]} ({data[4]})"))
info.append(formatLine("P2", _("Free"), data[3]))
else:
Expand Down

0 comments on commit f81035a

Please sign in to comment.