diff options
author | Jonathan Weth <git@jonathanweth.de> | 2020-07-29 16:20:46 +0200 |
---|---|---|
committer | Jonathan Weth <git@jonathanweth.de> | 2020-07-29 16:20:46 +0200 |
commit | 3187df811af566cf3bc648a65fcc8a516420ed47 (patch) | |
tree | dcf86f2fee5d64fb67c62ece7a76f5ffd274a228 | |
parent | 7dc7a503fbf1bf80a4c6afdb34335a5c6fcad38c (diff) | |
download | RWA.Support.SessionService-3187df811af566cf3bc648a65fcc8a516420ed47.tar.gz RWA.Support.SessionService-3187df811af566cf3bc648a65fcc8a516420ed47.tar.bz2 RWA.Support.SessionService-3187df811af566cf3bc648a65fcc8a516420ed47.zip |
Add one-time service option
-rwxr-xr-x | service.py | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -17,7 +17,6 @@ from trigger import TriggerServerThread logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s", level=logging.INFO) -ONE_TIME_SERVICE = False ALLOW_ONLY_ONE_SESSION = True @@ -32,9 +31,10 @@ class RWAService(dbus.service.Object): :param mockup_mode: Starts the service in mock up mode """ - def __init__(self, loop: GLib.MainLoop, mockup_mode: bool = False): + def __init__(self, loop: GLib.MainLoop, mockup_mode: bool = False, one_time: bool = False): self.loop = loop self.mockup_mode = mockup_mode + self.one_time = one_time self.bus = dbus.SessionBus() name = dbus.service.BusName("org.ArcticaProject.RWA", bus=self.bus) @@ -192,7 +192,7 @@ class RWAService(dbus.service.Object): self.update_service_running = False logging.info("Stopped update service for sessions.") - if ONE_TIME_SERVICE: + if self.one_time: self._stop_all() def _trigger(self, token: str) -> bool: @@ -241,9 +241,19 @@ if __name__ == "__main__": default=False, help="Activates mock up mode. Acts like the real session service but don't do changes or call RWA.", ) + parser.add_argument( + "-o", + "--one-time", + type=str2bool, + nargs="?", + const=True, + default=False, + help="Runs as one-time-service. Stops after one session.", + ) args = parser.parse_args() mockup_mode = args.mockup_mode + one_time = args.one_time if mockup_mode: logging.warning( @@ -253,7 +263,7 @@ if __name__ == "__main__": dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) loop = GLib.MainLoop() - object = RWAService(loop, mockup_mode) + object = RWAService(loop, mockup_mode, one_time) def signal_handler(sig, frame): logging.info("Service was terminated.") |