Skip to content

Commit bcf1551

Browse files
authored
[emrun] Remove stale comments and fix ruff warnings. NFC (#26805)
The exceptions are apparently just aliases in recent versions of python `(error[UP024][*]: Replace aliased errors with 'OSError')`.
1 parent 1ae24a4 commit bcf1551

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

emrun.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# University of Illinois/NCSA Open Source License. Both these licenses can be
55
# found in the LICENSE file.
66

7-
# This file needs to run on older version of python too (even python 2!) so
8-
# suppress these upgrade warnings:
9-
# ruff: noqa: UP015, UP024, UP021, UP025
10-
117
"""emrun: Tool for running an .html page as if it was a standard executable file.
128
139
Usage: emrun <options> filename.html <args to program>
@@ -612,7 +608,7 @@ def send_head(self):
612608

613609
try:
614610
f = open(path, 'rb')
615-
except IOError:
611+
except OSError:
616612
self.send_error(404, "File not found: " + path)
617613
return None
618614

@@ -848,19 +844,19 @@ def find_gpu_model(model):
848844
hVideoCardReg = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, CleanVideoCardString)
849845
try:
850846
VideoCardDescription = winreg.QueryValueEx(hVideoCardReg, 'Device Description')[0]
851-
except WindowsError:
847+
except OSError:
852848
VideoCardDescription = winreg.QueryValueEx(hVideoCardReg, 'DriverDesc')[0]
853849

854850
try:
855851
driverVersion = winreg.QueryValueEx(hVideoCardReg, 'DriverVersion')[0]
856852
VideoCardDescription += ', driver version ' + driverVersion
857-
except WindowsError:
853+
except OSError:
858854
pass
859855

860856
try:
861857
driverDate = winreg.QueryValueEx(hVideoCardReg, 'DriverDate')[0]
862858
VideoCardDescription += f' ({driverDate})'
863-
except WindowsError:
859+
except OSError:
864860
pass
865861

866862
VideoCardMemorySize = winreg.QueryValueEx(hVideoCardReg, 'HardwareInformation.MemorySize')[0]
@@ -870,7 +866,7 @@ def find_gpu_model(model):
870866
vram = int(VideoCardMemorySize)
871867
if not find_gpu_model(VideoCardDescription):
872868
gpus += [{'model': VideoCardDescription, 'ram': vram}]
873-
except WindowsError:
869+
except OSError:
874870
pass
875871
return gpus
876872

@@ -1030,7 +1026,7 @@ def win_get_file_properties(fname):
10301026

10311027
strInfo = {}
10321028
for propName in propNames:
1033-
strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
1029+
strInfoPath = '\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
10341030
# print str_info
10351031
strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)
10361032

@@ -1046,7 +1042,7 @@ def get_computer_model():
10461042
with open(os.path.join(os.getenv("HOME"), '.emrun.hwmodel.cached'), encoding='utf-8') as f:
10471043
model = f.read()
10481044
return model
1049-
except IOError:
1045+
except OSError:
10501046
pass
10511047

10521048
try:
@@ -1167,7 +1163,7 @@ def win_get_default_browser():
11671163
parts = shlex.split(cmd)
11681164
if len(parts):
11691165
return [parts[0]]
1170-
except WindowsError:
1166+
except OSError:
11711167
logv("Unable to find default browser key in Windows registry. Trying fallback.")
11721168

11731169
# Fall back to 'start "" %1', which we have to treat as if user passed --serve-forever, since

0 commit comments

Comments
 (0)