def run(self): # Migrate server preferences Preferences.initialize() Preferences.migrate() # Try migrate administrator preferences try: Preferences.initialize(account=1) Preferences.migrate(account=1) except Account.DoesNotExist: log.debug('Unable to migrate administrator preferences, no account found')
def run(self): # Migrate server preferences Preferences.initialize() Preferences.migrate() # Try migrate administrator preferences try: Preferences.initialize(account=1) Preferences.migrate(account=1) except Account.DoesNotExist: log.debug( 'Unable to migrate administrator preferences, no account found' )
def ValidatePrefs(): # Retrieve plex token token_plex = AccountMigration.get_token(Request.Headers) # Retrieve current activity mode last_activity_mode = Preferences.get('activity.mode') if Request.Headers.get('X-Disable-Preference-Migration', '0') == '0': # Run account migration am = AccountMigration() am.run(token_plex) # Migrate server preferences Preferences.migrate() # Try migrate administrator preferences try: Preferences.initialize(account=1) Preferences.migrate(account=1) except Account.DoesNotExist: log.debug( 'Unable to migrate administrator preferences, no account found' ) else: log.debug('Ignoring preference migration (disabled by header)') # Restart if activity_mode has changed if Preferences.get('activity.mode') != last_activity_mode or Prefs[ 'language'] != Dict['language']: log.info('Restart required to apply changes, restarting plugin...') def restart(): # Delay until after `ValidatePrefs` returns time.sleep(3) # Restart plugin Plex[':/plugins'].restart(PLUGIN_IDENTIFIER) spawn(restart) return MessageContainer(_("Success"), _("Success")) # Fire configuration changed callback spawn(Main.on_configuration_changed) return MessageContainer(_("Success"), _("Success"))
def ValidatePrefs(): # Retrieve plex token token_plex = AccountMigration.get_token(Request.Headers) # Retrieve current activity mode last_activity_mode = Preferences.get('activity.mode') if Request.Headers.get('X-Disable-Preference-Migration', '0') == '0': # Run account migration am = AccountMigration() am.run(token_plex) # Migrate server preferences Preferences.migrate() # Try migrate administrator preferences try: Preferences.initialize(account=1) Preferences.migrate(account=1) except Account.DoesNotExist: log.debug('Unable to migrate administrator preferences, no account found') else: log.debug('Ignoring preference migration (disabled by header)') # Restart if activity_mode has changed if Preferences.get('activity.mode') != last_activity_mode: log.info('Activity mode has changed, restarting plugin...') def restart(): # Delay until after `ValidatePrefs` returns time.sleep(3) # Restart plugin Plex[':/plugins'].restart(PLUGIN_IDENTIFIER) spawn(restart) return MessageContainer("Success", "Success") # Fire configuration changed callback spawn(Main.on_configuration_changed) return MessageContainer("Success", "Success")
def ValidatePrefs(): # Retrieve plex token token_plex = AccountMigration.get_token(Request.Headers) # Retrieve current activity mode last_activity_mode = Preferences.get("activity.mode") if Request.Headers.get("X-Disable-Preference-Migration", "0") == "0": # Run account migration am = AccountMigration() am.run(token_plex) # Migrate server preferences Preferences.migrate() # Try migrate administrator preferences try: Preferences.initialize(account=1) Preferences.migrate(account=1) except Account.DoesNotExist: log.debug("Unable to migrate administrator preferences, no account found") else: log.debug("Ignoring preference migration (disabled by header)") # Restart if activity_mode has changed if RestartRequired(last_activity_mode): log.info("Restart required to apply changes, restarting plugin...") def restart(): # Delay until after `ValidatePrefs` returns time.sleep(3) # Restart plugin Plex[":/plugins"].restart(PLUGIN_IDENTIFIER) spawn(restart, daemon=True) return MessageContainer(_("Success"), _("Success")) # Fire configuration changed callback spawn(Main.on_configuration_changed, daemon=True) return MessageContainer(_("Success"), _("Success"))