aboutsummaryrefslogtreecommitdiff
path: root/rwa/support/sessionservice/service.py
diff options
context:
space:
mode:
Diffstat (limited to 'rwa/support/sessionservice/service.py')
-rwxr-xr-xrwa/support/sessionservice/service.py49
1 files changed, 20 insertions, 29 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index 4798df6..2bc727d 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -25,7 +25,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
-import argparse
import json
import logging
import signal
@@ -33,6 +32,7 @@ import time
from threading import Thread
from typing import Union
+import click
import dbus
import dbus.mainloop.glib
import dbus.service
@@ -354,7 +354,23 @@ def str2bool(v: Union[str, bool, int]) -> bool:
raise argparse.ArgumentTypeError("Boolean value expected.")
-def main():
+@click.command()
+@click.option(
+ "-m",
+ "--mockup",
+ is_flag=True,
+ default=False,
+ help="Activates mock up mode. Acts like the real Session Service "
+ "but don't do changes or call RWA.Support.WebApp.",
+)
+@click.option(
+ "-o",
+ "--once",
+ is_flag=True,
+ default=False,
+ help="Runs as one-time-service. Stops after one session.",
+)
+def main(mockup, once):
# Check for lock file
if is_locked():
logging.error("The service is already running.")
@@ -363,38 +379,13 @@ def main():
# Create lock file
lock()
- parser = argparse.ArgumentParser(description="D-Bus Session Service for RWA.Support")
- parser.add_argument(
- "-m",
- "--mockup-mode",
- type=str2bool,
- nargs="?",
- const=True,
- 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:
+ if mockup:
logging.warning("All API responses are faked and should NOT BE USED IN PRODUCTION!")
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()
- service_object = RWASupportSessionService(loop, mockup_mode, one_time)
+ service_object = RWASupportSessionService(loop, mockup, once)
def signal_handler(sig, frame):
logging.info("Service was terminated.")