Remove ethercalc support
In preparation for the fully IRC-driven system, remove the code getting extra info from ethercalc. Change-Id: I1a7092803630a790290205f0b202bc347c3f18c0
This commit is contained in:
parent
b9ba78d793
commit
0ff1a65f6c
|
@ -10,9 +10,7 @@ the bot, like::
|
||||||
|
|
||||||
and from that information the bot builds a static webpage with discussion
|
and from that information the bot builds a static webpage with discussion
|
||||||
topics currently discussed ("now") and an indicative set of discussion
|
topics currently discussed ("now") and an indicative set of discussion
|
||||||
topics coming up next ("next"). It also merges information from the
|
topics coming up next ("next").
|
||||||
reservable rooms ethercalc in order to produce a single, static,
|
|
||||||
mobile-friendly page.
|
|
||||||
|
|
||||||
Room operators commands
|
Room operators commands
|
||||||
=======================
|
=======================
|
||||||
|
|
|
@ -4,37 +4,5 @@
|
||||||
"irc_server": "irc.freenode.net",
|
"irc_server": "irc.freenode.net",
|
||||||
"irc_port": 6667,
|
"irc_port": 6667,
|
||||||
"irc_channel": "#CHANNEL",
|
"irc_channel": "#CHANNEL",
|
||||||
"db_filename": "html/ptg.json",
|
"db_filename": "html/ptg.json"
|
||||||
"ethercalc_url": "https://ethercalc.openstack.org/_/MYDOC/cells",
|
|
||||||
"ethercalc_cells": {
|
|
||||||
"room_line": "8",
|
|
||||||
"time_column": "A",
|
|
||||||
"time_range": [ 9, 24 ],
|
|
||||||
"days": [
|
|
||||||
{
|
|
||||||
"B": ["14", "15", "16"],
|
|
||||||
"C": [],
|
|
||||||
"D": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"E": ["14", "15", "16"],
|
|
||||||
"F": [],
|
|
||||||
"G": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"H": ["14", "15", "16"],
|
|
||||||
"I": [],
|
|
||||||
"J": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"K": ["14", "15", "16"],
|
|
||||||
"L": [],
|
|
||||||
"M": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"N": [],
|
|
||||||
"O": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,18 +59,6 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading"><h3 class="panel-title">Planned for today in reservable rooms</h3></div>
|
|
||||||
<table class="table">
|
|
||||||
{{#each ethercalc}}
|
|
||||||
<tr>
|
|
||||||
<td>{{#hashtag}}{{this}}{{/hashtag}}</td>
|
|
||||||
</tr>
|
|
||||||
{{else}}
|
|
||||||
<tr><td><small><i>Nothing yet</i></small><td></tr>
|
|
||||||
{{/each}}
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<p class="text-muted">Content on this page is being driven by room operators through the openstackptg bot on the #openstack-ptg IRC channel. It was last refreshed on {{timestamp}}.</p>
|
<p class="text-muted">Content on this page is being driven by room operators through the openstackptg bot on the #openstack-ptg IRC channel. It was last refreshed on {{timestamp}}.</p>
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -25,7 +25,6 @@ import time
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
import ptgbot.db
|
import ptgbot.db
|
||||||
import ptgbot.ethercalc
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import daemon.pidlockfile as pid_file_module
|
import daemon.pidlockfile as pid_file_module
|
||||||
|
@ -183,14 +182,7 @@ def start(configpath):
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
if 'ethercalc_url' in config:
|
db = ptgbot.db.PTGDataBase(config['db_filename'])
|
||||||
ethercalc = ptgbot.ethercalc.Ethercalc(
|
|
||||||
config['ethercalc_url'],
|
|
||||||
config.get('ethercalc_cells'))
|
|
||||||
else:
|
|
||||||
ethercalc = None
|
|
||||||
|
|
||||||
db = ptgbot.db.PTGDataBase(config['db_filename'], ethercalc)
|
|
||||||
|
|
||||||
bot = PTGBot(config['irc_nick'],
|
bot = PTGBot(config['irc_nick'],
|
||||||
config.get('irc_pass', ''),
|
config.get('irc_pass', ''),
|
||||||
|
|
|
@ -21,12 +21,11 @@ import datetime
|
||||||
|
|
||||||
class PTGDataBase():
|
class PTGDataBase():
|
||||||
|
|
||||||
BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {},
|
BASE = {'rooms': [], 'now': {}, 'next': {}, 'colors': {},
|
||||||
'location': {}}
|
'location': {}}
|
||||||
|
|
||||||
def __init__(self, filename, ethercalc):
|
def __init__(self, filename):
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.ethercalc = ethercalc
|
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
with open(filename, 'r') as fp:
|
with open(filename, 'r') as fp:
|
||||||
self.data = json.load(fp)
|
self.data = json.load(fp)
|
||||||
|
@ -87,8 +86,6 @@ class PTGDataBase():
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
if self.ethercalc:
|
|
||||||
self.data['ethercalc'] = self.ethercalc.load()
|
|
||||||
timestamp = datetime.datetime.now()
|
timestamp = datetime.datetime.now()
|
||||||
self.data['timestamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(timestamp)
|
self.data['timestamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(timestamp)
|
||||||
self.data['rooms'] = sorted(self.data['rooms'])
|
self.data['rooms'] = sorted(self.data['rooms'])
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
#! /usr/bin/env python
|
|
||||||
|
|
||||||
# Copyright (c) 2017, Thierry Carrez
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
import requests
|
|
||||||
|
|
||||||
|
|
||||||
class Ethercalc():
|
|
||||||
|
|
||||||
def __init__(self, url, cells_spec):
|
|
||||||
self.url = url
|
|
||||||
self.room_line = cells_spec['room_line']
|
|
||||||
self.time_column = cells_spec['time_column']
|
|
||||||
time_range = range(cells_spec['time_range'][0],
|
|
||||||
cells_spec['time_range'][1])
|
|
||||||
self.times = [str(i) for i in time_range]
|
|
||||||
self.days = cells_spec['days']
|
|
||||||
|
|
||||||
def load(self):
|
|
||||||
doc = requests.get(self.url).json()
|
|
||||||
ret = []
|
|
||||||
today = datetime.datetime.today().weekday()
|
|
||||||
if len(self.days) <= today:
|
|
||||||
return ret
|
|
||||||
for time in self.times:
|
|
||||||
for room, exclusions in self.days[today].items():
|
|
||||||
if time not in exclusions:
|
|
||||||
datacell = room + time
|
|
||||||
roomcell = room + self.room_line
|
|
||||||
timecell = self.time_column + time
|
|
||||||
if doc[datacell]['datavalue']:
|
|
||||||
msg = '%s, %s: %s' % (
|
|
||||||
doc[timecell]['datavalue'],
|
|
||||||
doc[roomcell]['datavalue'],
|
|
||||||
doc[datacell]['datavalue'],
|
|
||||||
)
|
|
||||||
ret.append(msg)
|
|
||||||
return ret
|
|
|
@ -1,3 +1,2 @@
|
||||||
irc
|
irc
|
||||||
python-daemon
|
python-daemon
|
||||||
requests
|
|
||||||
|
|
Loading…
Reference in New Issue