Add method to print values to stdout

Added __str__ method to SystemInformation class.
This commit is contained in:
Dionisio E Alonso 2015-04-09 17:45:11 -03:00
parent cf10b7d2b5
commit cee144f27a
1 changed files with 13 additions and 0 deletions

View File

@ -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)