Clean code
This commit is contained in:
parent
3971e24b95
commit
a547dd790c
2 changed files with 5 additions and 9 deletions
|
@ -282,7 +282,9 @@ def init():
|
||||||
while retry:
|
while retry:
|
||||||
retry = False
|
retry = False
|
||||||
if not plexapp.ACCOUNT.authToken:
|
if not plexapp.ACCOUNT.authToken:
|
||||||
token = authorize()
|
from .windows import background
|
||||||
|
with background.BackgroundContext(function=authorize) as d:
|
||||||
|
token = d.result
|
||||||
|
|
||||||
if not token:
|
if not token:
|
||||||
LOG.info('FAILED TO AUTHORIZE')
|
LOG.info('FAILED TO AUTHORIZE')
|
||||||
|
@ -326,12 +328,6 @@ def requirePlexPass():
|
||||||
|
|
||||||
|
|
||||||
def authorize():
|
def authorize():
|
||||||
from .windows import background
|
|
||||||
with background.BackgroundContext(function=_authorize) as win:
|
|
||||||
return win.result
|
|
||||||
|
|
||||||
|
|
||||||
def _authorize():
|
|
||||||
from .windows import signin, background
|
from .windows import signin, background
|
||||||
|
|
||||||
background.setSplash(False)
|
background.setSplash(False)
|
||||||
|
|
|
@ -49,9 +49,9 @@ class BackgroundContext(object):
|
||||||
Context Manager to open a Plex background window - in the background. This
|
Context Manager to open a Plex background window - in the background. This
|
||||||
will e.g. ensure that you can capture key-presses
|
will e.g. ensure that you can capture key-presses
|
||||||
Use like this:
|
Use like this:
|
||||||
with BackgroundContext(function) as win:
|
with BackgroundContext(function) as d:
|
||||||
<now function will be executed immediately. Get its results:>
|
<now function will be executed immediately. Get its results:>
|
||||||
result = win.result
|
result = d.result
|
||||||
"""
|
"""
|
||||||
def __init__(self, function=None):
|
def __init__(self, function=None):
|
||||||
self.window = None
|
self.window = None
|
||||||
|
|
Loading…
Reference in a new issue