Example #1
0
 def sCondition(self, *p):
     """
     DBus signal handler
     """
     if len(p) == 2:
         if (p[0]=="ButtonPressed"):
             mswitch.publish(self.agent, "mk_key_press", p[1], "source1", 5)
Example #2
0
 def sMsg(self, *p):
     """
     DBus signal handler
     """
     #print "*** Eventor: %s" % p
     if len(p) == 1:
         mswitch.publish(self.agent, "eventor_msg", p[0])
Example #3
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min=False
        tick_hour=False
        tick_day=False
        tick_second = (self.tick_count % self.ticks_second) == 0 
        self.tick_count += 1
        
        if tick_second:
            self.sec_count += 1

            tick_min=(self.sec_count % 60)==0
            if tick_min:
                self.min_count += 1
                
                tick_hour=(self.min_count % 60)==0
                if tick_hour:
                    self.hour_count += 1
                    
                    tick_day=(self.hour_count % 24)==0
                    if tick_day:
                        self.day_count += 1
        
        #print "tick! ", tick_second
        mswitch.publish("__main__", "__tick__", self.ticks_second, 
                        tick_second, tick_min, tick_hour, tick_day, 
                        self.sec_count, self.min_count, self.hour_count, self.day_count)
        
        #(src_agent, agent_name, agent_id, 
        #  interest_map, responsesInterestList, 
        #  iq, isq, processor, low_priority_burst_size=5)
        quit=process_queues(False, self, "__main__", "__main__", 
                       self.interests, self.responsesInterests,
                       self.iq, self.isq, message_processor 
                       )
        ## for gobject... just in case
        return True
def main(debug=False):
    try:
        
        try:    
            import pysqueezecenter #@UnresolvedImport @UnusedImport
        except: 
            raise Exception("package 'pysqueezecenter' is required")
        
        from jld_scripts.res import get_res_path
        icon_path=get_res_path()
        
        from jld_scripts.agents.squeeze_tray import TrayAgent
        _ta=TrayAgent(APP_NAME, icon_path, ICON_NAME, HELP_URL, APP_VERSION)

        import jld_scripts.agents.mk_dbus #@UnusedImport
        import jld_scripts.agents.squeeze #@UnusedImport
        
        from jld_scripts.agents.notifier import notify, NotifierAgent #@Reimport
        _na=NotifierAgent(APP_NAME, ICON_NAME)
        _na.start()

        from jld_scripts.agents.clock import Clock #@Reimport        
        _clk=Clock(TIME_BASE)
        _clk.init()
        
        mswitch.publish("__main__", "debug", debug)
        
        import gtk
        gtk.main()
        
    except KeyboardInterrupt:
        mswitch.quit()
        sys.exit(1)        
        
    except Exception,e:
        notify(APP_NAME, "There was an error: %s" % e)
        mswitch.quit()
        sys.exit(1)
Example #5
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min = False
        tick_hour = False
        tick_day = False
        tick_second = (self.tick_count % self.ticks_second) == 0
        self.tick_count += 1

        if tick_second:
            self.sec_count += 1

            if (self.sec_count % self.REFRESH_TIMEOUT) == 0:
                self.refreshUi()

            tick_min = (self.sec_count % 60) == 0
            if tick_min:
                self.min_count += 1

                tick_hour = (self.min_count % 60) == 0
                if tick_hour:
                    self.hour_count += 1

                    tick_day = (self.hour_count % 24) == 0
                    if tick_day:
                        self.day_count += 1

        # print "tick! ", tick_second
        mswitch.publish(
            "__main__",
            "__tick__",
            self.ticks_second,
            tick_second,
            tick_min,
            tick_hour,
            tick_day,
            self.sec_count,
            self.min_count,
            self.hour_count,
            self.day_count,
        )

        # (src_agent, agent_name, agent_id,
        #  interest_map, responsesInterestList,
        #  iq, isq, processor, low_priority_burst_size=5)
        quit = process_queues(
            self, "__main__", "__main__", self.interests, self.responsesInterests, self.iq, self.isq, message_processor
        )
        if quit:
            self.on_destroy()

        """
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    break
                
            except Empty:
                break
            continue            
        
        burst=self.LOW_PRIORITY_MESSAGE_BURST_SIZE
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    break
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue
        """
        ## for gobject... just in case
        return True
Example #6
0
 def show(self, *_):
     mswitch.publish(self, "app_show")
Example #7
0
 def sound_only(self, widget):
     state=widget.active
     mswitch.publish(self, "mode_sound_only", state)
Example #8
0
 def disable_eventor(self, widget):
     state=widget.active
     mswitch.publish(self, "mode_disable_eventor", state)
Example #9
0
 def exit(self, *p):
     mswitch.publish(self, "__quit__")
     gtk.main_quit()
Example #10
0
 def sCondition(self, *p):
     """
     DBus signal handler
     """
     if len(p) == 2:
         mswitch.publish(self.agent, "mk_key_press", p[1].lower(), "source2", 1)
Example #11
0
    def tick(self, *_):
        """
        Performs message dispatch
        """
        tick_min = False
        tick_hour = False
        tick_day = False
        tick_second = (self.tick_count % self.ticks_second) == 0
        self.tick_count += 1

        if tick_second:
            self.sec_count += 1

            if (self.sec_count % self.REFRESH_TIMEOUT) == 0:
                self.refreshUi()

            tick_min = (self.sec_count % 60) == 0
            if tick_min:
                self.min_count += 1

                tick_hour = (self.min_count % 60) == 0
                if tick_hour:
                    self.hour_count += 1

                    tick_day = (self.hour_count % 24) == 0
                    if tick_day:
                        self.day_count += 1

        #print "tick! ", tick_second
        mswitch.publish("__main__", "__tick__", self.ticks_second, tick_second,
                        tick_min, tick_hour, tick_day, self.sec_count,
                        self.min_count, self.hour_count, self.day_count)

        #(src_agent, agent_name, agent_id,
        #  interest_map, responsesInterestList,
        #  iq, isq, processor, low_priority_burst_size=5)
        quit = process_queues(self, "__main__", "__main__", self.interests,
                              self.responsesInterests, self.iq, self.isq,
                              message_processor)
        if quit:
            self.on_destroy()
        """
        while True:
            try:     
                envelope=self.isq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.isq))
                if quit:
                    self.on_destroy()
                    break
                
            except Empty:
                break
            continue            
        
        burst=self.LOW_PRIORITY_MESSAGE_BURST_SIZE
        
        while True:
            try:     
                envelope=self.iq.get(False)
                quit, mtype, handled=mdispatch(self, "__main__", envelope)
                if handled==False:
                    mswitch.publish(self.__class__, "__interest__", (mtype, False, self.iq))
                if quit:
                    self.on_destroy()
                    break
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue
        """
        ## for gobject... just in case
        return True
Example #12
0
 def pub(self, msgType, *pargs, **kargs):
     mswitch.publish("__main__", msgType, *pargs, **kargs)