HI
I have a service running under weewx 3,9 its working fine connected to a Davis vantage. On a second pi i have installed weewx 4.2 with view to upgrading the 3.9 pi to the latest weewx version
the service i have on the weewx3.9 will not run under python 3
import syslog
import weewx
import os
import csv
from weewx.wxengine import StdService
class PlanetService(StdService):
def __init__(self, engine, config_dict):
super(PlanetService, self).__init__(engine, config_dict)
d = config_dict.get('PlanetService', {})
self.filename = d.get('filename', '/home/pi/cc/allplanets.csv')
syslog.syslog(syslog.LOG_INFO, "planet: using %s" % self.filename)
self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)
def read_file(self, event):
try:
with open(self.filename) as f:
f.seek(-10, os.SEEK_END)
line = f.readlines()[-1]
value = line.split(',')
syslog.syslog(syslog.LOG_DEBUG, "allplanets: found value of %s" % value)
event.record['plutoAzi'] = float(value[3])
except Exception as e:
syslog.syslog(syslog.LOG_ERR, "allplanets: cannot read value: %s" % e)
the above runs under weewx 3.9 but it will not run under weewx 4.2
i have tried to modify if but i am getting the error in the log file
"/weewxd: allplanets: cannot read value: read"
import syslog
import weewx
import os
import csv
from weewx.wxengine import StdService
class PlanetService(StdService):
def __init__(self, engine, config_dict):
super(PlanetService, self).__init__(engine, config_dict)
d = config_dict.get('PlanetService', {})
self.filename = d.get('filename', '/home/pi/cc/allplanets.csv')
syslog.syslog(syslog.LOG_INFO, "planet: using %s" % self.filename)
self.bind(weewx.NEW_ARCHIVE_RECORD, self.read_file)
def read_file(self, event):
try:
with open(self.filename , 'ab') as f:
f.seek(-10, 2)
line = f.readlines()[-1]
value = line.split(',')
syslog.syslog(syslog.LOG_DEBUG, "allplanets: found value of %s" % value)
event.record['extraTemp1'] = float(value[1])
except Exception as e:
syslog.syslog(syslog.LOG_ERR, "allplanets: cannot read value: %s" % e)
could any one offer advice as to why it will not run? is it the seek function?
thanks for any advice