@@ -366,10 +366,10 @@ def kill_browser_process():
366366 else :
367367 try :
368368 subprocess .call (['pkill' , processname_killed_atexit ])
369- except OSError as e :
369+ except OSError :
370370 try :
371371 subprocess .call (['killall' , processname_killed_atexit ])
372- except OSError as e :
372+ except OSError :
373373 loge ('Both commands pkill and killall failed to clean up the spawned browser process. Perhaps neither of these utilities is available on your system?' )
374374 delete_emrun_safe_firefox_profile ()
375375 # Clear the process name to represent that the browser is now dead.
@@ -567,7 +567,7 @@ def send_head(self):
567567
568568 def log_request (self , code ):
569569 # Filter out 200 OK messages to remove noise.
570- if code is not 200 :
570+ if code != 200 :
571571 SimpleHTTPRequestHandler .log_request (self , code )
572572
573573 def log_message (self , format , * args ):
@@ -588,7 +588,7 @@ def do_POST(self):
588588 dump_out_directory = 'dump_out'
589589 try :
590590 os .mkdir (dump_out_directory )
591- except :
591+ except OSError :
592592 pass
593593 filename = os .path .join (dump_out_directory , os .path .normpath (filename ))
594594 open (filename , 'wb' ).write (data )
@@ -598,7 +598,7 @@ def do_POST(self):
598598 system_info = json .loads (get_system_info (format_json = True ))
599599 try :
600600 browser_info = json .loads (get_browser_info (browser_exe , format_json = True ))
601- except :
601+ except ValueError :
602602 browser_info = ''
603603 data = {'system' : system_info , 'browser' : browser_info }
604604 self .send_response (200 )
@@ -630,7 +630,7 @@ def do_POST(self):
630630 i = data .index ('^' , 5 )
631631 seq_num = int (data [5 :i ])
632632 data = data [i + 1 :]
633- except :
633+ except ValueError :
634634 pass
635635
636636 is_exit = data .startswith ('^exit^' )
@@ -735,7 +735,7 @@ def find_gpu_model(model):
735735
736736 try :
737737 import_win32api_modules ()
738- except :
738+ except Exception :
739739 return []
740740
741741 for i in range (0 , 16 ):
@@ -760,13 +760,13 @@ def find_gpu_model(model):
760760 try :
761761 driverVersion = winreg .QueryValueEx (hVideoCardReg , 'DriverVersion' )[0 ]
762762 VideoCardDescription += ', driver version ' + driverVersion
763- except :
763+ except WindowsError :
764764 pass
765765
766766 try :
767767 driverDate = winreg .QueryValueEx (hVideoCardReg , 'DriverDate' )[0 ]
768768 VideoCardDescription += ' (' + driverDate + ')'
769- except :
769+ except WindowsError :
770770 pass
771771
772772 VideoCardMemorySize = winreg .QueryValueEx (hVideoCardReg , 'HardwareInformation.MemorySize' )[0 ]
@@ -831,7 +831,7 @@ def macos_get_gpu_info():
831831 memory = int (re .search ("VRAM (.*?): (.*) MB" , gpu ).group (2 ).strip ())
832832 gpus += [{'model' : model_name + ' (' + bus + ')' , 'ram' : memory * 1024 * 1024 }]
833833 return gpus
834- except :
834+ except Exception :
835835 pass
836836
837837
@@ -941,7 +941,7 @@ def win_get_file_properties(fname):
941941 strInfo [propName ] = win32api .GetFileVersionInfo (fname , strInfoPath )
942942
943943 props ['StringFileInfo' ] = strInfo
944- except :
944+ except Exception :
945945 pass
946946
947947 return props
@@ -954,7 +954,7 @@ def get_computer_model():
954954 with open (os .path .join (os .getenv ("HOME" ), '.emrun.hwmodel.cached' ), 'r' ) as f :
955955 model = f .read ()
956956 return model
957- except :
957+ except IOError :
958958 pass
959959
960960 try :
@@ -969,7 +969,7 @@ def get_computer_model():
969969 model = model .group (1 ).strip ()
970970 open (os .path .join (os .getenv ("HOME" ), '.emrun.hwmodel.cached' ), 'w' ).write (model ) # Cache the hardware model to disk
971971 return model
972- except :
972+ except Exception :
973973 hwmodel = check_output (['sysctl' , 'hw.model' ])
974974 hwmodel = re .search ('hw.model: (.*)' , hwmodel ).group (1 ).strip ()
975975 return hwmodel
@@ -1006,15 +1006,15 @@ def get_os_version():
10061006 version = ''
10071007 try :
10081008 version = ' ' + check_output (['wmic' , 'os' , 'get' , 'version' ]).split ('\n ' )[1 ].strip ()
1009- except :
1009+ except Exception :
10101010 pass
10111011 return productName [0 ] + version + bitness
10121012 elif MACOS :
10131013 return 'macOS ' + platform .mac_ver ()[0 ] + bitness
10141014 elif LINUX :
10151015 kernel_version = check_output (['uname' , '-r' ]).strip ()
10161016 return ' ' .join (platform .linux_distribution ()) + ', linux kernel ' + kernel_version + ' ' + platform .architecture ()[0 ] + bitness
1017- except :
1017+ except Exception :
10181018 return 'Unknown OS'
10191019
10201020
@@ -1037,7 +1037,7 @@ def get_system_memory():
10371037 return win32api .GlobalMemoryStatusEx ()['TotalPhys' ]
10381038 elif MACOS :
10391039 return int (check_output (['sysctl' , '-n' , 'hw.memsize' ]).strip ())
1040- except :
1040+ except Exception :
10411041 return - 1
10421042
10431043
@@ -1292,7 +1292,7 @@ def get_system_info(format_json):
12921292 else :
12931293 try :
12941294 unique_system_id = open (os .path .expanduser ('~/.emrun.generated.guid' ), 'r' ).read ().strip ()
1295- except :
1295+ except Exception :
12961296 import uuid
12971297 unique_system_id = str (uuid .uuid4 ())
12981298 try :
0 commit comments