fix movieplayer
[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):
15                 GUIComponent.__init__(self)
16                 VariableText.__init__(self)
17                 self.type = type
18                 self.path = path
19                 self.update()
20         
21         def update(self):
22                 try:
23                         stat = os.statvfs(self.path)
24                 except OSError:
25                         return -1
26                 
27                 if self.type == self.FREE:
28                         free = stat.f_bfree / 1000 * stat.f_bsize / 1000
29                         self.setText(("%dMB " + _("free diskspace")) % (free))
30
31         def createWidget(self, parent):
32                 return eLabel(parent)