def image_info(): data = {} input_json = request.get_json() print('scan-container with payload: {p}'.format(p=input_json)) if input_json and 'image' in input_json and input_json['image']: try: print('Retrieving the image into the system') retrieve_image(input_json['image']) data = fetch_container_info(input_json['image']) except Exception as e: current_app.logger.error(e) return flask.jsonify(data)
def fotolife2rest(self, str_line): """Convert fotolife to image directive. Argument: str_line: text string of blog entry. convert is from: hatena; [f:id:imageid:image] to: reST ; .. image:: imgsrc :target: uri """ r, m = utils.regex_search( '\[f:id:(.*):([0-9]*)[a-z]:image(|:.+?)\]', str_line) if m: img_uri_partial = ('http://cdn-ak.f.st-hatena.com/images/fotolife/' + m.group(1)[0] + '/' + m.group(1) + '/' + m.group(2)[0:8] + '/' + m.group(2)) # get image file img_src = utils.retrieve_image(img_uri_partial, self.dstdir + __imgdir__, self.retrieve_image_flag) repl_str = ('\n.. image:: ' + __imgdir__ + img_src) str_line = r.sub(repl_str, str_line) return str_line
def convert_blog_parts(self, str_line): """Convert blog parts to reST. Argument: str_line: text string of blog entry. """ # remove hatena internal link str_line = convert.remove_internal_link(str_line) # for ditto str_line = convert.ditto(str_line) # remove span element str_line = convert.remove_span(str_line) # remove del element str_line = convert.remove_del(str_line) # for google maps str_line = convert.google_maps(str_line) # for gmodules str_line = convert.gmodules(str_line) # for img element str_line = convert.img2image(str_line) # for amazlet pat_amazon, m = utils.regex_search('amazlet', str_line) if not m: pat_image, m = utils.regex_search( '(<a href="(.+?)" .+?><img src="(.+?)".*?/?></.+?>)', str_line) if m: img_path = utils.retrieve_image(m.group(3), self.dstdir + __imgdir__, self.retrieve_image_flag) str_line = pat_image.sub( '\n.. image:: ' + __imgdir__ + img_path + '\n :target: ' + m.group(2) + '\n\n', str_line) # for youtube str_line = convert.youtube(str_line) # for tweet str_line = convert.tweet(str_line) # for blogparts str_line = convert.extract_blog_parts(str_line) return str_line