from collections import Counter import requests from tabulate import tabulate from corji.data_sources import google_spreadsheets from corji.logging import Logger from corji.settings import Config logger = Logger(Config.LOGGER_NAME, Config.LOG_PATH, Config.LOG_NAME) SPREADSHEET_URL = Config.SPREADSHEET_URL if __name__ == "__main__": logger.debug("START: Spreadsheet URL defined: %s", SPREADSHEET_URL) google_spreadsheets.load(SPREADSHEET_URL) corgi_counter = Counter() keys = google_spreadsheets.keys(include_empty_keys=True) for emoji in keys: corgis = google_spreadsheets.get_all(emoji) for corgi in corgis: try: requests.get(corgi) except: print("FAILURE: {}".format(corgi)) corgi_counter[len(corgis)] += 1 print(tabulate(corgi_counter.items(),
import twilio.twiml # Why yes, this *is* janky as hell. Needed to avoid circular imports. app = Flask(__name__) import corji.cache as cache import corji.data_sources as data_sources from corji.exceptions import CorgiNotFoundException from corji.logging import Logger, logged_view import corji.settings as settings from corji.utils import (emojis_for_emoticons, text_contains_emoji) logger = None app.config.from_object('corji.settings.Config') logger = Logger(app, settings.Config.LOG_PATH, settings.Config.LOG_NAME) SPREADSHEET_URL = settings.Config.SPREADSHEET_URL logger.debug("START: Spreadsheet URL defined: %s", SPREADSHEET_URL) # TODO: GLOBALS BAD. corgis = data_sources.load_from_spreadsheet(SPREADSHEET_URL) if __name__ == "__main__": logger.debug("START: Starting to load Corjis into cache.") cache.put_in_local_cache(corgis) logger.debug("START: Completed Corji Cache loading") # TODO: Serve statics not via Flask. @app.route("/local/<path:file_name>", methods=['GET']) def get_image(file_name):
import corji.cache as cache import corji.data_sources as data_sources from corji.exceptions import CorgiNotFoundException from corji.logging import Logger, logged_view import corji.settings as settings from corji.utils import ( emojis_for_emoticons, text_contains_emoji ) logger = None app.config.from_object('corji.settings.Config') logger = Logger(app, settings.Config.LOG_PATH, settings.Config.LOG_NAME) SPREADSHEET_URL = settings.Config.SPREADSHEET_URL logger.debug("START: Spreadsheet URL defined: %s", SPREADSHEET_URL) # TODO: GLOBALS BAD. corgis = data_sources.load_from_spreadsheet(SPREADSHEET_URL) if __name__ == "__main__": logger.debug("START: Starting to load Corjis into cache.") cache.put_in_local_cache(corgis) logger.debug("START: Completed Corji Cache loading") # TODO: Serve statics not via Flask. @app.route("/local/<path:file_name>", methods=['GET'])