Clean code

This commit is contained in:
croneter 2018-10-02 07:56:43 +02:00
parent 3971e24b95
commit a547dd790c
2 changed files with 5 additions and 9 deletions

View file

@ -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)

View file

@ -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