예제 #1
0
파일: mpdc.py 프로젝트: milkypostman/wmpy
    def update(self):
        if self._mpd._sock is None and not self._connect():
            wmii.schedule(10, self.update)
            return

        self._update()
        wmii.schedule(5, self.update)
예제 #2
0
    def update(self):
        self.file.seek(0)
        try:
            data = self._parse(self.file)
        except IOError:
            wmii.schedule(60, self.update)
            return


        state = data['charging state']
        remaining = int(data['remaining capacity'].split()[0])
        if state == 'discharging':
            rate = int(data['present rate'].split()[0])
            timeleft = remaining / float(rate)
            hoursleft = int(timeleft)
            minutesleft = (timeleft - hoursleft) * 60
        else:
            hoursleft = 0
            minutesleft = 0

        if remaining < self.warn:
            self.widget.fg = '#000000'
            self.widget.bg = '#e7e700'
        elif remaining < self.low:
            self.widget.fg = '#000000'
            self.widget.bg = '#d70000'
        else:
            self.widget.fg = wmii.colors['normfg']
            self.widget.bg = wmii.colors['normbg']

        symbol = self.symbols[state]
        self.widget.show("%2d:%02d %s%2d%s" % (hoursleft, minutesleft, symbol, float(remaining)/self.capacity * 100, symbol) )

        wmii.schedule(60, self.update)
예제 #3
0
파일: cpu.py 프로젝트: milkypostman/wmpy
    def _update(cls, timeout=3):
        cls._file.seek(0)
        i = 0
        for line in cls._file:
            if cls._re.match(line):
                info = cls._sep.split(line)
                active = reduce(add, imap(int, info[1:4]))
                total = active + int(info[4])

                try:
                    difftotal = total - cls.data[i]['total']
                    diffactive = active - cls.data[i]['active']
                    cls.data[i]['usage'] = math.floor((float(diffactive) / difftotal) * 100)
                except KeyError:
                    cls.data[i] = {}
                except ZeroDivisionError:
                    cls.data[i]['usage'] = 0

                cls.data[i]['total'] = total
                cls.data[i]['active'] = active

                for w in cls._widgets.get(i, []):
                    w.show(str(cls.data[i]['usage']))

                i += 1

        wmii.schedule(timeout, cls._update)
예제 #4
0
파일: notice.py 프로젝트: milkypostman/wmpy
    def update(self):
        c = self.colors[self.color_index]
        self.widget.fg = c[0]
        self.widget.bg = c[1]
        self.widget.border = c[2]
        self.widget.show(self.text)

        if self.color_index > 0:
            self.color_index -= 1
            wmii.schedule(1, self.update)
예제 #5
0
파일: volume.py 프로젝트: milkypostman/wmpy
 def update(self):
     self._update()
     wmii.schedule(5, self.update)
예제 #6
0
파일: clock.py 프로젝트: milkypostman/wmpy
 def update(self):
     self.widget.show(time.strftime(self.format))
     wmii.schedule(1, self.update)