mirror of https://gitlab.com/baco/winsysinfo.git
Rewrite of data saving and storing
Moved all the output formatting strings to the save method of class SystemInformation. Now data stored in class members are the raw output of class methods.
This commit is contained in:
parent
8b3c471361
commit
a9269dd622
|
@ -25,15 +25,11 @@ def get_registry_value(key, subkey, value):
|
|||
|
||||
class SystemInformation:
|
||||
def __init__(self):
|
||||
self.cpu = 'CPU:\t{}'.format(self._cpu().strip())
|
||||
self.graphics = 'Video:\t{}'.format(self._graphics())
|
||||
self.cpu = self._cpu().strip()
|
||||
self.graphics = self._graphics()
|
||||
self.totalRam, self.availableRam = self._ram()
|
||||
self.ram = 'RAM:\t{:.2f}GB total'.format(self.totalRam/(1024**3))
|
||||
hdd = []
|
||||
for part in self._disk_c():
|
||||
hdd.append('{} {:.2f}GB free'.format(part[0], part[1]/(1024**3)))
|
||||
self.hdFree = 'HDD:\t{}'.format(', '.join(hdd))
|
||||
self.os = 'OS:\t{}'.format(self._os_version())
|
||||
self.hdFree = self._disk_c()
|
||||
self.os = self._os_version()
|
||||
|
||||
def _cpu(self):
|
||||
return get_registry_value(
|
||||
|
@ -132,14 +128,18 @@ class SystemInformation:
|
|||
return '{} {} (build {})'.format(os, sp, build)
|
||||
|
||||
def save(self):
|
||||
hdd = []
|
||||
for part in self.hdFree:
|
||||
hdd.append('{} {:.2f}GB free'.format(part[0], part[1]/(1024**3)))
|
||||
hdstring = ', '.join(hdd)
|
||||
with open('system_information.txt', 'w') as f:
|
||||
f.write('System Information\n'
|
||||
'==================\n\n')
|
||||
f.write(self.cpu + '\n')
|
||||
f.write(self.graphics + '\n')
|
||||
f.write(self.ram + '\n')
|
||||
f.write(self.hdFree + '\n')
|
||||
f.write(self.os + '\n')
|
||||
f.write('CPU:\t{}\n'.format(self.cpu))
|
||||
f.write('Video:\t{}\n'.format(self.graphics))
|
||||
f.write('RAM:\t{:.2f}GB total\n'.format(self.totalRam/(1024**3)))
|
||||
f.write('HDD:\t{}\n'.format(hdstring))
|
||||
f.write('OS:\t{}\n'.format(self.os))
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys = SystemInformation()
|
||||
|
|
Loading…
Reference in New Issue