swh:1:snp:7ce5f1105410d5ee1ad6abfdc873986c25b579e5
Tip revision: 33856ab3088005962e0bd22d26ada78905d84de2 authored by Dirk Roorda on 18 June 2018, 20:08:27 UTC
New main release 5.0.0
New main release 5.0.0
Tip revision: 33856ab
start.py
import webbrowser
from time import sleep
from subprocess import PIPE, Popen
from tf.server.common import getParam, getDebug, getConfig
from tf.server.data import TF_DONE
def main():
dataSource = getParam()
ddataSource = ('-d', dataSource) if getDebug() else (dataSource,)
if dataSource is not None:
config = getConfig(dataSource)
pService = None
pWeb = None
if config is not None:
try:
pService = Popen(
['python3', '-m', 'tf.server.service', dataSource],
stdout=PIPE, encoding='utf-8',
)
print(f'Loading data for {dataSource}. Please wait ...')
with pService.stdout as ph:
for line in ph:
print(line)
if line.rstrip() == TF_DONE:
break
print(f'Opening {dataSource} in browser')
pWeb = Popen(['python3', '-m', 'tf.server.web', *ddataSource])
sleep(2)
webbrowser.open(
f'{config.protocol}{config.host}:{config.webport}',
new=2,
autoraise=True,
)
if pWeb:
pWeb.wait()
except KeyboardInterrupt:
if pWeb:
pWeb.terminate()
print('Web server has stopped')
if pService:
pService.terminate()
print('TF service has stopped')