Skip to content

Commit

Permalink
Run black on the main.py code
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalex committed Jun 15, 2019
1 parent 1e996ed commit 1f3d57c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

if pew.ui.platform == "android":
from jnius import autoclass
PythonActivity = autoclass('org.kivy.android.PythonActivity')
File = autoclass('java.io.File')
Timezone = autoclass('java.util.TimeZone')

PythonActivity = autoclass("org.kivy.android.PythonActivity")
File = autoclass("java.io.File")
Timezone = autoclass("java.util.TimeZone")


# TODO check for storage availibility, allow user to chose sd card or internal
Expand Down Expand Up @@ -62,8 +63,8 @@ def setUp(self):
"""

# Set loading screen
loader_page = os.path.abspath(os.path.join('assets', '_load.html'))
self.loader_url = 'file://{}'.format(loader_page)
loader_page = os.path.abspath(os.path.join("assets", "_load.html"))
self.loader_url = "file://{}".format(loader_page)
self.kolibri_loaded = False
self.view = pew.ui.WebUIView("Kolibri", self.loader_url, delegate=self)

Expand Down Expand Up @@ -91,7 +92,11 @@ def page_loaded(self, url):
# history after first load so that the user cannot go back to the loading screen. We cannot clear the history
# during load, so we do it here.
# For more info, see: https://stackoverflow.com/questions/8103532/how-to-clear-webview-history-in-android
if pew.ui.platform == 'android' and not self.kolibri_loaded and url != self.loader_url:
if (
pew.ui.platform == "android"
and not self.kolibri_loaded
and url != self.loader_url
):
# FIXME: Change pew to reference the native webview as webview.native_webview rather than webview.webview
# for clarity.
self.kolibri_loaded = True
Expand All @@ -100,7 +105,7 @@ def page_loaded(self, url):
def wait_for_server(self):
from kolibri.utils import server

home_url = 'http://localhost:5000'
home_url = "http://localhost:5000"

# test url to see if servr has started
def running():
Expand All @@ -112,12 +117,14 @@ def running():

# Tie up this thread until the server is running
while not running():
logging.info('Kolibri server not yet started, checking again in one second...')
logging.info(
"Kolibri server not yet started, checking again in one second..."
)
time.sleep(1)

# Check for saved URL, which exists when the app was put to sleep last time it ran
saved_state = self.view.get_view_state()
logging.debug('Persisted View State: {}'.format(self.view.get_view_state()))
logging.debug("Persisted View State: {}".format(self.view.get_view_state()))

if "URL" in saved_state and saved_state["URL"].startswith(home_url):
pew.ui.run_on_main_thread(self.view.load_url(saved_state["URL"]))
Expand All @@ -128,6 +135,7 @@ def running():
def get_main_window(self):
return self.view


if __name__ == "__main__":
app = Application()
app.run()

0 comments on commit 1f3d57c

Please sign in to comment.