Example #1
0
def getImage(imageId):
    if not FileUtil.exists(join(settings.images_cache_folder, imageId)):
        mapfileId = HbaseUtil.getMapFileId(imageId)
        logging.info(mapfileId)
        if mapfileId is None:
            logging.error('404')
            response.status = 404
            return
        if FileUtil.exists(join(settings.mapfile_cache_folder, mapfileId)):
            MapFileUtil.readMapFile(mapfileId)
        else:
            MapFileUtil.readMapFileFromHdfs(mapfileId)
    # folder_path = join(settings.images_cache_folder,mapfileId)
    folder_path = settings.images_cache_folder
    logging.info(folder_path)
    return static_file(imageId, root=folder_path, mimetype='image/jpg')
Example #2
0
def init():
    folders = [settings.prepare_dir,settings.queue_dir,\
    settings.images_cache_folder,settings.mapfile_cache_folder]
    for path in folders:
        if not FileUtil.exists(path):
            if not FileUtil.makedirs(path):
                logging.error('init error...')
                break
    logging.info('init success...')
Example #3
0
 def _generateMapFileId(self):
     while True:
         self.mapFileId = str(random.randint(1, MAX_MAPFILE_ID))
         if not FileUtil.exists(self.mapFileId):
             break