Skip to content

Commit

Permalink
New daemon command to replace user config
Browse files Browse the repository at this point in the history
This is a convenience command intended for GUI clients.
  • Loading branch information
Askannz committed Sep 28, 2019
1 parent b430b16 commit 6cd1a5e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions optimus_manager/optimus_manager_daemon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import sys
import os
import shutil
import signal
import select
import socket
Expand Down Expand Up @@ -101,13 +102,26 @@ def _process_command(config, msg):
print("Writing temporary config file path %s" % command["args"]["path"])
var.write_temp_conf_path_var(command["args"]["path"])

elif command["type"] == "user_config":
_replace_user_config(command["args"]["path"])

else:
print("Invalid command \"%s\" ! Unknown type %s" % (msg, command["type"]))

except KeyError as e:
print("Invalid command \"%s\" ! Key error : %s" % (msg, str(e)))


def _replace_user_config(source_path):

if not os.path.isfile(source_path):
print("ERROR : cannot replace persistent config : %s does not exist" % source_path)
return

print("Replacing user config at %s with file %s" % (envs.USER_CONFIG_PATH, source_path))
shutil.copy(source_path, envs.USER_CONFIG_PATH)


class _SignalHandler:
def __init__(self, server_socket):
self.server_socket = server_socket
Expand Down

0 comments on commit 6cd1a5e

Please sign in to comment.