def callback_wrapper(result): if result.successful: callback(result) else: logger.info('s3 {0}'.format( os.path.join(match.group('bucket').rstrip('/'), match.group('path').lstrip('/'))) ) # If not on efs, try s3 S3Loader.load(context, os.path.join(match.group('bucket').rstrip('/'), match.group('path').lstrip('/')), callback)
def load(context, url, callback): logger.debug("*** LOADER.load" ) start = datetime.datetime.now() if HTTP_RE.match(url): method = 'http' HttpLoader.load(context, url, callback) else: method = 's3' logger.debug("*** s3") S3Loader.load(context, url, callback) finish = datetime.datetime.now() metric_name = "thumbor.loader.%s.request_time" % method logger.debug("*** librato submit") LIBRATO_API.submit(metric_name, (finish - start).total_seconds() * 1000, description="original file request time (ms)")
def load(context, url, callback): url = quote_url(url) match = S3_RE.match(url) def callback_wrapper(result): if result.successful: callback(result) else: logger.info('s3 {0}'.format( os.path.join(match.group('bucket').rstrip('/'), match.group('path').lstrip('/'))) ) # If not on efs, try s3 S3Loader.load(context, os.path.join(match.group('bucket').rstrip('/'), match.group('path').lstrip('/')), callback) # If melody s3 file, first try to load from efs if match: logger.info('BOTO {0}'.format(match.group('path'))) # TEMP try s3 direct S3Loader.load(context, os.path.join(match.group('bucket').rstrip('/'), match.group('path').lstrip('/')), callback) # FileLoader.load(context, match.group('path'), callback_wrapper) # else get from the internet elif HTTP_RE.match(url): logger.info('WEB {0}'.format(url)) HttpLoader.load(context, url, callback) else: logger.info('FILE {0}'.format(url)) result = LoaderResult() result.successful = False result.error = LoaderResult.ERROR_NOT_FOUND # callback(result) # TEMP enable file loader FileLoader.load(context, url, callback)
def load(context, url, callback): if HTTP_RE.match(url): HttpLoader.load(context, url, callback) else: S3Loader.load(context, url, callback)