aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Weth <git@jonathanweth.de>2021-07-01 13:00:34 +0200
committerJonathan Weth <git@jonathanweth.de>2021-07-01 13:00:34 +0200
commit0d4fa0b19f3ff02cea3c01c9119767d9d27cceef (patch)
tree355540ca58a3cef6622c312e06c646c25a3394db
parent125b78b43f24dcbbe9d75879660a056920c72ea5 (diff)
parent807200788a336d309909cb92ec03da0d5627acb5 (diff)
downloadRWA.Support.SessionService-0d4fa0b19f3ff02cea3c01c9119767d9d27cceef.tar.gz
RWA.Support.SessionService-0d4fa0b19f3ff02cea3c01c9119767d9d27cceef.tar.bz2
RWA.Support.SessionService-0d4fa0b19f3ff02cea3c01c9119767d9d27cceef.zip
Merge branch 'master' into feature/api-handshake
-rw-r--r--rwa/support/sessionservice/config.py6
-rwxr-xr-xrwa/support/sessionservice/service.py28
2 files changed, 17 insertions, 17 deletions
diff --git a/rwa/support/sessionservice/config.py b/rwa/support/sessionservice/config.py
index 7863751..a9f75e6 100644
--- a/rwa/support/sessionservice/config.py
+++ b/rwa/support/sessionservice/config.py
@@ -23,12 +23,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 usersettings
-
-user_settings = usersettings.Settings("org.ArcticaProject.RWASupportSessionService")
-user_settings.add_setting("web_app_hosts", list, ["http://127.0.0.1:8000"])
-user_settings.load_settings()
-
SUPPORTED_API_VERSIONS = [1]
API_PATH = "/app/rwasupport/api/"
ALLOW_ONLY_ONE_SESSION = True
diff --git a/rwa/support/sessionservice/service.py b/rwa/support/sessionservice/service.py
index 9f0ad0a..bb9a1e1 100755
--- a/rwa/support/sessionservice/service.py
+++ b/rwa/support/sessionservice/service.py
@@ -36,10 +36,11 @@ import dbus
import dbus.mainloop.glib
import dbus.service
import requests
+import usersettings
import validators
from gi.repository import GLib
-from .config import ALLOW_ONLY_ONE_SESSION, API_PATH, SUPPORTED_API_VERSIONS, user_settings
+from .config import ALLOW_ONLY_ONE_SESSION, API_PATH, SUPPORTED_API_VERSIONS
from .lock import is_locked, lock, unlock
from .log import logging
from .session import Session
@@ -73,6 +74,11 @@ class RWASupportSessionService(dbus.service.Object):
self.update_service_running = False
self.sessions = {}
+
+ self.settings = usersettings.Settings("org.ArcticaProject.RWASupportSessionService")
+ self.settings.add_setting("web_app_hosts", list, ["http://127.0.0.1:8000"])
+ self.settings.load_settings()
+
super().__init__(name, "/RWASupportSessionService")
logging.info("D-Bus service has been started.")
@@ -92,7 +98,7 @@ class RWASupportSessionService(dbus.service.Object):
Helper function: No D-Bus API.
"""
- hosts = user_settings.web_app_hosts
+ hosts = self.settings.web_app_hosts
return json.dumps(hosts)
@dbus.service.method("org.ArcticaProject.RWASupportSessionService", out_signature="s")
@@ -202,8 +208,8 @@ class RWASupportSessionService(dbus.service.Object):
if res["status"] == "error":
return json.dumps(res)
- user_settings.save_settings()
- user_settings.web_app_hosts.append(host)
+ self.settings.web_app_hosts.append(host)
+ self.settings.save_settings()
logging.debug('Added "%s" to "web_app_hosts" in user_settings', host)
return self._get_web_app_hosts()
@@ -225,15 +231,15 @@ class RWASupportSessionService(dbus.service.Object):
"""
logging.info("D-Bus method call: %s(%d)", "remove_web_app_host", host_idx)
- if host_idx >= 0 and host_idx < len(user_settings.web_app_hosts):
- host = user_settings.web_app_hosts[host_idx]
- del user_settings.web_app_hosts[host_idx]
- user_settings.save_settings()
- logging.debug('Removed web_app_hosts[%d]="%s" in user_settings', host_idx, host)
+ if host_idx >= 0 and host_idx < len(self.settings.web_app_hosts):
+ host = self.settings.web_app_hosts[host_idx]
+ del self.settings.web_app_hosts[host_idx]
+ self.settings.save_settings()
+ logging.debug('Removed web_app_hosts[%d]="%s" in user settings', host_idx, host)
else:
logging.warning("Given host index is not valid!")
logging.debug(
- "Did not remove web_app_hosts[%d] (not existent!) in " "user_settings", host_idx
+ "Did not remove web_app_hosts[%d] (not existent!) in " "user settings", host_idx
)
return self._get_web_app_hosts()
@@ -280,7 +286,7 @@ class RWASupportSessionService(dbus.service.Object):
return response
try:
- host = user_settings.web_app_hosts[host_idx]
+ host = self.settings.web_app_hosts[host_idx]
logging.debug('web_app_hosts[%d] is the following host: "%s"', host_idx, host)
except IndexError:
logging.error("web_app_hosts[%d] does not exist!", host_idx)