mirror of
https://github.com/weewx/weewx.git
synced 2026-04-18 16:46:56 -04:00
Moved Wunderground queue.
This commit is contained in:
8
MANIFEST
8
MANIFEST
@@ -4,12 +4,17 @@ NEW_FEATURES.txt
|
||||
README
|
||||
configure.py
|
||||
daemon.py
|
||||
readme.htm
|
||||
setup.cfg
|
||||
setup.py
|
||||
upload.py
|
||||
weewx.conf
|
||||
weewxd.py
|
||||
docs/customizing.htm
|
||||
docs/readme.htm
|
||||
docs/sheeva.htm
|
||||
docs/upgrading.htm
|
||||
examples/__init__.py
|
||||
examples/alarm.py
|
||||
public_html/weewx.css
|
||||
public_html/backgrounds/band.gif
|
||||
public_html/backgrounds/butterfly.jpg
|
||||
@@ -47,4 +52,5 @@ weewx/processdata.py
|
||||
weewx/station.py
|
||||
weewx/stats.py
|
||||
weewx/wunderground.py
|
||||
weewx/wxengine.py
|
||||
weewx/wxformulas.py
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
recursive-include templates *.tmpl
|
||||
recursive-include docs *
|
||||
recursive-include public_html *.gif *.jpg *.css
|
||||
recursive-include start_scripts *
|
||||
recursive-include templates *.tmpl
|
||||
include CHANGES.txt
|
||||
include LICENSE.txt
|
||||
include readme.htm
|
||||
include weewx.conf
|
||||
include NEW_FEATURES.txt
|
||||
include README
|
||||
include weewx.conf
|
||||
|
||||
5
TODO.txt
5
TODO.txt
@@ -1,16 +1,11 @@
|
||||
TODO before the next release:
|
||||
|
||||
Modify WunderThread to reflect the new service architecture.
|
||||
|
||||
Test setup.py to make sure it deletes #upstream.last
|
||||
|
||||
Add year-to-date rain feature.
|
||||
|
||||
Check example in weewxd.py of how to override the default engine
|
||||
|
||||
Move option clock_check to section Station. Move attribute to class StdTimeSynch.
|
||||
Change docs to reflect.
|
||||
|
||||
Write customization.htm --- how to customize.
|
||||
|
||||
Edit templates so they are less KORHOODR3 specific.
|
||||
|
||||
6
setup.py
6
setup.py
@@ -197,10 +197,12 @@ setup(name='weewx',
|
||||
author='Tom Keffer',
|
||||
author_email='tkeffer@gmail.com',
|
||||
url='http://www.threefools.org/weewx',
|
||||
packages = ['weewx', 'weeplot', 'weeutil'],
|
||||
packages = ['weewx', 'weeplot', 'weeutil', 'examples'],
|
||||
py_modules = ['upload', 'daemon'],
|
||||
scripts = ['configure.py', 'weewxd.py'],
|
||||
data_files = [('', ['CHANGES.txt', 'LICENSE.txt', 'README', 'readme.htm', 'weewx.conf']),
|
||||
data_files = [('', ['CHANGES.txt', 'LICENSE.txt', 'README', 'weewx.conf']),
|
||||
('docs', ['docs/customizing.htm', 'docs/readme.htm',
|
||||
'docs/sheeva.htm', 'docs/upgrading.htm']),
|
||||
('templates', ['templates/index.tmpl', 'templates/week.tmpl',
|
||||
'templates/month.tmpl', 'templates/year.tmpl',
|
||||
'templates/NOAA_month.tmpl', 'templates/NOAA_year.tmpl']),
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#
|
||||
"""Publish weather data to the Weather Underground."""
|
||||
import syslog
|
||||
import time
|
||||
import datetime
|
||||
import threading
|
||||
import urllib
|
||||
@@ -18,10 +17,6 @@ import urllib2
|
||||
import weewx
|
||||
import weeutil.weeutil
|
||||
|
||||
# If publishing to the Weather Underground is requested, data to be
|
||||
# published will be put in this queue:
|
||||
wunderQueue = None
|
||||
|
||||
class WunderStation(object):
|
||||
"""Manages interactions with the Weather Underground"""
|
||||
|
||||
@@ -136,25 +131,35 @@ class WunderThread(threading.Thread):
|
||||
Inherits from threading.Thread.
|
||||
|
||||
Basically, it watches a queue, and if anything appears in it, it publishes it.
|
||||
The queue should be populated with a 2-way tuple, where the first member is
|
||||
an instance of weewx.archive.Archive, and the second is a timestamp with the
|
||||
time of the data record to be published.
|
||||
The queue should be populated with the timestamps of the data records to be published.
|
||||
"""
|
||||
def __init__(self, station, password):
|
||||
def __init__(self, archive, queue, station, password):
|
||||
"""Initialize an instance of WunderThread.
|
||||
|
||||
archive: The archive database. Usually an instance of weewx.archive.Archive
|
||||
|
||||
queue: An instance of Queue.Queue where the timestamps will appear
|
||||
|
||||
station: The Weather Underground station to which data is to be published
|
||||
(e.g., 'KORHOODR3')
|
||||
|
||||
password: The password for the station.
|
||||
"""
|
||||
threading.Thread.__init__(self, name="WunderThread")
|
||||
# In the strange vocabulary of Python, declaring yourself a "daemon thread"
|
||||
# allows the program to exit even if this thread is running:
|
||||
self.setDaemon(True)
|
||||
self.WUstation = WunderStation(station, password)
|
||||
self.start()
|
||||
self.archive = archive
|
||||
self.queue = queue # Fifo queue where new records will appear
|
||||
|
||||
def run(self):
|
||||
while 1 :
|
||||
while True :
|
||||
# This will block until something appears in the queue:
|
||||
(archive, time_ts) = wunderQueue.get()
|
||||
time_ts = self.queue.get()
|
||||
|
||||
# Gp get the data from the archive for the requested time:
|
||||
record = self.WUstation.extractRecordFrom(archive, time_ts)
|
||||
# Go get the data from the archive for the requested time:
|
||||
record = self.WUstation.extractRecordFrom(self.archive, time_ts)
|
||||
|
||||
# This string is just used for logging:
|
||||
time_str = weeutil.weeutil.timestamp_to_string(record['dateTime'])
|
||||
|
||||
@@ -345,12 +345,15 @@ class StdWunderground(StdService):
|
||||
# and password exist before committing:
|
||||
if wunder_dict and (wunder_dict.has_key('station') and
|
||||
wunder_dict.has_key('password')):
|
||||
# Create the queue into which we'll put the timestamps of new data
|
||||
self.queue = Queue.Queue()
|
||||
# Create an instance of weewx.archive.Archive
|
||||
archiveFilename = os.path.join(self.engine.config_dict['Station']['WEEWX_ROOT'],
|
||||
self.engine.config_dict['Archive']['archive_file'])
|
||||
t = weewx.wunderground.WunderThread(archiveFilename = archiveFilename,
|
||||
queue = self.queue,
|
||||
**wunder_dict)
|
||||
archive = weewx.archive.Archive(archiveFilename)
|
||||
t = weewx.wunderground.WunderThread(archive = archive, queue = self.queue, **wunder_dict)
|
||||
t.start()
|
||||
|
||||
else:
|
||||
self.queue = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user