def init_services(self): ''' Initializes music service structures :return: Structure of Playback devices representing each available music service to the Pi ''' services = [] # attempt to initialize local service. If it fails, don't load that # service try: cachePath = self.run_dir + ".mood_switch_cache/" # make directory if missing if not (os.path.exists(cachePath)): os.makedirs(cachePath) # make services local_service = LocalService(self.run_dir + "local_music/") radio_service = RadioService() # init a single player for all music services self.player = Playback.constructPlayer() # add services services.append(Playback(self.player, local_service, cachePath)) # remote services, such as the radio service will constantly # throw errors if there is no X11 (although they appear to work) # So they are disabled if X11 is missing if (os.environ.get("DISPLAY") != None): services.append(Playback(self.player, radio_service, cachePath)) except ServiceException: print("Warning: No local music found") return services
def init_services(self): ''' Initializes music service structures :return: Structure of Playback devices representing each available music service to the Pi ''' services = [] # attempt to initialize local service. If it fails, don't load that # service try: cachePath = self.run_dir + ".mood_switch_cache/" # make directory if missing if not(os.path.exists(cachePath)): os.makedirs(cachePath) # make services local_service = LocalService(self.run_dir + "local_music/") radio_service = RadioService() # init a single player for all music services self.player = Playback.constructPlayer() # add services services.append(Playback(self.player, local_service, cachePath)) # remote services, such as the radio service will constantly # throw errors if there is no X11 (although they appear to work) # So they are disabled if X11 is missing if (os.environ.get("DISPLAY") != None): services.append( Playback(self.player, radio_service, cachePath)) except ServiceException: print("Warning: No local music found") return services