Exemple #1
0
 def sTracks(self, source, ref, list_dic):
     """
     DBus signal handler - /Tracks/Tracks
     """
     #if source=="__heart__":
     #    print "MB Heart: "+str(list_dic)
     
     try:    ours=(ref.split(":")[0])=="musync"
     except: ours=False
     if ours:
         #print "sTracks: source(%s) ref(%s) list_dic: %s" % (source, ref, list_dic)
         mswitch.publish(self.agent, "mb_tracks", source, ref, list_dic)
     self.mb_detected_count+=1
 def sQTrack(self, ref, artist_name, track_name, priority):
     """
     DBus signal handler - /Tracks/qTrack
     
     @param ref: string - an opaque "reference"
     @param artist_name: string
     @param track_name:  string
     @param priority:    string [low|high]
     
     @todo: better error handling
     """
     try:    artist=str(artist_name)
     except: artist=None
     try:    track=str(track_name)
     except: track=None
     
     mswitch.publish(self.agent, "track?", ref, artist, track, priority)
    def tick(self, *_):
        """
        Performs message dispatch
        """
        
        tick_second = (self.tick_count % self.ticks_seconds) == 0 
        self.tick_count += 1
        
        #print "tick! ", tick_second
        
        mswitch.publish("__main__", "tick", self.ticks_seconds, tick_second)
        
        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()
                    
            except Empty:
                break
            continue            
        
        burst=5
        
        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()
                    
                burst -= 1
                if burst == 0:
                    break
            except Empty:
                break
            
            continue

        return True
    def tick(self):
        #print "tick (%s)" % time.time()
        self._manageUserMessage()
        
        while True:
            try:
                envelope=self.isq.get(block=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()
            except Empty:
                break
            
        burst=5
        while True:
            try:
                envelope=self.iq.get(block=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()                    
                burst -= 1
                if burst==0:
                    break
            except Empty:
                break

        self.count += 1
        mswitch.publish("__main__", "tick", self.count)
        
        if self.quitting:
            self.quit()
            self.loop.quit()
 def show(self, *_):
     print "menu: show"
     mswitch.publish(self, "__show__")
 def exit(self, *p):
     print "menu: exit"
     mswitch.publish(self, "__quit__")
Exemple #7
0
 def _chAuthorize(self, *_):
     """ Starts the authorization phase
     """  
     mswitch.publish(self, "start_authorize")
Exemple #8
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
Exemple #9
0
 def do_destroy(self, *_):
     mswitch.publish(self, "app_close")
Exemple #10
0
 def _chVerify(self, *_):
     """ Starts the verification phase
     """
     vc=self.eVerificationCode.get_text()
     mswitch.publish(self, "start_verify", vc)
Exemple #11
0
 def show(self, *_):
     mswitch.publish(self, "app_show")
Exemple #12
0
 def exit(self, *p):
     mswitch.publish(self, "__quit__")
Exemple #13
0
 def do_destroy(self, *_):
     print "ui.window: destroy"
     mswitch.publish(self, "__destroy__")
 def on_destroy(self):
     mswitch.publish(None, "__quit__", None)
     self.quitting=True
Exemple #15
0
 def rx_rating(self, source, timestamp, artist_name, album_name, track_name, rating):
     mswitch.publish(self, "rating", source, timestamp, artist_name, album_name, track_name, rating)
Exemple #16
0
 def sTracks(self, source, ref, list_dic):
     """
     DBus signal handler - /Tracks/Tracks
     """
     mswitch.publish(self.agent, "mb_tracks", source, ref, list_dic)
Exemple #17
0
 def rx_qrating(self, artist_name, album_name, track_name):
     mswitch.publish(self, "qrating", artist_name, album_name, track_name)