aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrwa/support/sessionservice/service.py32
1 files changed, 21 insertions, 11 deletions
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index ecc465c..cdf2a1d 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -161,22 +161,22 @@ class RWASupportSessionService(dbus.service.Object):
r = requests.post(url)
except requests.exceptions.ConnectionError:
- logging.warning(" resulted in a connection error.")
+ logging.warning("Handshake resulted in a connection error.")
return {"status": "error", "type": "connection"}
if not r.ok:
- logging.warning(" resulted in a connection error.")
+ logging.warning("Handshake resulted in a connection error.")
return {"status": "error", "type": "connection"}
if not r.json()["allowed"]:
- logging.warning(" was not permitted.")
+ logging.warning("Handshake was not permitted.")
return {"status": "error", "type": "permission_denied"}
if r.json().get("api_version") not in SUPPORTED_API_VERSIONS:
- logging.warning(" resulted in a incompatible API version.")
+ logging.warning("Handshake resulted in a incompatible API version.")
return {"status": "error", "type": "unsupported_server"}
- logging.info(" was successful.")
+ logging.info("Handshake was successful.")
return {"status": "success", "type": "valid_host"}
@@ -216,17 +216,26 @@ class RWASupportSessionService(dbus.service.Object):
if not self._is_url(host):
logging.warning("Given URL is not valid!")
logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host)
- return json.dumps({"status": "error", "type": "invalid_url"})
+
+ response = json.dumps({"status": "error", "type": "invalid_url"})
+ logging.debug('The response to D-Bus caller: "%s"', response)
+ return response
if host in self.settings.web_app_hosts:
logging.warning("Given URL is already present!")
logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host)
- return json.dumps({"status": "error", "type": "duplicate"})
+
+ response = json.dumps({"status": "error", "type": "duplicate"})
+ logging.debug('The response to D-Bus caller: "%s"', response)
+ return response
res = self._do_api_handshake(host)
if res["status"] == "error":
logging.debug('Did not add "%s" to "web_app_hosts" in user_settings', host)
- return json.dumps(res)
+
+ response = json.dumps(res)
+ logging.debug('The response to D-Bus caller: "%s"', response)
+ return response
host_id = str(uuid4())
host_object = {"url": host}
@@ -234,7 +243,7 @@ class RWASupportSessionService(dbus.service.Object):
self.settings.web_app_hosts[host_id] = host_object
self.settings.save_settings()
- logging.debug('Added "%s" to "web_app_hosts" in user_settings', host)
+ logging.info('Added "%s" to "web_app_hosts" in user_settings', host)
response = json.dumps(self._build_host_dict(host_id, host_object))
logging.debug('The response to D-Bus caller: "%s"', response)
@@ -261,11 +270,12 @@ class RWASupportSessionService(dbus.service.Object):
host_object = self.settings.web_app_hosts[host_id]
del self.settings.web_app_hosts[host_id]
self.settings.save_settings()
- logging.debug('Removed web_app_hosts[%s]="%s" in user settings', host_id, host_object)
+ logging.info('Removed web_app_hosts[%s]="%s" in user settings', host_id, host_object)
else:
logging.warning("Given host index is not valid!")
logging.debug(
- "Did not remove web_app_hosts[%s] (not existent!) in " "user settings", host_id
+ "Did not remove web_app_hosts[%s]"
+ "(not existent!) in " "user settings", host_id
)
return json.dumps({"status": "error", "type": "host_not_found"})