+ added check for Tor to be ready before openhome works
* fixed not being able to stop Onionr when awaiting onboarding survey to be finished
This commit is contained in:
parent
3bb51a16e1
commit
353b2f1c63
5 changed files with 44 additions and 12 deletions
|
@ -3,9 +3,12 @@
|
|||
Open the web interface properly into a web browser
|
||||
"""
|
||||
import webbrowser
|
||||
from time import sleep
|
||||
|
||||
import logger
|
||||
from onionrutils import getclientapiserver
|
||||
import config
|
||||
from onionrutils.localcommand import local_command
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -22,8 +25,27 @@ import config
|
|||
"""
|
||||
|
||||
|
||||
def _tell_if_ui_not_ready():
|
||||
if local_command('/torready') != 'true':
|
||||
logger.warn('The UI is not ready yet, waiting on Tor to start.', terminal=True)
|
||||
|
||||
|
||||
def _wait_for_ui_to_be_ready():
|
||||
if config.get('general.offline_mode', False) or \
|
||||
not config.get('transports.tor', True) or \
|
||||
config.get('tor.use_existing_tor'):
|
||||
return
|
||||
_tell_if_ui_not_ready()
|
||||
while local_command('/torready') != 'true':
|
||||
sleep(0.5)
|
||||
logger.info("Tor is ready, opening UI", terminal=True)
|
||||
|
||||
|
||||
def get_url() -> str:
|
||||
"""Build UI URL string and return it."""
|
||||
onboarding = ""
|
||||
if not config.get('onboarding.done', False):
|
||||
onboarding = "onboarding/"
|
||||
try:
|
||||
url = getclientapiserver.get_client_API_server()
|
||||
except FileNotFoundError:
|
||||
|
@ -32,7 +54,7 @@ def get_url() -> str:
|
|||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
url = 'http://%s/%s#%s' % (url, onboarding, config.get('client.webpassword'))
|
||||
logger.info('Onionr web interface URL: ' + url, terminal=True)
|
||||
return url
|
||||
|
||||
|
@ -50,7 +72,8 @@ def open_home():
|
|||
'Onionr seems to not be running (could not get api host)',
|
||||
terminal=True)
|
||||
else:
|
||||
url = 'http://%s/#%s' % (url, config.get('client.webpassword'))
|
||||
_wait_for_ui_to_be_ready()
|
||||
url = get_url()
|
||||
logger.info(
|
||||
'If Onionr does not open automatically, use this URL: ' + url,
|
||||
terminal=True)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue