Add arg checker.

master
Marko Semet 2020-04-16 13:38:08 +02:00
parent 10f59ae380
commit f8e1324c82
1 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,9 @@ def main(args):
args = ["--help"]
result = parser.parse_args(args)
def check_client_args_exists():
return False
# Deamon mode
if not isinstance(result.sys_server, bool):
raise RuntimeError("Arg parser has the wrong type.")
@ -26,14 +29,23 @@ def main(args):
if result.sys_server and result.user_server:
raise ValueError("System and user service can't be set simultan.")
if result.sys_server:
# Check if root
if os.getuid() != 0:
# Checks
if check_client_args_exists():
raise RuntimeError("Client settings are setting in system service mode.")
if os.getuid() != 0: # Check root
raise RuntimeError("System service has to run as root.")
# Run deamon
asyncio.run(sys_service.rpc.run_deamon()) # TODO: Change default path
elif result.user_server:
# Checks
if check_client_args_exists():
raise RuntimeError("Client settings are setting in system service mode.")
# Run deamon
asyncio.run(user_service.rpc.run_deamon()) # TODO: Change default path of user and system socket
else:
raise NotImplementedError()
if __name__ == "__main__":