Skip to content

Commit

Permalink
Automatic update weather.ini to use new twitter
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Easterbrook <jim@jim-easterbrook.me.uk>
  • Loading branch information
jim-easterbrook committed Aug 21, 2018
1 parent 1a5bac2 commit 4e3889c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pywws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '18.8.0'
_release = '1568'
_commit = 'f6fa877'
_release = '1569'
_commit = '1a5bac2'
20 changes: 20 additions & 0 deletions src/pywws/regulartasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ def __init__(self, context):
last_update += timezone.utcoffset(last_update)
while self.cron[section].get_current(datetime) <= last_update:
self.cron[section].get_next()
# convert old Twitter flags
for section in list(self.cron.keys()) + [
'live', 'logged', 'hourly', '12 hourly', 'daily']:
templates = eval(self.params.get(section, 'text', '[]'))
services = eval(self.params.get(section, 'services', '[]'))
changed = False
for n, template in enumerate(templates):
if not isinstance(template, (list, tuple)):
continue
template, flags = template
if 'T' not in flags:
continue
templates[n] = (template, 'L')
task = ('twitter', template)
if task not in services:
services.append(task)
changed = True
if changed:
self.params.set(section, 'text', repr(templates))
self.params.set(section, 'services', repr(services))
# create service uploader objects
self.services = {}
for section in list(self.cron.keys()) + [
Expand Down

0 comments on commit 4e3889c

Please sign in to comment.