"finished" message also when skipping configuration backup
[enigma2.git] / lib / python / Components / DiskInfo.py
1 from GUIComponent import GUIComponent
2 from VariableText import VariableText
3 from os import statvfs
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(VariableText, GUIComponent):
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 = 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(("%d MB " + _("free diskspace")) % (free))
31
32         GUI_WIDGET = eLabel