예제 #1
0
 def st_push_mode(self):
     """
     MuSync seems empty... populate it!
     """
     now=time.time()
     count=0
     while True:
         try:    
             rbid=self.song_entries_with_ratings.pop()
         except:
             break
         
         try:
             dbe=self.db.entry_lookup_by_id(int(rbid))
             e=EntryHelper.track_details2(self.db, dbe)
         except Exception,e:
             print "!! PUSH MODE: get track details: exception: %s" % e
             #Bus.publish(self.__class__, "llog", "err/", "error", "Fetching track details from RB")
             continue
         
         #h_out_rating(self, source, ref, timestamp, artist_name, album_name, track_name, rating):
         try:
             Bus.publish(self.__class__, "out_rating", "rb", "rb:%s" % rbid,
                         int(now), 
                         e["artist_name"], e["album_name"], e["track_name"], 
                         e["rating"])
         except Exception,e:
             print "!! PUSH MODE: publish: exception: %s" % e
예제 #2
0
    def __init__(self):

        self.iq = Queue()  # normal queue
        self.ipq = Queue()  # high priority queue

        mswitch.subscribe(self.NAME, self.iq, self.ipq)
        Bus.subscribe(self.NAME, "*", self.h_msg)
예제 #3
0
    def _dispatcher(self, mtype, *pargs):

        ## let's not repeart ourselves...
        if mtype == "__tick__":
            return

        try:
            handled = Bus.publish(self.NAME, mtype, *pargs)
            return (handled, False)
        except Exception, e:
            print "BridgeAgent._dispatcher: pargs: %s ---- exception: %s" % (str(pargs), e)
            return (False, False)
예제 #4
0
    def __init__(self):
        self.song_entries=[]
        self.song_entries_with_ratings=[]
        
        self.load_completed=False
        self.appname=None
        
        self.state="wait_load_completed"
        self.musync_detected=False
        self.musync_lastest_timestamp=None
        self.musync_lastest_ratings_count=None
        
        
        Bus.subscribe(self.__class__, "__tick__",           self.h_tick)
        Bus.subscribe(self.__class__, "rb_shell",           self.h_rb_shell)
        Bus.subscribe(self.__class__, "rb_load_completed",  self.h_rb_load_completed)
        Bus.subscribe(self.__class__, "musync_in_updated",  self.h_musync_in_updated)
        Bus.subscribe(self.__class__, "entry_added",        self.h_entry_added)
        Bus.subscribe(self.__class__, "entry_changed",      self.h_entry_changed)
        Bus.subscribe(self.__class__, "entry_deleted", self.h_entry_deleted)
        Bus.subscribe(self.__class__, "appname",       self.h_appname)
        Bus.subscribe(self.__class__, "devmode",       self.h_devmode)

        ## get configuration, the tricky way ;-)
        Bus.publish(self.__class__, "appname?")
        Bus.publish(self.__class__, "devmode?")
        
        self.sm=StateManager(self.appname)