def _retry_handler(self, exception): if (isinstance(exception, sqlite3.OperationalError) and # pylint: disable=no-member "database is locked" in g.UNICODE(exception)): g.log( "database is locked waiting: {}".format(self.path), "warning", ) g.wait_for_abort(0.1) else: super(SQLiteConnection, self)._retry_handler(exception)
def status_update_loop(self): while not g.abort_requested() and not self.cancelled: if g.wait_for_abort(10): raise KodiShutdownException( "Kodi Shutdown requested, cancelling download") try: self._update_status() g.log( self.progress_message.format( self.status, self.current_percent, self.get_display_speed(), self.seeds, )) if self.status == "finished": self._notify_user_of_completion() self._update_database() break if self.status == "downloading": self._do_download_frame() else: self._handle_failure("Unknown Failure at Debrid Provider") except KodiShutdownException: self._delete_transfer() break except Exception as e: self._delete_transfer() raise e
def _run(self): if self.runned_once(): return while not g.abort_requested() and self.running(): if g.wait_for_abort(.100): break g.HOME_WINDOW.setProperty(self._create_key("Running"), 'true')
def __exit__(self, exc_type, exc_val, exc_tb): [ g.HOME_WINDOW.clearProperty(self._create_key(i)) for i in self._trakt_ids if g.HOME_WINDOW.getProperty(self._create_key(i)) == self._handle ] while not g.abort_requested() and self._still_processing(): if g.wait_for_abort(.100): break
def _create_connection(self): retries = 0 while not retries == 50 and not g.abort_requested(): import sqlite3 try: connection = sqlite3.connect( # pylint: disable=no-member self.path, timeout=30, detect_types=sqlite3.PARSE_DECLTYPES, # pylint: disable=no-member isolation_level=None, check_same_thread=False) self._set_connection_settings(connection) return connection except sqlite3.OperationalError as error: # pylint: disable=no-member if "database is locked" in g.UNICODE(error): g.log( "database is locked waiting: {}".format(self.path), "warning", ) g.wait_for_abort(0.1) retries += 1
def onNotification(self, sender, method, data): if method == "System.OnWake": g.log("System.OnWake notification received" "info") xbmc.executebuiltin( 'RunPlugin("plugin://plugin.video.seren/?action=runMaintenance")' ) if not g.wait_for_abort( 15 ): # Sleep to make sure tokens refreshed during maintenance xbmc.executebuiltin( 'RunPlugin("plugin://plugin.video.seren/?action=syncTraktActivities")' ) return
def __exit__(self, exc_type, exc_val, exc_tb): for i in self._running_ids: g.clear_runtime_setting(self._create_key(i)) while not g.abort_requested() and self._still_processing(): if g.wait_for_abort(.100): break
def _run(self): while not g.abort_requested() and self._running(): if g.wait_for_abort(.100): break g.set_runtime_setting(self._create_key("Running"), True) self._check_ran_once_already()
do_update_news() validate_timezone_detected() try: g.clear_kodi_bookmarks() except TypeError: g.log( "Unable to clear bookmarks on service init. This is not a problem if it occurs immediately after install.", "warning") # Disable the restoration of reuselanguageinvoker addon.xml based on settings value on upgrade. # It can still be toggled in settings although initially it will show user's last setting value # This is in preparation for removal of user setting/toggle. # maintenance.toggle_reuselanguageinvoker( # True if g.get_setting("reuselanguageinvoker.status") == "Enabled" else False) g.wait_for_abort( 30) # Sleep for a half a minute to allow widget loads to complete. while not monitor.abortRequested(): xbmc.executebuiltin( 'RunPlugin("plugin://plugin.video.seren/?action=runMaintenance&action_args=updateCheck")' ) xbmc.executebuiltin( 'RunPlugin("plugin://plugin.video.seren/?action=runMaintenance")') if not g.wait_for_abort( 15): # Sleep to make sure tokens refreshed during maintenance xbmc.executebuiltin( 'RunPlugin("plugin://plugin.video.seren/?action=syncTraktActivities")' ) if g.wait_for_abort(60 * randint(13, 17)): break finally: del monitor
do_update_news() validate_timezone_detected() try: g.clear_kodi_bookmarks() except TypeError: g.log( "Unable to clear bookmarks on service init. This is not a problem if it occurs immediately after install.", "warning") # Disable the restoration of reuselanguageinvoker addon.xml based on settings value on upgrade. # It can still be toggled in settings although initially it will show user's last setting value # This is in preparation for removal of user setting/toggle. # maintenance.toggle_reuselanguageinvoker( # True if g.get_setting("reuselanguageinvoker.status") == "Enabled" else False) g.wait_for_abort( 30) # Sleep for a half a minute to allow widget loads to complete. while not monitor.abortRequested(): try: if g.get_bool_setting("general.checkAddonUpdates"): maintenance.check_for_addon_update() maintenance.run_maintenance() TraktSyncDatabase().sync_activities() except Exception: g.log("Background service failure", "error") g.log_stacktrace() if g.wait_for_abort(60 * randint(13, 17)): break finally: del monitor g.deinit()
do_update_news() g.clear_kodi_bookmarks() # Disable the restoration of reuselanguageinvoker addon.xml based on settings value on upgrade. # It can still be toggled in settings although initially it will show user's last setting value # This is in preparation for removal of user setting/toggle. # maintenance.toggle_reuselanguageinvoker( # True if g.get_setting("reuselanguageinvoker.status") == "Enabled" else False) while not monitor.abortRequested(): try: if g.get_bool_setting("general.checkAddonUpdates"): maintenance.check_for_addon_update() try: maintenance.run_maintenance() TraktSyncDatabase().sync_activities() except Exception as e: g.log("Background Service Failure", "error") g.log_stacktrace() if g.wait_for_abort(60 * randint(13, 17)): break except: # pylint: disable=bare-except g.log("Background service failure", "error") g.log_stacktrace() if g.wait_for_abort(60 * randint(13, 17)): break continue finally: del monitor g.deinit()
def _service_trigger_loop(self): while not g.wait_for_abort(0.5): self._handle_messages(self.get_messages())