Esempio n. 1
0
    def upload(self):
        self.youtube = Youtube()
        title = util.template(self.config.youtube_title, self.dictionary)
        description = util.template(self.config.youtube_description, self.dictionary)
        category_id = self.config.youtube_category_id
        tags = []
        upload_result = self.youtube.initialize_upload(title, description, self.video_path, category_id, tags)
        self.youtube_videoid = upload_result["id"]

        return upload_result["id"]
Esempio n. 2
0
def templates(request):
    callback = request.params['callback'] if 'callback' in request.params else None

    return dream.JSONResponse(callback=callback, body={
        'servers': [{'server': server} for server in local_settings.servers],
        'templates': {
            'content': util.template('content.html'),
            'servers': util.template('servers.html'),
            'queues': util.template('queues.html'),
        }
    })
Esempio n. 3
0
 def get_csv_row(self):
     row = [
         util.template(self.config.youtube_title, self.dictionary),
         util.template("{{ColumnA}}", self.dictionary),
         util.template(self.config.youtube_description, self.dictionary),
         u"Travel",
         self.video_path,
     ]
     row2 = []
     for r in row:
         row2.append(r.replace('"', '\\"').replace("\n", " ").replace("\r", " "))
     return row2
Esempio n. 4
0
def templates(request):
    callback = request.params[
        'callback'] if 'callback' in request.params else None

    return dream.JSONResponse(callback=callback,
                              body={
                                  'servers': [{
                                      'server': server
                                  } for server in local_settings.servers],
                                  'templates': {
                                      'content': util.template('content.html'),
                                      'servers': util.template('servers.html'),
                                      'queues': util.template('queues.html'),
                                  }
                              })
Esempio n. 5
0
def entry(path):
    cwd = os.getcwd()
    dir = os.path.join(cwd, path)

    items = {}
    for file in os.listdir(dir):
        path = os.path.join(dir, file)
        item = util.template(path)

        links = []
        for l in ["sitelink", "directlink", "summarylink"]:
            if item.get(l):
                links.append(item.get(l))

        items.update({file: links})

    exit_code = 0
    for file, links in items.items():
        print()
        print(file)
        for link in links:
            code = check_link(link)

            if not code:
                log.error(f"XXX: {link}")
                exit_code += 1
            elif code == 404:
                log.error(f"{code}: {link}")
                exit_code += 1
            else:
                print(f"{code}: {link}")

    sys.exit(exit_code)
Esempio n. 6
0
def directory_html(category=None, search=None, languages=None, browse=False,
                   name=None):
    languages_specified = languages != None
    if not languages_specified:
      languages = ['en']
    if category:
        plugins = list(Plugin.query(Plugin.categories == category,
                                    Plugin.approved == True))
        plugins = stable_daily_shuffle(plugins)
    elif search:
        plugins = search_plugins(search)
    elif name:
        plugin = Plugin.by_name(name)
        plugins = [plugin] if plugin else []
    else:
        plugins = []
    count = len(plugins)
    plugin_dicts = []
    for p in plugins:
        plugin = info_dict_for_plugin(p, languages)
        plugin_dicts.append(plugin)
    groups = group_plugins(plugin_dicts, languages, languages_specified)
    return template("directory.html",
                    {
                      "groups": groups,
                      "browse": browse,
                      "count": count,
                      "search": search})
Esempio n. 7
0
	def get(self, source):
		if source not in ['web', 'image', 'news']:
			self.error(404)
			return
		response = query(self.request.get('q'), sources=source)
		#self.response.write(response)
		#return
		self.response.write(template(source+'.html', {"response": response}))
Esempio n. 8
0
def render_and_upload(c, template_path, remote_path, cfg):
    rendered_config = util.template(template_path, cfg)
    contents = json.dumps(rendered_config, indent=4)

    tmpfile = remote_path + ".new" + secrets.token_hex(
        3)  # try to now overwrite existing files
    fs.write_file(c, contents, tmpfile, overwrite=True, sudo=True)
    fs.move(c, tmpfile, remote_path, sudo=True)
Esempio n. 9
0
def build_context(c):
    config = util.template("pubpublica.json")

    ctx = {}
    ctx.update(config.get("DEPLOY"))
    ctx.update(config.get("PUBPUBLICA"))
    ctx.pop("INCLUDES", None)
    ctx.pop("SOCKET_PATH", None)

    return ctx
Esempio n. 10
0
def generate_annot_dict(exp_num, image_paths, labels, mode, args):
    annot_dict = util.template(exp_num=exp_num)

    for img_num, img in enumerate(image_paths):
        fname = os.path.basename(img)
        if os.path.splitext(fname)[0] + ".txt" in labels:
            img_labels = labels[os.path.splitext(fname)[0] + ".txt"]
        else:
            img_labels = []
        util.add_image(annot_dict, img, img_num, img_labels, args)

    if mode != "inference":
        annot_dict = util.remove_negative_samples(annot_dict)

    return annot_dict
Esempio n. 11
0
def directory_html(category=None,
                   search=None,
                   languages=None,
                   browse=False,
                   name=None,
                   gae=None,
                   deep_links=False):

    if gae == None:
        gae = not browse

    new = category == 'New'
    if new: category = None

    languages_specified = languages != None
    if not languages_specified:
        languages = ['en']
    if category:
        plugins = list(
            Plugin.query(Plugin.categories == category,
                         Plugin.approved == True))
        plugins = stable_daily_shuffle(plugins)
    elif search:
        plugins = search_plugins(search)
    elif name:
        plugin = Plugin.by_name(name)
        plugins = [plugin] if plugin else []
    elif new:
        plugins = Plugin.query(
            Plugin.approved == True).order(-Plugin.added).fetch(limit=10)
    else:
        plugins = []
    count = len(plugins)
    plugin_dicts = []
    for p in plugins:
        plugin = info_dict_for_plugin(p, languages)
        plugin_dicts.append(plugin)
    groups = group_plugins(plugin_dicts, languages, languages_specified)
    return template(
        "directory.html", {
            "groups": groups,
            "browse": browse,
            "count": count,
            "search": search,
            "deep_links": deep_links,
            "new": new,
            "gae": gae
        })
Esempio n. 12
0
def directory_html(category=None, search=None, languages=None, browse=False, name=None, gae=None, deep_links=False):

    if gae == None:
        gae = not browse

    new = category == "New"
    if new:
        category = None

    languages_specified = languages != None
    if not languages_specified:
        languages = ["en"]
    if category:
        plugins = list(Plugin.query(Plugin.categories == category, Plugin.approved == True))
        plugins = stable_daily_shuffle(plugins)
    elif search:
        plugins = search_plugins(search)
    elif name:
        plugin = Plugin.by_name(name)
        plugins = [plugin] if plugin else []
    elif new:
        plugins = Plugin.query(Plugin.approved == True).order(-Plugin.added).fetch(limit=10)
    else:
        plugins = []
    count = len(plugins)
    plugin_dicts = []
    for p in plugins:
        plugin = info_dict_for_plugin(p, languages)
        plugin_dicts.append(plugin)
    groups = group_plugins(plugin_dicts, languages, languages_specified)
    return template(
        "directory.html",
        {
            "groups": groups,
            "browse": browse,
            "count": count,
            "search": search,
            "deep_links": deep_links,
            "new": new,
            "gae": gae,
        },
    )
Esempio n. 13
0
 def add_styles(self):
     """Add the css to the svg"""
     for css in ['base.css'] + list(self.graph.css):
         if urlparse(css).scheme:
             self.processing_instructions.append(
                 etree.PI(
                     u'xml-stylesheet', u'href="%s"' % css))
         else:
             if not os.path.exists(css):
                 css = os.path.join(
                     os.path.dirname(__file__), 'css', css)
             with io.open(css, encoding='utf-8') as f:
                 css_text = template(
                     f.read(),
                     style=self.graph.style,
                     font_sizes=self.graph.font_sizes())
                 if not self.graph.pretty_print:
                     css_text = minify_css(css_text)
                 self.node(
                     self.defs, 'style', type='text/css').text = css_text
Esempio n. 14
0
def build_context(c):
    with Guard("· gathering build information..."):
        config = util.template("pubpublica.json")

        context = {}
        context.update(config.get("BUILD", {}))

        local_config_path = os.path.abspath(context.get("LOCAL_CONFIG_PATH"))
        context.update({"LOCAL_CONFIG_PATH": local_config_path})

        local_app_path = os.path.abspath(context.get("LOCAL_APP_PATH"))
        context.update({"LOCAL_APP_PATH": local_app_path})

        context.update(config.get("PROVISION", {}))
        context.update(config.get("DEPLOY", {}))

        if pubpublica_config := config.get("PUBPUBLICA"):
            context.update({"PUBPUBLICA": pubpublica_config})

        if flask_config := config.get("FLASK"):
            context.update({"FLASK": flask_config})
Esempio n. 15
0
 def get(self):
     if users.is_current_user_admin():
         # generate_fake_data()
         self.response.write(template("stats.html", stats()))
Esempio n. 16
0
 def write_text_files(self):
     title = util.template(self.config.youtube_title, self.dictionary)
     description = util.template(self.config.youtube_description, self.dictionary)
     util.text_to_file(title, os.path.join(self.video_dir, "title.txt"))
     util.text_to_file(description, os.path.join(self.video_dir, "description.txt"))
Esempio n. 17
0
def home(request):
    return dream.Response(body=util.template('index.html'), content_type='text/html')
Esempio n. 18
0
    def _kmeans(self, points, k):
        _points = np.array([(int(p.pt[0]), int(p.pt[1])) for p in points])
        _points = np.float32(_points)
        criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 10, 1.0)

        ret, label, center = cv2.kmeans(_points, k, criteria, 10, cv2.KMEANS_RANDOM_CENTERS)
        result = []
        for i in range(k):
            result.append((center[i], _points[label.ravel() == i]))
        return result


# to keep it order
logo_detector_map = OrderedDict()
logo_detector_map['xigua_right'] = LogoDectorMatch(template("template_xigua.jpg"), (40, 20, 130, 140), 0.85)
logo_detector_map['xigua_left'] = LogoDectorMatch(template("template_xigua.jpg"), (40, 20, 130, 140), 0.85)
logo_detector_map['duanzi_left'] = LogoDectorSift(template("template_duanzi.png"), ratio=5, threshold=15,
                                                  center_location=(0.5, 0.5, 0.6, 0.4))
logo_detector_map['tencent_right'] = LogoDectorMatch(template("template_tecent.png"), (25, 25, 330, 100), 0.92)

logo_detector_strict_map = OrderedDict()
logo_detector_strict_map['xigua_right'] = LogoDectorMatch(template("template_xigua.jpg"), (40, 20, 130, 140), 0.80)
logo_detector_strict_map['xigua_left'] = LogoDectorMatch(template("template_xigua.jpg"), (40, 20, 130, 140), 0.80)
logo_detector_strict_map['xigua_part_right'] = LogoDectorMatch(template("template_xigua_part.png"), (60, 90, 220, 270),
                                                               0.80)
logo_detector_strict_map['tencent_right'] = LogoDectorMatch(template("template_tecent.png"), (25, 25, 330, 100), 0.92)
logo_detector_strict_map['duanzi_left'] = LogoDectorSift(template("template_duanzi.png"), ratio=4, threshold=15,
                                                  center_location=(0.5, 0.5, 0.6, 0.35))

Esempio n. 19
0
def template(*args):
	debug('Deprecation warning: use webframe.util.template instead of webframe.template')
	return util.template(*args)
Esempio n. 20
0
 def get(self):
     if users.is_current_user_admin():
         # generate_fake_data()
         self.response.write(template("stats.html", stats()))
Esempio n. 21
0
def home(request):
    return dream.Response(body=util.template('index.html'), content_type='text/html')