Esempio n. 1
0
    def mw_biff_update(self):

        # A thread is working on checking that pesky mail
        # Sleep some more.
        if self.mw_biff_set_message == ():
            self.events.add_timer(event.TimerEvent(BiffEventType, after = 15))

        # If a mail check thread has finished, display
        # the message, if any, and reschedule a tick
        elif self.mw_biff_set_message:
            text, ding = self.mw_biff_set_message
            self.mw_biff_update_message(text, ding)

            self.mw_biff_set_message = None
            self.events.add_timer(event.TimerEvent(BiffEventType, after = 12))

        # Else its time to start a new thread
        elif self.mw_biff_set_message is None:
            import thread

            # Indicate that we're working on it
            self.mw_biff_set_message = ()

            thread.start_new_thread(self.mw_biff_start_check, ())

            # Give the other thread three seconds to check for new mail.
            # If it takes longer than that, we're probably having NFS problems.

            self.events.add_timer(event.TimerEvent(BiffEventType, after = 3))
Esempio n. 2
0
    def mw_acpi_poll(self, force=0):
        # Recheck in 30 seconds: schedule this before polling, if that
        # produces an exception in parsing the ACPI info
        self.events.add_timer(event.TimerEvent(TimerEventType, after=30))

        newstatus = self.mw_acpi_interface.poll(force)
        self.mw_acpi_update(newstatus)
Esempio n. 3
0
    def mw_clock_update(self):
        t = time.localtime(time.time())
        s = time.strftime(self.mw_clock_format, t)
        self.mw_clock_message.set_text(s)

        wmanager.debug('clock', 'updated to "%s", rescheduling in %d seconds',
                       s, 61 - t[5])

        # Trig a timer when minute change
        self.events.add_timer(event.TimerEvent(ClockEventType,
                                               after=61 - t[5]))
Esempio n. 4
0
        def mw_xmms_update(self):
            try:
                stime = xmms.get_output_time()
                stitle = xmms.get_playlist_title(xmms.get_playlist_pos())

                if stitle:
                    minutes = stime/1000.0/60
                    seconds = (minutes-int(minutes))*60

                    # Format the message
                    self.wm_xmms_message.set_text('%s %d:%02d' %
                                                  (stitle,
                                                   minutes,seconds))
                self.events.add_timer(event.TimerEvent(XMMSTimerEvent,
                                                       after = 1))
            except:
                # There was some problem, so we'll try again in 20 seconds.
                self.events.add_timer(event.TimerEvent(XMMSTimerEvent,
                                                       after = 20))
                import traceback
                traceback.print_exc()
Esempio n. 5
0
    def mw_apm_update(self):
        msg, beeps = self.mw_apm_interface.get()

        self.mw_apm_message.set_text(msg)

        # Beep if status have changed
        if beeps:
            for i in range(beeps):
                self.display.bell(100)

        # Recheck in 30 seconds
        self.events.add_timer(event.TimerEvent(TimerEventType, after=30))
Esempio n. 6
0
    def mw_watchfiles_tick(self, evt):
        msgs = []
        for file in self.mw_watchfiles:
            msg = file.update()
            if msg:
                msgs.append(msg)

        msg = '  '.join(msgs)

        if self.mw_watchfiles_last_msg != msg:
            self.mw_watchfiles_last_msg = msg
            self.mw_watchfiles_message.set_text(msg)

        self.events.add_timer(event.TimerEvent(TimerEventType, after = self.mw_watchfiles_interval))
Esempio n. 7
0
        def mw_gmail_update(self):
            try:

                ga = libgmail.GmailAccount(self.account, self.password)
                ga.login()

                #result = ga.getMessagesByFolder('inbox', True)
                unread = ga.getUnreadMsgCount()
                inbox = self.getInboxMsgCount(ga)

                # Format the message
                self.wm_gmail_message.set_text('%d/%d' % (unread, inbox))
            except:
                import traceback
                traceback.print_exc()
                self.wm_gmail_message.set_text('N.A.')

            # Check again in 10 minutes.
            self.events.add_timer(event.TimerEvent(GMAILTimerEvent, after=600))
Esempio n. 8
0
    def mixer_status_view(self, devs=None, stereo=0, timeout=5):
        if self.mixer_interface is None:
            wmanager.debug('mixer', 'no mixer interface')
            return

        if devs is None:
            devs = self.mixer_devs.keys()

        msg = ''
        for dev in devs:
            try:
                val = self.mixer_mute_devs[dev]
                valstr = 'MUTE:%s' % val
            except KeyError:
                try:
                    values = self.mixer_devs[dev]

                    if type(values) is types.TupleType:
                        if stereo:
                            valstr = '%s:%s' % values
                        else:
                            valstr = str(values[0])
                    else:
                        valstr = str(values)
                except KeyError:
                    valstr = 'N/A'

            msg = '%s  [%s %s]' % (msg, dev, valstr)

        if self.mixer_status_msg is None:
            self.mixer_status_msg = self.current_screen.modestatus_new(msg)
        else:
            self.mixer_status_msg.set(msg)

        if self.mixer_timer_event is not None:
            self.mixer_timer_event.cancel()

        self.mixer_timer_event = event.TimerEvent(MixerTimeoutEventType,
                                                  after=timeout)
        self.events.add_timer(self.mixer_timer_event)
Esempio n. 9
0
    def mw_biff_update(self):
        text, ding = self.mw_biff_check_mail()
        self.mw_biff_update_message(text, ding)

        # Trig a timer to recheck in 15 seconds
        self.events.add_timer(event.TimerEvent(BiffEventType, after = 15))
Esempio n. 10
0
        def mw_xmms2_update(self):
            """Update the mode window message.
            
            Query the artist and title of the currently-playing tracko and set
            the message accordingly.

            """
            if self.mw_xmms2_connection.get_fd() == -1:
                self.mw_xmms2_connect()
            else:
                result = self.mw_xmms2_connection.playback_current_id()
                result.wait()
                if result.iserror():
                    print "mw_xmms2: playback current id returns error, %s" % result.get_error()

                    self.wm_xmms2_message.set_text("XMMS2 Error: %s" % result.get_error())

                    # There was some problem, so we'll try again in 20 seconds.
                    self.events.add_timer(event.TimerEvent(XMMS2ReconnectEvent, after = 20))

                if result.value() == 0:
                    curstatus = "Stopped"

                else:
                    result = self.mw_xmms2_connection.medialib_get_info(result.value())
                    result.wait()
                    if result.iserror():
                        print "mw_xmms2: medialib get info returns error, %s" % result.get_error()

                        self.wm_xmms2_message.set_text("XMMS2 Error: %s" % result.get_error())

                        # There was some problem, so we'll try again in 20 seconds.
                        self.events.add_timer(event.TimerEvent(XMMS2ReconnectEvent, after = 20))

                    minfo = result.value()
                    try:
                        duration = self.mw_xmms2_ms_to_time(minfo["duration"])
                    except KeyError:
                        duration = "?:??"

                    try:
                        artist = minfo["artist"]
                    except KeyError:
                        artist = "No artist"

                    try:
                        title = minfo["title"]
                    except KeyError:
                        title = "No title"

                    if artist == "No artist" and title == "No title":
                        try:
                            stitle = minfo["file"]
                        except KeyError:
                            stitle = "No file"
                    else:
                        stitle = "%s - %s" % (title, artist)


                    result = self.mw_xmms2_connection.playback_playtime()
                    result.wait()
                    if result.iserror():
                        print "mw_xmms2: playback playtime returns error, %s" % result.get_error()

                        self.wm_xmms2_message.set_text("XMMS2 Error: %s" % result.get_error())

                        # There was some problem, so we'll try again in 20 seconds.
                        self.events.add_timer(event.TimerEvent(XMMS2ReconnectEvent, after = 20))

                    stime = result.value()
                    elapsed = self.mw_xmms2_ms_to_time(stime)


                    result = self.mw_xmms2_connection.playback_status()
                    result.wait()
                    if result.iserror():
                        print "mw_xmms2: playback status returns error, %s" % result.get_error()

                        self.wm_xmms2_message.set_text("XMMS2 Error: %s" % result.get_error())

                        # There was some problem, so we'll try again in 20 seconds.
                        self.events.add_timer(event.TimerEvent(XMMS2ReconnectEvent, after = 20))

                    status = "Unknown"
                    statnum = result.value()
                    if statnum == xmmsclient.PLAYBACK_STATUS_STOP:
                        status = "Stopped"
                    elif statnum == xmmsclient.PLAYBACK_STATUS_PLAY:
                        status = "Playing"
                    elif statnum == xmmsclient.PLAYBACK_STATUS_PAUSE:
                        status = "Paused"

                    # Format the message
                    if status == "Stopped":
                        curstatus = '%s <%s>' % (status, stitle)
                    else:
                        curstatus = '%s <%s> [%s/%s]' % (status, stitle, elapsed, duration)

                self.events.add_timer(event.TimerEvent(XMMS2TimerEvent, after = 1))

                self.wm_xmms2_message.set_text(str(curstatus))
Esempio n. 11
0
    def mw_load_update(self):
        msg = self.mw_load_interface.get(self)
        self.mw_load_message.set_text(msg)

        self.events.add_timer(event.TimerEvent(LoadTimerEvent, after = 60))