Commit 87655bd2 authored by Stavros Sachtouris's avatar Stavros Sachtouris Committed by Giorgos Korfiatis
Browse files

Treat mandatory config values as not set if empty

parent 8713a26f
...@@ -287,7 +287,7 @@ class WebSocketProtocol(WebSocket): ...@@ -287,7 +287,7 @@ class WebSocketProtocol(WebSocket):
def set_status(self, **kwargs): def set_status(self, **kwargs):
with self.status.lock() as d: with self.status.lock() as d:
LOGGER.debug('CHANGING STATUS TO %s' % kwargs) LOGGER.debug('Set status to %s' % kwargs)
d.update(kwargs) d.update(kwargs)
@property @property
...@@ -346,16 +346,15 @@ class WebSocketProtocol(WebSocket): ...@@ -346,16 +346,15 @@ class WebSocketProtocol(WebSocket):
sync = self._get_default_sync() sync = self._get_default_sync()
cloud = self._get_sync_cloud(sync) cloud = self._get_sync_cloud(sync)
try: for option in ('url', 'token'):
self.settings['url'] = self.cnf.get_cloud(cloud, 'url') try:
except Exception: value = self.cnf.get_cloud(cloud, option)
self.settings['url'] = None if not value:
self.set_status(code=STATUS['SETTINGS MISSING']) raise Exception()
try: self.settings[option] = value
self.settings['token'] = self.cnf.get_cloud(cloud, 'token') except Exception:
except Exception: self.settings[option] = None
self.settings['url'] = None self.set_status(code=STATUS['SETTINGS MISSING'])
self.set_status(code=STATUS['SETTINGS MISSING'])
self.settings['sync_on_start'] = ( self.settings['sync_on_start'] = (
self.cnf.get('global', 'sync_on_start') == 'on') self.cnf.get('global', 'sync_on_start') == 'on')
...@@ -364,7 +363,10 @@ class WebSocketProtocol(WebSocket): ...@@ -364,7 +363,10 @@ class WebSocketProtocol(WebSocket):
# for option in ('container', 'directory', 'exclude'): # for option in ('container', 'directory', 'exclude'):
for option in ('container', 'directory'): for option in ('container', 'directory'):
try: try:
self.settings[option] = self.cnf.get_sync(sync, option) value = self.cnf.get_sync(sync, option)
if not value:
raise KeyError()
self.settings[option] = value
except KeyError: except KeyError:
LOGGER.debug('No %s is set' % option) LOGGER.debug('No %s is set' % option)
self.set_status(code=STATUS['SETTINGS MISSING']) self.set_status(code=STATUS['SETTINGS MISSING'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment