aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xservice.py19
-rw-r--r--session.py9
2 files changed, 11 insertions, 17 deletions
diff --git a/service.py b/service.py
index ba61f49..3a6f014 100755
--- a/service.py
+++ b/service.py
@@ -8,7 +8,9 @@ from threading import Thread
from typing import Union
import dbus
+import dbus.mainloop.glib
import dbus.service
+from gi.repository import GLib
from session import Session
from trigger import TriggerServerThread
@@ -30,7 +32,7 @@ class RWAService(dbus.service.Object):
:param mockup_mode: Starts the service in mock up mode
"""
- def __init__(self, loop, mockup_mode: bool = False):
+ def __init__(self, loop: GLib.MainLoop, mockup_mode: bool = False):
self.loop = loop
self.mockup_mode = mockup_mode
@@ -123,7 +125,7 @@ class RWAService(dbus.service.Object):
return self._get_status(pid)
@dbus.service.method("org.ArcticaProject.RWA", in_signature="i", out_signature="s")
- def stop(self, pid: int):
+ def stop(self, pid: int) -> str:
"""Stop a remote session.
:param pid: (Process) ID of session (D-Bus integer)
@@ -229,11 +231,7 @@ def str2bool(v: Union[str, bool, int]) -> bool:
if __name__ == "__main__":
- parser = argparse.ArgumentParser(
- description="D-Bus session service for "
- + "ArcticaProject's "
- + "Remote Web App"
- )
+ parser = argparse.ArgumentParser(description="D-Bus Session Service for RWA")
parser.add_argument(
"-m",
"--mockup-mode",
@@ -241,9 +239,7 @@ if __name__ == "__main__":
nargs="?",
const=True,
default=False,
- help="Activate mockup mode. Act like the session "
- + "service but don't do changes or call other "
- + "parts of RWA.",
+ help="Activates mock up mode. Acts like the real session service but don't do changes or call RWA.",
)
args = parser.parse_args()
@@ -254,9 +250,6 @@ if __name__ == "__main__":
"All API responses are faked and should NOT BE USED IN PRODUCTION!"
)
- import dbus.mainloop.glib
- from gi.repository import GLib
-
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
loop = GLib.MainLoop()
diff --git a/session.py b/session.py
index af71c6a..71650d8 100644
--- a/session.py
+++ b/session.py
@@ -6,6 +6,7 @@ import signal
import string
import subprocess
import threading
+from typing import Dict, Union
import psutil
import requests
@@ -65,7 +66,7 @@ class Session:
return self.ws_port
@property
- def _api_headers(self) -> dict:
+ def _api_headers(self) -> Dict[str, str]:
return {"Authorization": f"Token {self.api_token}"}
def _generate_password(self):
@@ -232,7 +233,7 @@ class Session:
del self
@property
- def vnc_process_running(self):
+ def vnc_process_running(self) -> bool:
"""Check if the VNC process is still running."""
if self.mockup_session:
filename = f"/tmp/rwa/{str(self.ws_port) + str(self.vnc_port) + str(self.ws_pid) + str(self.vnc_pid)}.lock"
@@ -246,9 +247,9 @@ class Session:
return False
@property
- def client_meta(self):
+ def client_meta(self) -> Dict[str, Union[str, int]]:
return {"id": self.pid, "url": self.web_url, "pin": self.pin}
@property
- def status(self):
+ def status(self) -> Dict[str, Union[str, int]]:
return {"id": self.pid, "status": self.status_text}