def run_app(self): signal_handler = SignalHandler() signal_handler.register() message = check_update(suppress_uptodate=True) if message: logger.error(message) parser = MyArgumentParser(signal_handler=signal_handler) parser.configure() # first parse is just for debug result = parser.parser.parse_args(sys.argv[1:]) debug = result.debug # rumps.debug_mode(debug) # result = parser.parser.parse_args(['-c']) vicki = Vicki(debug=debug, player_backend=result.player_backend) vicki.player.player.set_argparser(result) # self.console = Console() # self.queue = multiprocessing.Queue() vicki.player.start() self.vicki = vicki self.parser = parser self.__run_bg__() self.run()
def run_app(self): signal_handler = SignalHandler() signal_handler.register() message = check_update(suppress_uptodate=True) if message: logger.error(message) parser = MyArgumentParser(signal_handler=signal_handler) parser.configure() # first parse is just for debug result = parser.parser.parse_args(sys.argv[1:]) debug = result.debug # rumps.debug_mode(debug) # result = parser.parser.parse_args(['-c']) vicki = Vicki(debug=debug, player_backend=result.player_backend) vicki.player.player.set_argparser(result) # self.console = Console() # self.queue = multiprocessing.Queue() vicki.player.start() self.vicki = vicki self.parser = parser self.__run_bg__() self.run()
def menu_quit(self, _): try: self.console.set_exit() self.vicki.player.shutdown() self.th.stop_all() except Exception as exc: logger.error(repr(exc)) rumps.quit_application()
def menu_quit(self, _): try: self.console.set_exit() self.vicki.player.shutdown() self.th.stop_all() except Exception as exc: logger.error(repr(exc)) rumps.quit_application()
def health_check(self): """ Cache backend health check """ status = True if self.get_safe_available_space() <= 0: logger.error('GDrive: No free space available!') status = False return status
def health_check(self): """ Cache backend health check """ status = True if self.get_safe_available_space() <= 0: logger.error('GDrive: No free space available!') status = False return status
def main(noblock=False): """ CLI Main, called from shell script :param noblock: Disable server thread lock-up, requires extra care to run :type noblock: bool """ signal_handler = SignalHandler() signal_handler.register() message = check_update(suppress_uptodate=True) if message: logger.error(message) parser = MyArgumentParser(signal_handler=signal_handler) parser.configure() try: parser.parse(noblock=noblock) except Exception as _: send_traceback(sys.exc_info(), __file__)
def linux_notify(cls, message, icon): """ Linux OSD using GI """ from gi.repository import Notify # pylint:disable=import-error if not os.environ.get('DISPLAY'): # try default os.environ['DISPLAY'] = ':0.0' Notify.init(__title__) icon_file = mkstemp()[1] with open(icon_file, 'wb') as fh: fh.write(icon) n = Notify.Notification.new(message, '', icon_file) try: n.show() except Exception as exc: # No X running, etc logger.error('OSD failed with: %r', exc) os.remove(icon_file)
def linux_notify(cls, message, icon): """ Linux OSD using GI """ from gi.repository import Notify # pylint:disable=import-error if not os.environ.get('DISPLAY'): # try default os.environ['DISPLAY'] = ':0.0' Notify.init(__title__) icon_file = mkstemp()[1] with open(icon_file, 'wb') as fh: fh.write(icon) n = Notify.Notification.new(message, '', icon_file) try: n.show() except Exception as exc: # No X running, etc logger.error('OSD failed with: %r', exc) os.remove(icon_file)
def async_worker(self): """ Asynchronous notifier """ while not self.exit: if not self.queue.empty(): message = self.queue.get() else: time.sleep(0.05) continue try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.ip, int(self.port))) _ = s.send(message) _ = s.recv(1024) self.queue.task_done() except Exception as exc: logger.error('TCPAsync worker failed with %r, restarting...', exc)
def prefer_shorter(video_metadata, query): duration = video_metadata[2].get('metadata', {}).get('contentDetails', {}).get('duration', {}) duration = DateMan.iso2hms(duration) duration = duration.split(':') duration.reverse() length = 0 try: for idx, _ in enumerate(duration): length += int(duration[idx]) * math_pow(60, idx) except Exception as _: logger.error('score:prefer_shorter:%r', duration) return 0 # less than 15 minutes if length <= 900: score = 0 else: score = -20 return score
def pause_resume(self, _): try: self.console.parse_command('pause') except Exception as exc: logger.error(repr(exc))
def pause_resume(self, _): try: self.console.parse_command('pause') except Exception as exc: logger.error(repr(exc))