예제 #1
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()
예제 #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)
예제 #3
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)
예제 #4
0
def check_cache(args):
    cache = Cache(args)
    cache_result = cache.serve_cache()
    if cache_result:
        return cache_result
    return False
예제 #5
0
def check_cache( args ):
  cache = Cache( args )
  cache_result = cache.serve_cache()
  if cache_result:
    return cache_result
  return False