def verify(self): import remotecontrol.protocoldispatcher as proto # to fix AttributeError: 'module' object has no attribute if self._statefile.is_processing(): log.info('update successfully finished') self._statefile.remove() seq = self._sequence_number_file.read() proto.ProtocolDispatcher().send( 'ack_ok', sequence=seq, message= 'software update successfully finished, current version {}'. format(version.VERSION)) self._sequence_number_file.remove() elif self._statefile.is_failed(): log.error( 'failed to update software, previous version was restored') self._statefile.remove() seq = self._sequence_number_file.read() proto.ProtocolDispatcher().send( 'ack_fail', sequence=seq, message= 'failed to update software, previous version {} was restored'. format(version.VERSION)) self._sequence_number_file.remove()
def app(): with rw_fs.Storage(restart_player=False): hardware.platfrom.fix_file_permissions(config.Config().storage_path()) xmain.start() wallpaper.Wallpaper().load() if config.Config().enable_clockd(): threads.run_in_thread(clockd.Clockd().run) # threads.run_in_thread(networkd.Networkd().run) # threads.run_in_thread(hdmihotplug.HdmiHotplug(onchange_callback=resolution_changed).run) player = playercontroller.PlayerController() player.start_playlist() proto = protocoldispatcher.ProtocolDispatcher() threads.run_in_thread(webui.start, ['0.0.0.0', 8080]) while True: track = player.current_track_name() pos = player.current_track_posiotion() proto.send('now_playing', track=track, percent_position=pos) watchdog.Watchdog().feed() time.sleep(20)
def start_playlist(self): mediafiles_fullpath = files.mediafiles_path() if not os.path.exists(mediafiles_fullpath): with rw_fs.Storage(restart_player=False): files.mkdir(mediafiles_fullpath) playlist_fullpath = loader.Loader().filepath() if not os.path.exists(playlist_fullpath): log.error("playlist file '{f}' does not exists".format( f=playlist_fullpath)) return protocoldispatcher.ProtocolDispatcher().send( 'playlist_begin', files=loader.Loader(playlist_fullpath).list_all_files()) self._scheduler.set_playlist(playlist.Playlist())
def _onresume(self, item, position_seconds): log.debug("on resume: " + item.filename + " (from {} seconds)".format(position_seconds)) proto.ProtocolDispatcher().send('track_resume', item=item, position_seconds=position_seconds)
def _onsuspend(self, item, position_seconds): log.debug("on suspend: " + item.filename + " (at {} seconds)".format(position_seconds)) proto.ProtocolDispatcher().send('track_suspend', item=item, position_seconds=position_seconds)
def _onerror(self, item, message): log.debug("on error: " + item.filename + " : " + message) self._watchdog.reset() proto.ProtocolDispatcher().send('playback_error', item=item, message=message)
def _onstop(self, item): log.debug("on stop: " + item.filename) proto.ProtocolDispatcher().send('track_end', item=item)
def _onplay(self, item): log.debug("on play: " + item.filename) proto.ProtocolDispatcher().send('track_begin', item=item)