2018-02-26 22:55:01 +01:00
|
|
|
#!/usr/bin/env python3
|
2018-03-06 14:28:04 +01:00
|
|
|
import os, sys
|
2018-03-03 00:41:14 +01:00
|
|
|
from remi import start
|
2018-03-06 14:28:04 +01:00
|
|
|
from threading import Timer
|
2018-03-04 04:02:49 +01:00
|
|
|
from grzegorz_clients import api, remi_ui
|
2018-03-03 00:41:14 +01:00
|
|
|
|
2018-02-26 22:55:01 +01:00
|
|
|
|
2018-03-02 18:08:05 +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):
|
2018-03-02 18:08:05 +01:00
|
|
|
start_kwargs = {}
|
2018-03-03 00:43:33 +01:00
|
|
|
for attr in ("address", "port", "host_name", "websocket_port",
|
2018-03-02 18:08:05 +01:00
|
|
|
"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:
|
2018-03-02 18:35:10 +01:00
|
|
|
api.set_endpoint(config.api_base)
|
2018-02-26 22:55:01 +01:00
|
|
|
start(
|
2018-03-04 04:02:49 +01:00
|
|
|
remi_ui.RemiApp,
|
2018-02-26 22:55:01 +01:00
|
|
|
title = "Gregorz",
|
2018-03-02 18:08:05 +01:00
|
|
|
**start_kwargs
|
2018-02-26 22:55:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2018-03-06 14:28:04 +01:00
|
|
|
if "--no-volume" in sys.argv[1:]:
|
|
|
|
print("Keeping volume down")
|
|
|
|
def keep_volume_down():
|
|
|
|
api.set_volume(0)
|
|
|
|
Timer(5, keep_volume_down).start()
|
|
|
|
Timer(5, keep_volume_down).start()
|
|
|
|
|
2018-02-26 22:55:01 +01:00
|
|
|
if not os.path.exists("config.py"):
|
|
|
|
shutil.copy("default_config.py", "config.py")
|
|
|
|
import config
|
2018-03-06 14:28:04 +01:00
|
|
|
|
2018-02-26 22:55:01 +01:00
|
|
|
main(config)
|