You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe someone has a good solution to write this code here nicer than it is at the moment?
def cdrom():
lshw = json.loads(str(subprocess.check_output("sudo lshw -json -C disk", shell=True).decode()))
for disk in lshw:
if "cdrom" in disk['id']:
capabilities = {disk['capabilities'][k] for k in disk['capabilities'].keys() - {'removable'}} # removes key 'removable' from dictionary
capabilities = sorted(capabilities) # sorts capabilities alphabetically
capabilities = str(capabilities).replace("[","").replace("]", "").replace("'", "") # creates an output that makes sense without square braclets [] and single quotation mark '
if "DVD" in capabilities:
return "DVD-Laufwerk: " + capabilities
elif "CD" in capabilities:
return "CD-Laufwerk: " + capabilities
else:
continue
return "Laufwerk: Kein Laufwerk verbaut"
The text was updated successfully, but these errors were encountered:
dmuiX
changed the title
Code is not that nice
Code in cdrom could be better formatted
Mar 31, 2021
Maybe someone has a good solution to write this code here nicer than it is at the moment?
The text was updated successfully, but these errors were encountered: