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:
|
||||
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)
|
||||
|
|
|
@ -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:
|
||||
<now function will be executed immediately. Get its results:>
|
||||
result = win.result
|
||||
result = d.result
|
||||
"""
|
||||
def __init__(self, function=None):
|
||||
self.window = None
|
||||
|
|
Loading…
Reference in a new issue