Exemplo n.º 1
0
 def ShowResult():
     img_dir = 'html/'
     agl.removeDir(img_dir)
     for j,c in enumerate(clusters):
         elements = c.get_cluster_elements()
         nbr_elements = len(elements)
         center_index = calc_center(elements, distances) + offset
         
         #添加的字段
         dt = df_datas.index[center_index]
         clust_id = j
         label_id = 0
         label_desc = ''
         
         center_indexs.append([center_index, code, dt, tick_period, clust_id, label_id, label_desc])
         print(j, center_index, len(elements),elements)
Exemplo n.º 2
0
    def __init__(self, explicit=False, is_run_shell=True, is_clear_path=False):
        """编码默认为utf8
        info: 由pushlishinfo获取的元组
        explicit: 弹出页面是否使用显式调用
        is_run_shell: bool 是否跑生成后的start
        is_clear_path: bool 是否清空之前生成的目录文件
        """
        #当前目录
        self.path = os.getcwd() + "/html/"
        if not os.path.isdir("html"):
            os.mkdir("html")
        if is_clear_path:
            #删除当前目录的文件
            dirPath = self.path
            agl.removeDir(dirPath)

        #os_platform
        self.platform_id = 2
        if sys.platform == 'win32':
            self.platform_id = 0
        if sys.platform == 'darwin':
            self.platform_id = 1

        info = publishinfo()
        name = os.path.basename(info[0])
        name = name.replace('.py', '')
        module = info[1]
        module = str(module).replace('<', '')
        module = module.replace('>', '')
        name += '_' + module

        self.source_startrow = info[2] - 1

        self.explicit = explicit
        #获取模板html
        self.t_html = ''
        f = open(os.path.dirname(__file__) + '/test.html', 'r')
        self.t_html = f.read()
        if agl.IsRunAtCmd() or sys.version > '3':
            self.t_html = self.t_html.replace('utf-8', 'gb2312')
        f.close()

        self.name = name
        self.fig_num = 1

        #重定向输出
        self.redirect_fname = 'html/log' + str(os.getpid()) + '.txt'
        if self.platform_id == 0:
            self.logfile = open(self.redirect_fname, "w")
        else:
            self.logfile = codecs.open(self.redirect_fname,
                                       'w',
                                       encoding='utf_16')
        self.oldstdout = sys.stdout
        sys.stdout = self.logfile

        self.figs = []
        self.imgs = []
        self.use_figure = False

        #最后对imgs赋值
        self.myimgs = ''
        self.is_run_shell = is_run_shell