mirror of https://gitlab.com/baco/winsysinfo.git
Better error handling using exceptions by name
This commit is contained in:
parent
271fffee79
commit
8b3c471361
|
@ -57,7 +57,7 @@ class SystemInformation:
|
|||
'{}\\0000'.format(reg_key),
|
||||
'HardwareInformation.AdapterString')
|
||||
reg_keys.add(reg_key)
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
video_cards = []
|
||||
|
@ -68,14 +68,14 @@ class SystemInformation:
|
|||
'SYSTEM\\CurrentControlSet\\Control\\Video\\'
|
||||
'{}\\0000'.format(video_card),
|
||||
'Device Description')
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
device_descrption = get_registry_value(
|
||||
'HKEY_LOCAL_MACHINE',
|
||||
'SYSTEM\\CurrentControlSet\\Control\\Video\\'
|
||||
'{}\\0000'.format(video_card),
|
||||
'DriverDesc')
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
device_descrption = 'Failed to obtain video adapter.'
|
||||
video_cards.append(device_descrption)
|
||||
return '\n\t'.join(video_cards)
|
||||
|
@ -123,10 +123,10 @@ class SystemInformation:
|
|||
os = get('ProductName')
|
||||
try:
|
||||
sp = get('CSDVersion')
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
sp = 'n' + get('CSDBuildNumber')
|
||||
except:
|
||||
except FileNotFoundError:
|
||||
sp = '(no service pack found)'
|
||||
build = get('CurrentBuildNumber')
|
||||
return '{} {} (build {})'.format(os, sp, build)
|
||||
|
|
Loading…
Reference in New Issue