Minor nips and tucks, mostly to suppress warnings, or to bring messages closer to the weewx style.

This commit is contained in:
Tom Keffer
2013-10-13 00:05:25 +00:00
parent 3976e67b0c
commit dabc9bde79
3 changed files with 25 additions and 24 deletions

View File

@@ -656,40 +656,40 @@ class StationRegistry(REST):
self._validateParameters()
syslog.syslog(syslog.LOG_INFO, 'register: station will register with %s' % self.server_url)
syslog.syslog(syslog.LOG_INFO, 'restful: station will register with %s' % self.server_url)
def postData(self, archive, time_ts):
now = time.time()
if self._last_ts is not None and now - self._last_ts < self.interval:
msg = 'registration interval (%d) has not passed.' % self.interval
syslog.syslog(syslog.LOG_DEBUG, 'register: %s' % msg)
msg = 'Registration interval (%d) has not passed.' % self.interval
syslog.syslog(syslog.LOG_DEBUG, 'restful: %s' % msg)
raise weewx.restful.SkippedPost, msg
url = self.getURL()
for _count in range(self.max_tries):
# Use HTTP GET to convey the station data
try:
syslog.syslog(syslog.LOG_DEBUG, "register: attempt to register using '%s'" % url)
syslog.syslog(syslog.LOG_DEBUG, "restful: Attempting to register using '%s'" % url)
_response = urllib2.urlopen(url)
except (urllib2.URLError, socket.error,
httplib.BadStatusLine, httplib.IncompleteRead), e:
# Unsuccessful. Log it and try again
syslog.syslog(syslog.LOG_ERR, 'register: failed attempt %d of %d: %e' % (_count+1, self.max_tries, e))
syslog.syslog(syslog.LOG_ERR, 'restful: Failed attempt %d of %d: %e' % (_count+1, self.max_tries, e))
else:
# Check for the server response
for line in _response:
# Registration failed, log it and bail out
if line.startswith('FAIL'):
syslog.syslog(syslog.LOG_ERR, "register: registration server returned %s" % line)
syslog.syslog(syslog.LOG_ERR, "restful: Registration server returned %s" % line)
raise weewx.restful.FailedPost, line
# Registration was successful
syslog.syslog(syslog.LOG_DEBUG, 'register: registration successful')
syslog.syslog(syslog.LOG_DEBUG, 'restful: Registration successful')
self._last_ts = time.time()
return
else:
# The upload failed max_tries times. Log it.
msg = 'failed to register after %d tries' % self.max_tries
syslog.syslog(syslog.LOG_ERR, 'register: %s' % msg)
msg = 'Failed to register after %d tries' % self.max_tries
syslog.syslog(syslog.LOG_ERR, 'restful: %s' % msg)
raise IOError, msg
def getURL(self):
@@ -727,8 +727,8 @@ class StationRegistry(REST):
msgs.append("server_url '%s' is not a valid URL" % self.server_url)
if msgs:
errmsg = 'one or more unusable parameters.'
syslog.syslog(syslog.LOG_ERR, 'register: %s' % errmsg)
errmsg = 'One or more unusable parameters.'
syslog.syslog(syslog.LOG_ERR, 'restful: %s' % errmsg)
for m in msgs:
syslog.syslog(syslog.LOG_ERR, ' **** %s' % m)
# FIXME: restful depends on a hack - throw a KeyError to indicate
@@ -736,7 +736,6 @@ class StationRegistry(REST):
# a ValueError, but that kills StdRESTful instead of simply
# indicating that this restful service is not ready to run.
raise KeyError(errmsg)
#===============================================================================
# class RESTThread

View File

@@ -8,14 +8,15 @@
The weewx setup.py script must be in the same directory as this script."""
import setup
import configobj
import optparse
import os
import shutil
import sys
import tempfile
import configobj
import setup
description = """merge weewx configuration file"""
usage = """%prog --install-dir dir --a file --b file --c file"""
@@ -35,7 +36,7 @@ def main():
parser.add_option('--debug', dest='debug', action='store_true',
help='display contents of merged file to stdout')
(options, args) = parser.parse_args()
(options, _args) = parser.parse_args()
if options.version:
print setup.get_version()
exit(0)
@@ -62,18 +63,18 @@ def main():
tmpfile = tempfile.NamedTemporaryFile("w", 1)
merged_cfg.write(tmpfile)
if os.path.exists(options.filec):
bup_cfg = setup.save_path(options.filec)
_bup_cfg = setup.save_path(options.filec)
shutil.copyfile(tmpfile.name, options.filec)
def printdict(d, indent=0):
for k in d.keys():
if type(d[k]) is configobj.Section:
for i in range(indent):
for _i in range(indent):
print ' ',
print k
printdict(d[k], indent=indent+1)
else:
for i in range(indent):
for _i in range(indent):
print ' ',
print k, '=', d[k]

View File

@@ -427,11 +427,12 @@ def update_config_file(config_dict):
config_dict['StdArchive'].pop('stats_types', None)
# --- Davis Vantage series ---
try:
if config_dict['Vantage']['driver'].strip() == 'weewx.VantagePro':
config_dict['Vantage']['driver'] = 'weewx.drivers.vantage'
except KeyError:
pass
if config_dict.has_key('Vantage'):
try:
if config_dict['Vantage']['driver'].strip() == 'weewx.VantagePro':
config_dict['Vantage']['driver'] = 'weewx.drivers.vantage'
except KeyError:
pass
# --- Oregon Scientific WMR100 ---