fix inverted setting (meaning was inverted too)
[enigma2.git] / lib / python / Components / DiskInfo.py
1 from GUIComponent import *
2 from VariableText import *
3 import os
4
5 from enigma import eLabel
6
7 # TODO: Harddisk.py has similiar functions, but only similiar.
8 # fix this to use same code
9 class DiskInfo(GUIComponent, VariableText):
10         FREE = 0
11         USED = 1
12         SIZE = 2
13         
14         def __init__(self, path, type, update = True):
15                 GUIComponent.__init__(self)
16                 VariableText.__init__(self)
17                 self.type = type
18                 self.path = path
19                 if update:
20                         self.update()
21         
22         def update(self):
23                 try:
24                         stat = os.statvfs(self.path)
25                 except OSError:
26                         return -1
27                 
28                 if self.type == self.FREE:
29                         free = stat.f_bfree / 1000 * stat.f_bsize / 1000
30                         self.setText(("%dMB " + _("free diskspace")) % (free))
31
32         def createWidget(self, parent):
33                 return eLabel(parent)