Skip to content
Snippets Groups Projects
Commit b65c290c authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Read Port from settings, global or user.

If user config exists and has Settings -> Port use that, otherwise
use system wide config, otherwise use defaults.
parent 4dbf27ef
No related branches found
No related tags found
1 merge request!1Rewrite devkit service in python.
......@@ -46,6 +46,12 @@ use_default_hooks = True
global_config = configparser.ConfigParser()
global_config.read(["/etc/steamos-devkit/steamos-devkit.conf", "/usr/share/steamos-devkit/steamos-devkit.conf"])
user_config_path = os.path.join(os.path.expanduser('~'), '.config', PACKAGE, PACKAGE + '.conf')
print("Trying to read user config from {}".format(user_config_path))
user_config = configparser.ConfigParser()
user_config.read(user_config_path)
def find_hook(hook_dirs, use_default_hooks, name):
# First see if it exists in the given paths.
for path in hook_dirs:
......@@ -139,9 +145,18 @@ class DevkitHandler(BaseHTTPRequestHandler):
class DevkitService:
def __init__(self):
# TODO: Get from config if set
self.port = SERVICE_PORT
if 'Settings' in global_config:
settings = global_config["Settings"]
if 'Port' in settings:
self.port = int(settings["Port"])
if 'Settings' in user_config:
settings = user_config["Settings"]
if 'Port' in settings:
self.port = int(settings["Port"])
self.httpd = socketserver.TCPServer(("", self.port), DevkitHandler, bind_and_activate=False)
print("serving at port: {}".format(self.port))
print("machine name: {}".format(machine_name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment