Festplattenrestdauer in GB und MB

  • zeigt festplattenrestdauer im movieplayer in GB und MB an.



    [php]
    from GUIComponent import GUIComponent
    from VariableText import VariableText
    from os import statvfs


    from enigma import eLabel


    # TODO: Harddisk.py has similiar functions, but only similiar.
    # fix this to use same code
    class DiskInfo(VariableText, GUIComponent):
    FREE = 0
    USED = 1
    SIZE = 2

    def __init__(self, path, type, update = True):
    GUIComponent.__init__(self)
    VariableText.__init__(self)
    self.type = type
    self.path = path
    if update:
    self.update()

    def update(self):
    try:
    stat = statvfs(self.path)
    except OSError:
    return -1

    if self.type == self.FREE:
    free = stat.f_bfree * stat.f_bsize
    g,s = divmod(free,1073741824)
    m,s = divmod(s,1048576)
    self.setText(("%d GB and %d MB " + _("free diskspace")) % (g,m))


    GUI_WIDGET = eLabel
    [/php]