import inflect import logging import matplotlib import matplotlib.pyplot as plt import re import tempfile import app_config from plugins.base import CarebotPlugin from util.analytics import GoogleAnalytics from util.models import Story from util.s3 import Uploader from util.time import TimeTools inflector = inflect.engine() s3 = Uploader() logging.basicConfig() logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) class NPRLingerRate(CarebotPlugin): """ Get linger rate stats on NPR stories Eg '1,000 people spent a median 10 seconds studying the graphic' """ SLUG_SEARCH_REGEX = re.compile(ur'slug ((\w*-*)+)') GRUBER_URLINTEXT_PAT = re.compile( ur'(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?\xab\xbb\u201c\u201d\u2018\u2019]))'
def test_upload(): uploader = Uploader() data = open('./test.gif', 'rb') f = uploader.upload(data) print f
from util.slack import SlackTools from util.s3 import Uploader from util.config import Config from scrapers.analytics import GoogleAnalyticsScraper from scrapers.nprapi import NPRAPIScraper from scrapers.rss import RSSScraper from scrapers.screenshot import Screnshotter from scrapers.spreadsheet import SpreadsheetScraper env.user = app_config.SERVER_USER env.hosts = app_config.SERVERS env.slug = app_config.PROJECT_SLUG screenshotter = Screnshotter() slackTools = SlackTools() uploader = Uploader() logging.basicConfig() logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) config = Config() """ Base configuration """ env.user = app_config.SERVER_USER env.forward_agent = True env.hosts = [] env.settings = None