示例#1
0
    def get_stages(trs, stage_url, has_gc):
        final_stages = []
        for tr in trs:
            tds = tr.find_all("td")
            temp_stage = Stage()
            temp_stage.set_stage_id(int(tds[0].string.strip()))
            temp_stage.set_submit_time(tds[2].string.strip())
            temp_stage.set_duration(tds[3].string.strip())
            temp_stage.set_tasks_percent(tds[4].find("span").string.strip())
            temp_stage.set_input("0MB" if tds[5].string is None else tds[5].string)
            temp_stage.set_shuffle_read("0MB" if tds[7].string is None else tds[6].string)
            temp_stage.set_shuffle_write("0MB" if tds[8].string is None else tds[7].string)
            gc_total = 0.0
            try:
                if has_gc is True:
                    gc_html = Worm.get_html(
                        stage_url + "stage/?id=" + str(temp_stage.get_stage_id()) + "&attempt=0", True, 6
                    )
                    print stage_url + "stage/?id=" + str(temp_stage.get_stage_id()) + "&attempt=0"
                    gc_soup = BeautifulSoup(gc_html, "html.parser")
                    tables = gc_soup.find_all("table", "table table-bordered table-condensed sortable table-striped")
                    trs = tables[1].find_all("tr")
                    for i in range(0, len(trs)):
                        tds = trs[i].find_all("td")
                        gc_str = tds[10].string.strip()
                        if gc_str != "":
                            # print  gc_str
                            gc_total += Util.format_second(gc_str)
            except Exception, e:
                print e
                gc_total = 0.0
            temp_stage.set_gc_time(gc_total)

            final_stages.append(temp_stage)