From a547dd790cf16852cdb716d7bbdb1f1132f50c08 Mon Sep 17 00:00:00 2001 From: croneter Date: Tue, 2 Oct 2018 07:56:43 +0200 Subject: [PATCH] Clean code --- resources/lib/plex.py | 10 +++------- resources/lib/windows/background.py | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/resources/lib/plex.py b/resources/lib/plex.py index 15a89fa6..c49fc5e8 100644 --- a/resources/lib/plex.py +++ b/resources/lib/plex.py @@ -282,7 +282,9 @@ def init(): while retry: retry = False if not plexapp.ACCOUNT.authToken: - token = authorize() + from .windows import background + with background.BackgroundContext(function=authorize) as d: + token = d.result if not token: LOG.info('FAILED TO AUTHORIZE') @@ -326,12 +328,6 @@ def requirePlexPass(): def authorize(): - from .windows import background - with background.BackgroundContext(function=_authorize) as win: - return win.result - - -def _authorize(): from .windows import signin, background background.setSplash(False) diff --git a/resources/lib/windows/background.py b/resources/lib/windows/background.py index 869d46a4..1d92e6a7 100644 --- a/resources/lib/windows/background.py +++ b/resources/lib/windows/background.py @@ -49,9 +49,9 @@ class BackgroundContext(object): Context Manager to open a Plex background window - in the background. This will e.g. ensure that you can capture key-presses Use like this: - with BackgroundContext(function) as win: + with BackgroundContext(function) as d: - result = win.result + result = d.result """ def __init__(self, function=None): self.window = None