Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzeman committed Dec 23, 2016
2 parents 8018127 + b37f451 commit 75549f8
Show file tree
Hide file tree
Showing 1,561 changed files with 75,334 additions and 48,656 deletions.
36 changes: 32 additions & 4 deletions Trakttv.bundle/Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@
from fs_migrator import FSMigrator

FSMigrator.run()

# ------------------------------------------------
# Logger
# ------------------------------------------------

from plugin.core.logger import LoggerManager

LoggerManager.setup(storage=False)

# ------------------------------------------------
# Interface messages
# ------------------------------------------------

from plugin.core.message import InterfaceMessages

InterfaceMessages.bind()

# ------------------------------------------------
# Language
# ------------------------------------------------
Expand Down Expand Up @@ -93,6 +104,12 @@ def Start():
# Complete logger initialization
LoggerManager.setup(storage=True)

# Store current proxy details
Dict['proxy_host'] = Prefs['proxy_host']

Dict['proxy_username'] = Prefs['proxy_username']
Dict['proxy_password'] = Prefs['proxy_password']

# Store current language
Dict['language'] = Prefs['language']

Expand All @@ -113,7 +130,7 @@ def Api(*args, **kwargs):
)

return json.dumps(data)
except Exception, ex:
except Exception as ex:
Log.Error('Unable to process API request (args: %r, kwargs: %r) - %s', args, kwargs, ex)
return None

Expand Down Expand Up @@ -143,7 +160,7 @@ def ValidatePrefs():
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']:
if RestartRequired(last_activity_mode):
log.info('Restart required to apply changes, restarting plugin...')

def restart():
Expand All @@ -153,10 +170,21 @@ def restart():
# Restart plugin
Plex[':/plugins'].restart(PLUGIN_IDENTIFIER)

spawn(restart)
spawn(restart, daemon=True)
return MessageContainer(_("Success"), _("Success"))

# Fire configuration changed callback
spawn(Main.on_configuration_changed)
spawn(Main.on_configuration_changed, daemon=True)

return MessageContainer(_("Success"), _("Success"))


def RestartRequired(last_activity_mode):
if Preferences.get('activity.mode') != last_activity_mode:
return True

for key in ['language', 'proxy_host', 'proxy_username', 'proxy_password']:
if Prefs[key] != Dict[key]:
return True

return False
Loading

0 comments on commit 75549f8

Please sign in to comment.