From 219ba4fda1f3a257c51cf9584245d2d157395552 Mon Sep 17 00:00:00 2001
From: Stavros Sachtouris <saxtouri@admin.grnet.gr>
Date: Thu, 30 Apr 2015 14:27:41 +0300
Subject: [PATCH] Let GUI client run without config file or settings

If some settings are added though the GUI, the client will
save them on exit.
---
 agkyra/agkyra/protocol.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/agkyra/agkyra/protocol.py b/agkyra/agkyra/protocol.py
index 2f6889d..19d0fad 100644
--- a/agkyra/agkyra/protocol.py
+++ b/agkyra/agkyra/protocol.py
@@ -69,7 +69,8 @@ class WebSocketProtocol(WebSocket):
         token=None, url=None,
         container=None, directory=None,
         exclude=None)
-    status = dict(progress=0, synced=0, unsynced=0, paused=True, can_sync=False)
+    status = dict(
+        progress=0, synced=0, unsynced=0, paused=True, can_sync=False)
     file_syncer = None
     cnf = AgkyraConfig()
     essentials = ('url', 'token', 'container', 'directory')
@@ -202,9 +203,13 @@ class WebSocketProtocol(WebSocket):
 
     # Syncer-related methods
     def get_status(self):
-        self._update_statistics()
-        self.status['paused'] = self.syncer.paused
-        self.status['can_sync'] = self.can_sync()
+        if self.can_sync():
+            self._update_statistics()
+            self.status['paused'] = self.syncer.paused
+            self.status['can_sync'] = self.can_sync()
+        else:
+            self.status = dict(
+                progress=0, synced=0, unsynced=0, paused=True, can_sync=False)
         return self.status
 
     def get_settings(self):
@@ -213,8 +218,9 @@ class WebSocketProtocol(WebSocket):
     def set_settings(self, new_settings):
         # Prepare setting save
         could_sync = self.can_sync()
-        was_active = not self.syncer.paused
-        if could_sync and was_active:
+        was_active = False
+        if could_sync and not self.syncer.paused:
+            was_active = True
             self.pause_sync()
         must_reset_syncing = self._essentials_changed(new_settings)
 
-- 
GitLab