Daemonic check-in/out.

master
blallo 2019-02-20 18:11:08 +01:00 committed by blallo
parent 9d0b48da9a
commit 7eacfa14f8
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
2 changed files with 24 additions and 14 deletions

View File

@ -193,7 +193,7 @@ class Operator(wd.Firefox):
user_form.send_keys(user)
pass_form.send_keys(password)
do_it = True
if self.debug and not force and self.opts.headless:
if self.debug and not force and not self.opts.headless:
_do_it = input("Really do the login? [y/n] ").lower()
do_it = True if _do_it == "y" else False
if do_it:

View File

@ -112,7 +112,7 @@ def operator_login(op: Operator, username: str, password: str, force: bool) -> N
"""
Instructs the operator to perform login.
"""
logger.debug("Performing login.")
logger.debug("Performing login...")
op.login(username, password, force)
logger.info("Login done.")
@ -121,7 +121,7 @@ def operator_logout(op: Operator, force: bool) -> None:
"""
Instructs the operator to perform logout.
"""
logger.debug("Performing logout.")
logger.debug("Performing logout...")
op.logout(force)
logger.info("Logout done.")
@ -131,7 +131,7 @@ def operator_checkin(op: Operator, force: bool) -> None:
Instructs the operator to perform the check in.
"""
logger.debug("Performing check in...")
op.checkin()
op.check_in(force)
logger.info("Check in done.")
@ -140,7 +140,7 @@ def operator_checkout(op: Operator, force: bool) -> None:
Instructs the operator to perform the check out.
"""
logger.debug("Performing check out...")
op.checkout()
op.check_out(force)
logger.info("Check out done.")
@ -175,24 +175,34 @@ def daemon_process(
debug=debug,
)
def stop_all() -> None:
pass
def _stop_all() -> None:
logger.debug("SIGTERM...stopping all the clients...")
clients = PLifo.All(lifo_path)
with Fifo(fifo_path) as fifo:
for client in clients:
fifo.write(cmd_marshal(name=client, cmd="stop"))
def reload_all() -> None:
pass
def _reload_all() -> None:
logger.debug("SIGUSR1 received here.")
clients = PLifo.All(lifo_path)
with Fifo(fifo_path) as fifo:
for client in clients:
fifo.write(cmd_marshal(name=client, cmd="reload"))
def list_all() -> None:
pass
def _list_all() -> None:
logger.debug("SIGUSR2 received here.")
clients = PLifo.All(lifo_path)
logger.info("Client list: %s", clients)
context = daemon.DaemonContext(
working_directory=working_dir, umask=umask, pidfile=pidfile
)
logger.debug("context defined")
context.signal_map = {
signal.SIGTERM: stop_all,
signal.SIGTERM: _stop_all,
signal.SIGHUP: "terminate",
signal.SIGUSR1: reload_all,
signal.SIGUSR2: list_all,
signal.SIGUSR1: _reload_all,
signal.SIGUSR2: _list_all,
}
logger.debug("signal map defined")
cmd_map = {