Exemple #1
0
def index(varargs=None):
    args = ParseArgs().go(varargs)
    args = remote_url_args(varargs, args)
    cache_result = check_cache(args)
    if cache_result:
        return Draw(args).go(cache_result)
    if 'download_url' in args:
        downloaded_file = Download(args).go('remote')
        args['file_path'] = downloaded_file
        return Draw(args).go(downloaded_file)
    return '404', 404
Exemple #2
0
def handle_error(ir):
    """
        Check for MLS Photo fallback then
        Company Specific Fallback
        Generic fallback
    """
    fallback_image = False
    fallback_dir = os.path.join(photo_path, 'fallback')
    if ('mls' in ir and
        ir['mls'] and
        'fallback' in ir['mls'] and
            ir['mls']['fallback']):
        fallback_image = os.path.join(
            fallback_dir,
            ir['mls']['fallback']
        )
    if not fallback_image:
        fallback_image = os.path.join(
            photo_path,
            'fallback',
            'primary.jpg'
        )
    if 'image_adj' in ir and ir['image_adj']:
        img_obj = Manipulations().go(fallback_image, ir)
        fallback_image = Cache(ir).save(img_obj)
    ir['draw_file'] = fallback_image
    response_code = None
    if ir['error'] in ['Unknown_File', 'Bad_Request']:
        response_code = 404
    return Draw(ir).image(response_code)
Exemple #3
0
def index(ir=None):
    ir = parse_request(ir)
    app.logger.debug(ir)
    cache = Cache(ir)
    cache_file = cache.serve()
    if cache_file:
        return draw_image(cache_file, ir)

    if not ir or ('error' in ir and ir['error']):
        return handle_error(ir)

    if os.path.exists(ir['override_photo_path']):
        app.logger.info('Loading Company Override Photo')
        ir['draw_file'] = ir['override_photo_path']
    elif os.path.exists(ir['mls_photo_path']):
        app.logger.info('Loading MLS Photo')
        ir['draw_file'] = ir['mls_photo_path']
    else:
        app.logger.warning('Cannot Find file')
        ir['error'] = 'Unknown_File'
        return handle_error(ir)
    if 'image_adj' in ir and ir['image_adj']:
        img_obj = Manipulations().go(ir['draw_file'], ir)
        maniup_file = cache.save(img_obj)
        ir['draw_file'] = maniup_file
    return Draw(ir).image()
Exemple #4
0
def index(ir=None):
    ir = parse_request(ir)
    cache = Cache(ir)
    cache_file = cache.serve()
    if cache_file:
        return draw_image(cache_file, ir)

    if not ir or ('error' in ir and ir['error']):
        return handle_error(ir)
    app.logger.debug(ir['realtor_file_id'])
    if os.path.exists(ir['realtor_file_id']):
        app.logger.info('Loading Realtor Photo')
        image_phile = ir['realtor_file_id']
    else:
        app.logger.warning('Cannot Find Realtor File')
        ir['error'] = 'Unknown_File'
        return handle_error(ir)
    if 'image_adj' in ir and ir['image_adj']:
        img_obj = Manipulations().go(image_phile, ir)
        image_phile = cache.save(img_obj)
        app.logger.debug(img_obj)
    return Draw.image(str(image_phile), ir)
Exemple #5
0
def handle_404(args):
    fallback_image = os.path.join(app.config['FALLBACK_DIR'], 'fallback.jpg')
    args['file_path'] = fallback_image
    return Draw(args).go(fallback_image)