add DiskInfo component
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 29 Sep 2005 22:09:43 +0000 (22:09 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 29 Sep 2005 22:09:43 +0000 (22:09 +0000)
lib/python/Components/DiskInfo.py [new file with mode: 0644]
lib/python/Components/Makefile.am
lib/python/Components/__init__.py

diff --git a/lib/python/Components/DiskInfo.py b/lib/python/Components/DiskInfo.py
new file mode 100644 (file)
index 0000000..9bd774b
--- /dev/null
@@ -0,0 +1,32 @@
+from GUIComponent import *
+from VariableText import *
+import os
+
+from enigma import eLabel
+
+# TODO: Harddisk.py has similiar functions, but only similiar.
+# fix this to use same code
+class DiskInfo(GUIComponent, VariableText):
+       FREE = 0
+       USED = 1
+       SIZE = 2
+       
+       def __init__(self, path, type):
+               GUIComponent.__init__(self)
+               VariableText.__init__(self)
+               self.type = type
+               self.path = path
+               self.update()
+       
+       def update(self):
+               try:
+                       stat = os.statvfs(self.path)
+               except OSError:
+                       return -1
+               
+               if self.type == self.FREE:
+                       free = stat.f_bfree / 1000 * stat.f_bsize / 1000
+                       self.setText("%dMB free diskspace" % (free))
+
+       def createWidget(self, parent):
+               return eLabel(parent)
index 6e99f78..2000eb9 100644 (file)
@@ -8,4 +8,4 @@ install_DATA = \
        EventInfo.py Label.py ServiceScan.py VolumeBar.py                       \
        GUIComponent.py MenuList.py TextInput.py __init__.py MovieList.py                               \
        InputDevice.py ServicePosition.py SetupDevices.py Harddisk.py                                           \
-       AVSwitch.py Network.py RFmod.py
+       AVSwitch.py Network.py RFmod.py DiskInfo.py
index 1e47fde..a625939 100644 (file)
@@ -5,5 +5,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
        "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar",
        "components", "config", "TimerList", "TimeInput", "MovieList", 
        "InputDevice",  "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
-       "IPNameserver", "Network" ]
-
+       "IPNameserver", "Network", "RFmon", "DiskInfo" ]