Esempio n. 1
0
def internal_error(error):
    '''500'''
    LOGGER.error(error)
    flash(error)
    return render_template('main.html',
        title='500',
        error='This is weird!',
        ), 500
Esempio n. 2
0
def not_found(error):
    '''404'''
    LOGGER.error(error)
    flash(error)
    return render_template('main.html',
        title='404',
        error='I checked twice!',
        ), 404
Esempio n. 3
0
    def redis_ping(self):
        if self.__rdb:
            try:
                LOGGER.info("redis ping")
                return self.__rdb.ping()
            except RedisConnectionError as ex:
                LOGGER.error("could not ping redis: %s" % (ex))

        return False
Esempio n. 4
0
 def download_image(self, url):
     try:
         LOGGER.info('downloading %s' %(url))
         filename = url.split('/')[-1]
         r = rget(url, stream=True)
         if r.status_code == 200:
             with open(path.join(CONTENTSUB['unsorted'], filename), 'wb') as f:
                 for chunk in r.iter_content(1024):
                     f.write(chunk)
             LOGGER.info('done: %s' %(filename))
     except Exception as ex:
         LOGGER.error('download error %s %s' %(url, ex))
Esempio n. 5
0
 def url_scrape(self, url, split=False):
     try:
         LOGGER.info('scraping %s' %(url))
         return rget(url).text.split('\n') if split else rget(url).text
     except Exception as ex:
         LOGGER.error('scrape error %s %s' %(url, ex))
Esempio n. 6
0
STARTMSG = 'fnordpad started'
LOGGER.info(STARTMSG)
LOGGER.info('=' * len(STARTMSG))

from itertools import cycle
TAGLINES = cycle(APP.config['TAGLINES'])

from app.db import Redabas
from config import REDIS_OPT
RDB = Redabas(REDIS_OPT)

from app.files import Duplicates
DUPLICATES = Duplicates()

from app.suppenkasper import Suppenkasper
SUPPENKASPER = Suppenkasper()

if not RDB.redis_ping():
    DB_ERRMSG = 'redis error'
    LOGGER.error(DB_ERRMSG)
    LOGGER.error('!' * len(DB_ERRMSG))

    @APP.route('/')
    @APP.route('/<brain>/')
    def errorsplash(brain=None):
        '''help - no brain found'''
        LOGGER.info('request was: %s' %(brain))
        return views.redis_error('no brain found: %s' %(DB_ERRMSG))

from app import views