summaryrefslogtreecommitdiffstats
path: root/mountconfig/MicroHAL.py
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2023-01-19 18:01:26 +0100
committerMichele Calgaro <[email protected]>2023-01-20 13:05:37 +0900
commit94f5a3f12e1c61aa2f3cde2d7b260c08489336ac (patch)
tree9062a30a1d81a1a97e9397548e4ec48ae63c18a4 /mountconfig/MicroHAL.py
parentb9c0b6996a6da72f93baf50121a1be4a6fa48d2e (diff)
downloadtde-guidance-94f5a3f12e1c61aa2f3cde2d7b260c08489336ac.tar.gz
tde-guidance-94f5a3f12e1c61aa2f3cde2d7b260c08489336ac.zip
Drop python2 support.
Signed-off-by: Slávek Banko <[email protected]>
Diffstat (limited to 'mountconfig/MicroHAL.py')
-rwxr-xr-xmountconfig/MicroHAL.py76
1 files changed, 38 insertions, 38 deletions
diff --git a/mountconfig/MicroHAL.py b/mountconfig/MicroHAL.py
index 9a913fa..3d6fce5 100755
--- a/mountconfig/MicroHAL.py
+++ b/mountconfig/MicroHAL.py
@@ -326,8 +326,8 @@ class MicroHAL__(object):
# but it might be built as module, so we try to load that.
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
if retval > 0:
- print msg
- print "Couldn't load driver " + module + " for filesystem " + fs
+ print(msg)
+ print("Couldn't load driver " + module + " for filesystem " + fs)
# Force refresh of list of supported filesystems
self.supportedfs = None
return proc in self.getSupportedFileSystems()
@@ -632,73 +632,73 @@ class MicroHAL(object):
# Detect the end of this block of device data.
state = READING_TOP
- if u"info.category" in parsed_hash:
+ if "info.category" in parsed_hash:
new_device = None
- capabilities_string = u" ".join(parsed_hash[u"info.capabilities"])
+ capabilities_string = " ".join(parsed_hash["info.capabilities"])
capabilities = self._parseStringList(capabilities_string)
- category = self._parseString(' '.join(parsed_hash[u"info.category"]))
- if category==u"volume":
+ category = self._parseString(' '.join(parsed_hash["info.category"]))
+ if category=="volume":
# Is it a volume?
- is_disc = parsed_hash.get(u"volume.is_disc")
+ is_disc = parsed_hash.get("volume.is_disc")
if is_disc is not None and is_disc[0]=='true':
continue
- is_partition = parsed_hash.get(u"volume.is_partition")
+ is_partition = parsed_hash.get("volume.is_partition")
if is_partition is not None:
is_partition = is_partition[0]
if is_partition=='true':
new_device = Partition()
- new_device.num = int(parsed_hash[u"volume.partition.number"][0])
+ new_device.num = int(parsed_hash["volume.partition.number"][0])
partition_to_uid[new_device] = current_uid
- if u"info.parent" in parsed_hash:
- parent_uid = self._parseString(' '.join(parsed_hash[u"info.parent"]))
+ if "info.parent" in parsed_hash:
+ parent_uid = self._parseString(' '.join(parsed_hash["info.parent"]))
partition_to_uid[new_device] = parent_uid
else:
new_device = Disk()
uid_to_disk[current_uid] = new_device
- if u"volume.uuid" in parsed_hash:
- new_device.uuid = self._parseString(' '.join(parsed_hash[u"volume.uuid"]))
+ if "volume.uuid" in parsed_hash:
+ new_device.uuid = self._parseString(' '.join(parsed_hash["volume.uuid"]))
- if u"volume.label" in parsed_hash:
- new_device.label = self._parseString(parsed_hash[u"volume.label"][0])
+ if "volume.label" in parsed_hash:
+ new_device.label = self._parseString(parsed_hash["volume.label"][0])
# If HAL returns label beginning with '#', it usually means that the
# actual label contains an Unix path. So we replace '#' with '/'.
if len(new_device.label) and new_device.label[0]=='%':
new_device.label = new_device.label.replace('%', '/')
- if u"volume.size" in parsed_hash:
- size = parsed_hash[u"volume.size"][0]
+ if "volume.size" in parsed_hash:
+ size = parsed_hash["volume.size"][0]
new_device.size = self.formatSizeBytes(int(size))
else:
new_device.size = "?"
# is it a storage device?
- elif category==u"storage":
- storage_model = self._parseString(' '.join(parsed_hash[u"storage.model"]))
- storage_removable = parsed_hash[u"storage.removable"][0]==u"true"
+ elif category=="storage":
+ storage_model = self._parseString(' '.join(parsed_hash["storage.model"]))
+ storage_removable = parsed_hash["storage.removable"][0]=="true"
- if u"storage.cdrom" in capabilities:
+ if "storage.cdrom" in capabilities:
- if u"storage.cdrom.cdrw" in parsed_hash \
- and parsed_hash[u"storage.cdrom.cdrw"][0]==u"true":
+ if "storage.cdrom.cdrw" in parsed_hash \
+ and parsed_hash["storage.cdrom.cdrw"][0]=="true":
new_device = BurnerDisk()
else:
new_device= RemovableDisk()
- elif u"storage.floppy" in capabilities:
+ elif "storage.floppy" in capabilities:
new_device = FloppyDevice()
else:
- if u"storage.bus" in parsed_hash \
- and self._parseString(' '.join(parsed_hash[u"storage.bus"]))==u"usb":
+ if "storage.bus" in parsed_hash \
+ and self._parseString(' '.join(parsed_hash["storage.bus"]))=="usb":
new_device = USBDisk()
else:
@@ -711,8 +711,8 @@ class MicroHAL(object):
continue
# Handle the generic properties.
- new_device.dev = self._parseString(' '.join(parsed_hash[u"block.device"]))
- new_device.major = int(parsed_hash[u"block.major"][0])
+ new_device.dev = self._parseString(' '.join(parsed_hash["block.device"]))
+ new_device.major = int(parsed_hash["block.major"][0])
self.devices.append(new_device)
@@ -722,9 +722,9 @@ class MicroHAL(object):
parsed_hash[ parts[0] ] = parts[2:]
# Attach the partitions to thier devices.
- for partition in partition_to_uid.keys():
+ for partition in list(partition_to_uid.keys()):
parent = partition_to_uid[partition]
- if parent in uid_to_disk.keys():
+ if parent in list(uid_to_disk.keys()):
parent_device = uid_to_disk[parent]
parent_device.appendPartition(partition)
self.devices.remove(partition)
@@ -819,8 +819,8 @@ class MicroHAL(object):
# but it might be built as module, so we try to load that.
retval, msg = SimpleCommandRunner().run(["/sbin/modprobe",module])
if retval > 0:
- print msg
- print "Couldn't load driver " + module + " for filesystem " + fs
+ print(msg)
+ print("Couldn't load driver " + module + " for filesystem " + fs)
# Force refresh of list of supported filesystems
self.supportedfs = None
return proc in self.getSupportedFileSystems()
@@ -842,7 +842,7 @@ class MicroHAL(object):
for partition in item.partitions:
if partition.dev==device:
return partition.label
- print "No Label found for ",device
+ print("No Label found for ",device)
return ""
def getUUIDByDevice(self, device):
@@ -851,7 +851,7 @@ class MicroHAL(object):
#print partition, partition.getUUID()
if partition.dev==device:
return partition.uuid
- print "No UUID found for ",device
+ print("No UUID found for ",device)
return ""
def getDeviceByUUID(self, uuid):
@@ -870,19 +870,19 @@ class MicroHAL(object):
if __name__=='__main__':
hal = MicroHAL()
for item in hal.getDevices():
- print(str(item))
+ print((str(item)))
- print
+ print()
#"""
for item in hal.getDevices():
for partition in item.partitions:
- print partition, partition.getLabel()
+ print(partition, partition.getLabel())
#"""
#realhal = RealHAL()
#for item in realhal.getDevices():
# print(str(item))
- print
+ print()