Skip to content

Commit

Permalink
Make all settings strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérôme Lafréchoux committed Jun 14, 2013
1 parent 78aafb4 commit 9362982
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
22 changes: 10 additions & 12 deletions oemgatewaybuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@
class OemGatewayBuffer(object):

def __init__(self):
"""Create a server data buffer initialized with server settings.
domain (string): domain name (eg: 'domain.tld')
path (string): emoncms path with leading slash (eg: '/emoncms')
apikey (string): API key with write access
period (int): sending interval in seconds
active (bool): whether the data buffer is active
"""
"""Create a server data buffer initialized with server settings."""

# Initialize logger
self._log = logging.getLogger("OemGateway")
Expand All @@ -45,6 +37,12 @@ def set(self, **kwargs):
**kwargs (dict): settings to be modified.
domain (string): domain name (eg: 'domain.tld')
path (string): emoncms path with leading slash (eg: '/emoncms')
apikey (string): API key with write access
period (string): sending interval in seconds
active (string): whether the data buffer is active (True/False)
"""

for key, value in kwargs.iteritems():
Expand All @@ -57,7 +55,7 @@ def add_data(self, data):
"""

if not self._settings['active']:
if not bool(self._settings['active']):
return

self._log.debug("Server " +
Expand All @@ -78,7 +76,7 @@ def check_time(self):
"""
now = time.time()
if (now - self._last_send > self._settings['period']):
if (now - self._last_send > int(self._settings['period'])):
return True

def has_data(self):
Expand Down Expand Up @@ -108,7 +106,7 @@ class OemGatewayEmoncmsBuffer(OemGatewayBuffer):
def send_data(self):
"""Send data to server."""

if not self._settings['active']:
if not bool(self._settings['active']):
return

# Prepare data string with the values in data buffer
Expand Down
8 changes: 4 additions & 4 deletions oemgatewayinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def check_settings(self):
'domain': 'localhost',
'path': '/emoncms',
'apikey': emoncms_s['apikey'],
'period': 0,
'active': True}
'period': '0',
'active': 'True'}
# Remote
settings['buffers']['emoncms_remote'] = \
{'type': 'OemGatewayEmoncmsBuffer',
Expand All @@ -186,8 +186,8 @@ def check_settings(self):
'domain': emoncms_s['remotedomain'],
'path': emoncms_s['remotepath'],
'apikey': emoncms_s['remoteapikey'],
'period': 30,
'active': bool(emoncms_s['remotesend'])}
'period': '30',
'active': emoncms_s['remotesend']}

# Return True if settings modified
if settings != self.settings:
Expand Down

0 comments on commit 9362982

Please sign in to comment.