From 0ff1a65f6cbb1d8b83a74ca36b7a8a2ab8cb9edf Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Wed, 29 Nov 2017 16:54:14 +0100 Subject: [PATCH] Remove ethercalc support In preparation for the fully IRC-driven system, remove the code getting extra info from ethercalc. Change-Id: I1a7092803630a790290205f0b202bc347c3f18c0 --- README.rst | 4 +--- config.json.sample | 34 +----------------------------- html/ptg.html | 12 ----------- ptgbot/bot.py | 10 +-------- ptgbot/db.py | 7 ++----- ptgbot/ethercalc.py | 51 --------------------------------------------- requirements.txt | 1 - 7 files changed, 5 insertions(+), 114 deletions(-) delete mode 100644 ptgbot/ethercalc.py diff --git a/README.rst b/README.rst index 8b6bf4b..568c41d 100644 --- a/README.rst +++ b/README.rst @@ -10,9 +10,7 @@ the bot, like:: and from that information the bot builds a static webpage with discussion topics currently discussed ("now") and an indicative set of discussion -topics coming up next ("next"). It also merges information from the -reservable rooms ethercalc in order to produce a single, static, -mobile-friendly page. +topics coming up next ("next"). Room operators commands ======================= diff --git a/config.json.sample b/config.json.sample index 8e751fa..bc7a17b 100644 --- a/config.json.sample +++ b/config.json.sample @@ -4,37 +4,5 @@ "irc_server": "irc.freenode.net", "irc_port": 6667, "irc_channel": "#CHANNEL", - "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": [] - } - ] - } + "db_filename": "html/ptg.json" } diff --git a/html/ptg.html b/html/ptg.html index b7201e2..faf01ff 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -59,18 +59,6 @@ {{/each}} -
-

Planned for today in reservable rooms

- - {{#each ethercalc}} - - - - {{else}} - - {{/each}} -
{{#hashtag}}{{this}}{{/hashtag}}
Nothing yet
-

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}}.

diff --git a/ptgbot/bot.py b/ptgbot/bot.py index b0bb90b..0571db5 100644 --- a/ptgbot/bot.py +++ b/ptgbot/bot.py @@ -25,7 +25,6 @@ import time import ssl import ptgbot.db -import ptgbot.ethercalc try: import daemon.pidlockfile as pid_file_module @@ -183,14 +182,7 @@ def start(configpath): else: logging.basicConfig(level=logging.DEBUG) - if 'ethercalc_url' in config: - ethercalc = ptgbot.ethercalc.Ethercalc( - config['ethercalc_url'], - config.get('ethercalc_cells')) - else: - ethercalc = None - - db = ptgbot.db.PTGDataBase(config['db_filename'], ethercalc) + db = ptgbot.db.PTGDataBase(config['db_filename']) bot = PTGBot(config['irc_nick'], config.get('irc_pass', ''), diff --git a/ptgbot/db.py b/ptgbot/db.py index 25f3f80..58ae284 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -21,12 +21,11 @@ import datetime class PTGDataBase(): - BASE = {'rooms': [], 'ethercalc': [], 'now': {}, 'next': {}, 'colors': {}, + BASE = {'rooms': [], 'now': {}, 'next': {}, 'colors': {}, 'location': {}} - def __init__(self, filename, ethercalc): + def __init__(self, filename): self.filename = filename - self.ethercalc = ethercalc if os.path.isfile(filename): with open(filename, 'r') as fp: self.data = json.load(fp) @@ -87,8 +86,6 @@ class PTGDataBase(): self.save() def save(self): - if self.ethercalc: - self.data['ethercalc'] = self.ethercalc.load() timestamp = datetime.datetime.now() self.data['timestamp'] = '{:%Y-%m-%d %H:%M:%S}'.format(timestamp) self.data['rooms'] = sorted(self.data['rooms']) diff --git a/ptgbot/ethercalc.py b/ptgbot/ethercalc.py deleted file mode 100644 index 6de1e16..0000000 --- a/ptgbot/ethercalc.py +++ /dev/null @@ -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 diff --git a/requirements.txt b/requirements.txt index f76d03f..31eaddc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ irc python-daemon -requests