aboutsummaryrefslogtreecommitdiff
path: root/service.py
diff options
context:
space:
mode:
Diffstat (limited to 'service.py')
-rwxr-xr-xservice.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/service.py b/service.py
index 3a6f014..5e32f65 100755
--- a/service.py
+++ b/service.py
@@ -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.")