コード例 #1
0
ファイル: html_export.py プロジェクト: wanziforever/tools
    def export(self, pos):
        elements = []
        delta_pos = self.gen_pos_delta(pos)
        for tile in self.view.tiles:
            tile_html = TileHtmlElement()
            tile_html.pos = list(map(lambda x: x[0]+x[1],
                                     zip(tile.pos, delta_pos)))
            tile_html.size = tile.size
            for facet in tile.facets:
                f = FacetHtmlElement(facet.pic, facet.title)
                if facet.typecode not in api_module.api_mapping:
                    err("ViewExport::export() no typecode found in api mapping "
                        "structure: %s"%facet.typecode)
                    exit(0)
                if facet.typecode not in api_module.module_mapping:
                    errtrace("Facet::self_verify() no api module defined for "
                             "typecode %s"%facet.typecode.encode())
                    exit(0)
                cl = api_module.module_mapping[facet.typecode]
                m = cl(facet.id, facet.title)
                f.url = m.export_html(settings.POSTER_HOME, settings.override)
                om_output("Facet %s export html %s"%(facet.title, f.url))
                if f.url is False:
                    f.url = "#"

                tile_html.facets.append(f)
            elements.append(tile_html)

        s = ""
        for e in elements:
            s += e.export() + "\n"
        return s
コード例 #2
0
    def export(self, pos):
        elements = []
        delta_pos = self.gen_pos_delta(pos)
        for tile in self.view.tiles:
            tile_html = TileHtmlElement()
            tile_html.pos = list(
                map(lambda x: x[0] + x[1], zip(tile.pos, delta_pos)))
            tile_html.size = tile.size
            for facet in tile.facets:
                f = FacetHtmlElement(facet.pic, facet.title)
                if facet.typecode not in api_module.api_mapping:
                    err("ViewExport::export() no typecode found in api mapping "
                        "structure: %s" % facet.typecode)
                    exit(0)
                if facet.typecode not in api_module.module_mapping:
                    errtrace("Facet::self_verify() no api module defined for "
                             "typecode %s" % facet.typecode.encode())
                    exit(0)
                cl = api_module.module_mapping[facet.typecode]
                m = cl(facet.id, facet.title)
                f.url = m.export_html(settings.POSTER_HOME, settings.override)
                om_output("Facet %s export html %s" % (facet.title, f.url))
                if f.url is False:
                    f.url = "#"

                tile_html.facets.append(f)
            elements.append(tile_html)

        s = ""
        for e in elements:
            s += e.export() + "\n"
        return s
コード例 #3
0
ファイル: production.py プロジェクト: wanziforever/tools
def recom_refresh(user, cnum):
    url = recom_fresh_url.format(user, cnum)
    info("going to refresh recom data through %s"%url)
    data = ""
    try:
        c = pycurl.Curl()
        b = StringIO.StringIO()
        c.setopt(pycurl.URL, url)
        c.setopt(pycurl.CONNECTTIMEOUT, 10)
        c.setopt(pycurl.WRITEFUNCTION, b.write)
        c.perform()
        data = b.getvalue()
    except Exception,e :
        errtrace("site::recom_refresh() exception when getting data "
                 "from %s, err(%s)"%(url, str(e)))
        data = ""
        return False
コード例 #4
0
def recom_refresh(user, cnum):
    url = recom_fresh_url.format(user, cnum)
    info("going to refresh recom data through %s" % url)
    data = ""
    try:
        c = pycurl.Curl()
        b = StringIO.StringIO()
        c.setopt(pycurl.URL, url)
        c.setopt(pycurl.CONNECTTIMEOUT, 10)
        c.setopt(pycurl.WRITEFUNCTION, b.write)
        c.perform()
        data = b.getvalue()
    except Exception, e:
        errtrace("site::recom_refresh() exception when getting data "
                 "from %s, err(%s)" % (url, str(e)))
        data = ""
        return False