grzegorz-clients/main.py

33 lines
918 B
Python
Raw Normal View History

2018-02-26 22:55:01 +01:00
#!/usr/bin/env python3
2018-02-28 22:17:44 +01:00
import os
from remi import start
from grzegorz_clients import api, gui
2018-02-26 22:55:01 +01:00
# config must be a object with the attributes seen in default_config.py:
2018-02-26 22:55:01 +01:00
def main(config):
start_kwargs = {}
for attr in ("address", "port", "hostname", "websocket_port",
"username", "password", "standalone", "start_browser",
"multiple_instance", "enable_file_cache"):
assert hasattr(config, attr), f"Config has no attribute {attr!r}!"
start_kwargs[attr] = getattr(config, attr)
assert hasattr(config, "api_base"), f"Config has no attribute 'api_base'!"
2018-03-02 18:27:33 +01:00
if config.standalone:#it's picky :(
start_kwargs = {"standalone":config.standalone}
2018-02-26 22:55:01 +01:00
# start the webserver:
api.set_endpoint(config.api_base)
2018-02-26 22:55:01 +01:00
start(
gui.MyApp,
2018-02-26 22:55:01 +01:00
title = "Gregorz",
**start_kwargs
2018-02-26 22:55:01 +01:00
)
if __name__ == "__main__":
if not os.path.exists("config.py"):
shutil.copy("default_config.py", "config.py")
import config
main(config)