diff options
Diffstat (limited to 'rwa')
-rwxr-xr-x | rwa/support/sessionservice/service.py | 48 | ||||
-rw-r--r-- | rwa/support/sessionservice/session.py | 2 |
2 files changed, 29 insertions, 21 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py index 471d599..44e18e2 100755 --- a/rwa/support/sessionservice/service.py +++ b/rwa/support/sessionservice/service.py @@ -115,8 +115,9 @@ class RWASupportSessionService(dbus.service.Object): """ logging.info("D-Bus method call: %s()", "get_web_app_hosts") - logging.debug('Return to D-Bus caller: "%s"', self._get_web_app_hosts()) - return self._get_web_app_hosts() + response = self._get_web_app_hosts() + logging.debug('The response to D-Bus caller: "%s"', response) + return response def _do_api_handshake(self, host: str) -> Dict[str, str]: """Contact a RWA.Support.WebApp host and find out API version. @@ -219,7 +220,9 @@ class RWASupportSessionService(dbus.service.Object): self.settings.save_settings() logging.debug('Added "%s" to "web_app_hosts" in user_settings', host) - return self._get_web_app_hosts() + response = self._get_web_app_hosts() + logging.debug('The response to D-Bus caller: "%s"', response) + return response @dbus.service.method( "org.ArcticaProject.RWASupportSessionService", in_signature="i", out_signature="s" @@ -249,7 +252,9 @@ class RWASupportSessionService(dbus.service.Object): "Did not remove web_app_hosts[%d] (not existent!) in " "user settings", host_idx ) - return self._get_web_app_hosts() + response = self._get_web_app_hosts() + logging.debug('The response to D-Bus caller: "%s"', response) + return response @dbus.service.method( "org.ArcticaProject.RWASupportSessionService", in_signature="i", out_signature="s" @@ -289,7 +294,7 @@ class RWASupportSessionService(dbus.service.Object): "session, so this session won't be started." ) response = json.dumps({"status": "error", "type": "multiple"}) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response try: @@ -298,7 +303,7 @@ class RWASupportSessionService(dbus.service.Object): except IndexError: logging.error("web_app_hosts[%d] does not exist!", host_idx) response = json.dumps({"status": "error", "type": "host_not_found"}) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response # Check host by doing a handshake @@ -319,10 +324,10 @@ class RWASupportSessionService(dbus.service.Object): return_json = session.client_meta return_json["status"] = "success" - logging.info(f"New session #{session.pid} was started with meta {return_json}.") + logging.info(f"New session #{session.pid} was started.") response = json.dumps(return_json) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response except ConnectionError: logging.error( @@ -331,7 +336,7 @@ class RWASupportSessionService(dbus.service.Object): ) response = json.dumps({"status": "error", "type": "connection"}) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response @dbus.service.method( @@ -364,7 +369,7 @@ class RWASupportSessionService(dbus.service.Object): """ logging.info("D-Bus method call: %s(%d)", "status", pid) response = self._get_status(pid) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response @dbus.service.method( @@ -376,7 +381,7 @@ class RWASupportSessionService(dbus.service.Object): self._update_session(pid) response = self._get_status(pid) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response @dbus.service.method( @@ -399,18 +404,20 @@ class RWASupportSessionService(dbus.service.Object): try: session = self.sessions[pid] except KeyError: + logging.debug("D-Bus method stop(): sessions[%d] does not exist.", pid) response = json.dumps({"pid": pid, "status": "stopped"}, sort_keys=True) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response session.stop() response = json.dumps({"id": pid, "status": "stopped"}, sort_keys=True) - logging.debug("The response to the D-Bus caller: '%s'", response) + logging.info("The response to the D-Bus caller: '%s'", response) return response def _get_status(self, pid: int) -> str: try: session = self.sessions[pid] except KeyError: + logging.debug("_get_status(): self.sessions[%d] does not exist.", pid) return json.dumps({"id": pid, "status": "dead"}, sort_keys=True) return json.dumps(session.status) @@ -426,7 +433,7 @@ class RWASupportSessionService(dbus.service.Object): session = self.sessions[pid] except KeyError: logging.info(f"Update status for session #{pid} …") - logging.warning(" Session is dead.") + logging.warning("Session #%d is dead.", pid) return # Check if VNC process is still running @@ -435,12 +442,12 @@ class RWASupportSessionService(dbus.service.Object): pass elif session.status_text == "stopped" and session.pid in self.sessions: logging.info(f"Update status for session #{pid} …") - logging.warning(" Session is dead.") + logging.warning("Session #%d is dead.", pid) del self.sessions[session.pid] else: logging.info(f"Update status for session #{pid} …") - logging.warning(" VNC was stopped, so session is dead.") + logging.warning("VNC was stopped, so session #%d is dead.", pid) session.stop() del self.sessions[session.pid] @@ -461,15 +468,15 @@ class RWASupportSessionService(dbus.service.Object): def _trigger(self, session_id: int, data: dict, method: str = "trigger") -> Union[dict, bool]: """Trigger a specific session via trigger token.""" - logging.info(f"Triggered with session ID {session_id} and {data}") + logging.info(f"Event triggered from Django with session ID {session_id} and {data}") for session in self.sessions.values(): if session.session_id == session_id: r = session.trigger(data, method) - logging.info(f"Session #{session.pid} matches the ID: {r}") + logging.info(f"Found matching session #{session.pid}") return r - logging.warning(" No matching session found for this ID.") + logging.warning(f"Given session ID does not exist!") return False def _stop_all(self): @@ -522,7 +529,8 @@ def main(mockup, once): lock() if mockup: - logging.warning("All API responses are faked and should NOT BE USED IN PRODUCTION!") + logging.warning("The mockup mode should NOT BE USED IN PRODUCTION!") + logging.warning("API responses can be faked and deliver dummy values.") dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) diff --git a/rwa/support/sessionservice/session.py b/rwa/support/sessionservice/session.py index aa97086..b704b08 100644 --- a/rwa/support/sessionservice/session.py +++ b/rwa/support/sessionservice/session.py @@ -197,7 +197,7 @@ class Session: pass if r.status_code in (401, 402, 403, 404, 405): - # Session doesn't exist anymore, so stop it local + # Session doesn't exist anymore, so stop it localy too self.stop(triggered=True) else: self.status_text = r.json()["status"] |