Port FileParse to Python 3

This commit is contained in:
Tom Keffer
2019-07-03 19:21:05 -07:00
parent 6ad83bb3cf
commit 747563194f
3 changed files with 24 additions and 7 deletions

View File

@@ -54,7 +54,7 @@ import weewx.drivers
from weeutil.log import logdbg, loginf, logerr
DRIVER_NAME = 'FileParse'
DRIVER_VERSION = "0.6"
DRIVER_VERSION = "0.7"
def _get_as_float(d, s):
@@ -80,9 +80,9 @@ class FileParseDriver(weewx.drivers.AbstractDevice):
# mapping from variable names to weewx names
self.label_map = stn_dict.get('label_map', {})
loginf("data file is %s" % self.path)
loginf("polling interval is %s" % self.poll_interval)
loginf('label map is %s' % self.label_map)
loginf("Data file is %s" % self.path)
loginf("Polling interval is %s" % self.poll_interval)
loginf('Label map is %s' % self.label_map)
def genLoopPackets(self):
while True:
@@ -117,4 +117,4 @@ if __name__ == "__main__":
import weeutil.weeutil
driver = FileParseDriver()
for packet in driver.genLoopPackets():
print weeutil.weeutil.timestamp_to_string(packet['dateTime']), packet
print(weeutil.weeutil.timestamp_to_string(packet['dateTime']), packet)

View File

@@ -1,3 +1,6 @@
0.7 03jul2019
* Port to Python 3
0.6 17apr2016
* keep pylint happy
* provide more configuration instructions in comments

View File

@@ -35,14 +35,28 @@ cp /home/weewx/examples/fileparse/bin/fileparse.py /home/weewx/bin/user
path = /var/tmp/datafile
driver = user.fileparse
3) in the WeeWX configuration file, modify the station_type setting to use the
3) If the variables in the file have names different from those in the database
schema, then add a mapping section called label_map. This will map the
variables in the file to variables in the database columns. For example:
[FileParse]
... (as before)
[[label_map]]
temp = outTemp
humi = outHumidity
in_temp = inTemp
in_humid = inHumidity
4) in the WeeWX configuration file, modify the station_type setting to use the
fileparse driver
[Station]
...
station_type = FileParse
4) restart WeeWX
5) restart WeeWX
sudo /etc/init.d/weewx stop
sudo /etc/init.d/weewx start