mirror of https://gitlab.com/baco/winsysinfo.git
Add method to print values to stdout
Added __str__ method to SystemInformation class.
This commit is contained in:
parent
cf10b7d2b5
commit
cee144f27a
|
@ -143,6 +143,19 @@ class SystemInformation:
|
|||
f.write('HDD:\t{}\n'.format(hdd_string))
|
||||
f.write('OS:\t{}\n'.format(self.os))
|
||||
|
||||
def __str__(self):
|
||||
part_strs = []
|
||||
for p in self.hdd_free:
|
||||
part_strs.append('{} {:.2f}GB free'.format(p[0], p[1]/(1024**3)))
|
||||
hdd_string = ', '.join(part_strs)
|
||||
return '\n'.join(['CPU:\t{}'.format(self.cpu),
|
||||
'Video:\t{}'.format(self.graphics),
|
||||
'RAM:\t{:.2f}GB total'
|
||||
.format(self.total_ram/(1024**3)),
|
||||
'HDD:\t{}'.format(hdd_string),
|
||||
'OS:\t{}'.format(self.os)])
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys = SystemInformation()
|
||||
sys.save()
|
||||
print(sys)
|
||||
|
|
Loading…
Reference in New Issue