def GET(self): if not base.logged(): raise web.seeother('/') else: input = web.input(project=None,idc=None,hc=None,page=None) if not input.project.isdigit() or not input.hc.isdigit(): return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>") project = int(input.project) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = int(input.hc) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: if not input.project.isdigit(): return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>") page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset pagerows = models.getPageByProject(project, offset, pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['statusid'] = h['status'] h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>下一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page+1,project,hostcount,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>上一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page-1,project,hostcount,page,pages,hostcount) else: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>下一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>上一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=1'>首页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page+1,project,hostcount,page-1,project,hostcount,project,hostcount,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.project_host_list(newhosts,pages,page,page_nav) else: return render.project_host_list_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') else: input = web.input(project=None,idc=None,hc=None,page=None) if not input.project.isdigit() or not input.hc.isdigit(): return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>") project = int(input.project) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = int(input.hc) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: if not input.project.isdigit(): return base.code("<script language='javascript'>alert('参数错误 !');window.history.back(-1);</script>") page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset pagerows = models.getPageByProject(project, offset, pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>下一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page+1,project,hostcount,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>上一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page-1,project,hostcount,page,pages,hostcount) else: page_nav = u"<a href='/projectlisthost?project=%d&hc=%d&page=%d'>下一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>上一页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=1'>首页</a> | <a href='/projectlisthost?project=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (project,hostcount,page+1,project,hostcount,page-1,project,hostcount,project,hostcount,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.project_host_list(newhosts,pages,page,page_nav) else: return render.project_host_list_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') else: # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = models.allHosts() # host_count para = web.input(page=None,action=None) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if para.page: if not para.page.isdigit(): return base.code("<script language='javascript'>alert('参数错误');window.history.back(-1);</script>") page = int(para.page) else: page = 1 offset = pagesize * (page - 1) # offset if para.action: pagerows = models.getPageByLastModify(offset, pagesize) else: pagerows = models.getPage(offset, pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['statusid'] = h['status'] h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/main?page=%d'>下一页</a> | <a href='/main?page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page+1,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/main?page=%d'>上一页</a> | <a href='/main?page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page-1, page, pages,hostcount) else: page_nav = u"<a href='/main?page=%d'>下一页</a> | <a href='/main?page=%d'>上一页</a> | <a href='/main?page=1'>首页</a> | <a href='/main?page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page+1,page-1,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.main(newhosts,pages,page,page_nav) else: return render.main_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') else: # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = models.allHosts() # host_count para = web.input(page=None,action=None) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if para.page: if not para.page.isdigit(): return base.code("<script language='javascript'>alert('参数错误');window.history.back(-1);</script>") page = int(para.page) else: page = 1 offset = pagesize * (page - 1) # offset if para.action: pagerows = models.getPageByLastModify(offset, pagesize) else: pagerows = models.getPage(offset, pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/main?page=%d'>下一页</a> | <a href='/main?page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page+1,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/main?page=%d'>上一页</a> | <a href='/main?page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page-1, page, pages,hostcount) else: page_nav = u"<a href='/main?page=%d'>下一页</a> | <a href='/main?page=%d'>上一页</a> | <a href='/main?page=1'>首页</a> | <a href='/main?page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (page+1,page-1,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.main(newhosts,pages,page,page_nav) else: return render.main_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') else: input = web.input(cid=None,iid=None,hc=None,page=None) cid = int(input.cid) iid = int(input.iid) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = int(input.hc) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset pagerows = models.getPageByIDC(iid,offset,pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['statusid'] = h['status'] h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>下一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page+1,cid,iid,hostcount,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>上一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page-1,cid,iid,hostcount,page,pages,hostcount) else: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>下一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>上一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=1'>首页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page+1,cid,iid,hostcount,page-1,cid,iid,hostcount,cid,iid,hostcount,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.city_idc_host_list(newhosts,pages,page,page_nav) else: return render.city_idc_host_list_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') else: input = web.input(cid=None,iid=None,hc=None,page=None) cid = int(input.cid) iid = int(input.iid) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows hostcount = int(input.hc) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset pagerows = models.getPageByIDC(iid,offset,pagesize) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) newhosts.append(h) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>下一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page+1,cid,iid,hostcount,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>上一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page-1,cid,iid,hostcount,page,pages,hostcount) else: page_nav = u"<a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>下一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>上一页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=1'>首页</a> | <a href='/cihl?cid=%d&iid=%d&hc=%d&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (cid,iid,hostcount,page+1,cid,iid,hostcount,page-1,cid,iid,hostcount,cid,iid,hostcount,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.city_idc_host_list(newhosts,pages,page,page_nav) else: return render.city_idc_host_list_admin(newhosts,pages,page,page_nav)
def GET(self): if not base.logged(): raise web.seeother('/') input = web.input(page=None) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows input.word = input.word.replace("'","\\'") if input.ops == '1': hostcount = models.getHostCountBySearch('hostname',input.word) elif input.ops == '2': hostcount = models.getHostCountBySearchIp(input.word) elif input.ops == '5': hostcount = models.getHostCountBySearch('port',input.word) elif input.ops == '6': hostcount = models.getHostCountBySearch('status',input.word) elif input.ops == '7': hostcount = models.getHostCountBySearch('bandwidth',input.word) elif input.ops == '8': hostcount = models.getHostCountBySearch('uses',input.word) elif input.ops == '9': hostcount = models.getHostCountBySearch('os',input.word) elif input.ops == '10': hostcount = models.getHostCountBySearch('company',input.word) elif input.ops == '11': hostcount = models.getHostCountBySearch('hardwareinfo',input.word) elif input.ops == '12': hostcount = models.getHostCountBySearch('other',input.word) elif input.ops == '13': hostcount = models.getHostCountBySearch('modifyman',input.word) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset if input.ops == '1': pagerows = models.getPageBySearch('hostname',input.word,str(offset),str(pagesize)) elif input.ops == '2': pagerows = models.getPageBySearchIp(input.word,str(offset),str(pagesize)) elif input.ops == '5': pagerows = models.getPageBySearch('port',input.word,str(offset),str(pagesize)) elif input.ops == '6': pagerows = models.getPageBySearch('status',input.word,str(offset),str(pagesize)) elif input.ops == '7': pagerows = models.getPageBySearch('bandwidth',input.word,str(offset),str(pagesize)) elif input.ops == '8': pagerows = models.getPageBySearch('uses',input.word,str(offset),str(pagesize)) elif input.ops == '9': pagerows = models.getPageBySearch('os',input.word,str(offset),str(pagesize)) elif input.ops == '10': pagerows = models.getPageBySearch('company',input.word,str(offset),str(pagesize)) elif input.ops == '11': pagerows = models.getPageBySearch('hardwareinfo',input.word,str(offset),str(pagesize)) elif input.ops == '12': pagerows = models.getPageBySearch('other',input.word,str(offset),str(pagesize)) elif input.ops == '13': pagerows = models.getPageBySearch('modifyman',input.word,str(offset),str(pagesize)) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) newhosts.append(h) ops = int(input.ops) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>下一页</a> | <a href='/search?ops=%d&word=%s&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page+1,ops,input.word,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>上一页</a> | <a href='/search?ops=%d&word=%s&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page-1,ops,input.word,page,pages,hostcount) else: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>下一页</a> | <a href='/search?ops=%d&word=%s&page=%d'>上一页</a> | <a href='/search?ops=%d&word=%s&page=1'>首页</a> | <a href='/search?ops=%d&word=%s&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page+1,ops,input.word,page-1,ops,input.word,ops,input.word,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.main(newhosts,pages,page,page_nav) else: return render.main_admin(newhosts,pages,page,page_nav) if input.ops == '1': result = models.searchHostName(input.content) return result
def GET(self): if not base.logged(): raise web.seeother('/') if web.ctx.session.privilege != 2: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") all_hosts = models.getAllHosts() new_hosts=[] for h in all_hosts: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) new_hosts.append(h) # Export host data wbk = xlwt.Workbook(encoding='utf-8') style = xlwt.XFStyle() style2 = xlwt.XFStyle() font = xlwt.Font() font2 = xlwt.Font() font2.bold = True font.name = 'SimSum' style.alignment.wrap=1 style.font = font style2.font = font2 sheet = wbk.add_sheet('hosts') # Define excel header names sheet.write(0,0,'主机标识', style2) sheet.write(0,1,'所属项目', style2) sheet.write(0,2,'所在城市', style2) sheet.write(0,3,'所在IDC', style2) sheet.write(0,4,'地址一', style2) sheet.write(0,5,'地址二', style2) sheet.write(0,6,'地址三', style2) sheet.write(0,7,'登录端口', style2) sheet.write(0,8,'所属公司', style2) sheet.write(0,9,'带宽', style2) sheet.write(0,10,'用途', style2) sheet.write(0,11,'状态', style2) sheet.write(0,12,'操作系统', style2) sheet.write(0,13,'内存(GB)', style2) sheet.write(0,14,'CPU(核心)', style2) sheet.write(0,15,'磁盘(GB)', style2) sheet.write(0,16,'购买时间', style2) sheet.write(0,17,'质保时间', style2) sheet.write(0,18,'硬件详细信息', style2) sheet.write(0,19,'备注', style2) # Start export row = 1 for i in new_hosts: sheet.write(row,0,i['hostname']) sheet.write(row,1,i['project']) sheet.write(row,2,i['city']) sheet.write(row,3,i['idc']) sheet.col(4).width = 0x0d00 + 3000 sheet.col(5).width = 0x0d00 + 3000 sheet.col(6).width = 0x0d00 + 3000 sheet.write(row,4,'IP:'+i['addr1_ip']+'\nNETMASK:'+i['addr1_netmask']+'\nGATEWAY:'+i['addr1_gateway']+'\nLINE:'+i['addr1_line'], style) sheet.write(row,5,'IP:'+i['addr2_ip']+'\nNETMASK:'+i['addr2_netmask']+'\nGATEWAY:'+i['addr2_gateway']+'\nLINE:'+i['addr2_line'], style) sheet.write(row,6,'IP:'+i['addr3_ip']+'\nNETMASK:'+i['addr3_netmask']+'\nGATEWAY:'+i['addr3_gateway']+'\nLINE:'+i['addr3_line'], style) sheet.write(row,7,i['port']) sheet.write(row,8,i['company']) sheet.write(row,9,i['bandwidth']) sheet.write(row,10,i['uses']) sheet.write(row,11,i['status']) sheet.write(row,12,i['os']) sheet.write(row,13,i['memory']) sheet.write(row,14,i['cpu']) sheet.write(row,15,i['disk']) sheet.write(row,16,i['buytime']) sheet.write(row,17,i['servicetime']) sheet.write(row,18,i['hardwareinfo']) sheet.write(row,19,i['other']) row += 1 wbk.save('download/hosts.xls') file = 'hosts.xls' return base.DownLoad(file)
def GET(self): if not base.logged(): raise web.seeother('/') input = web.input(page=None) # Paging sysconf = models.getConfig() pagesize = sysconf['page'] # page_per_rows input.word = input.word.replace("'","\\'") if input.ops == '1': hostcount = models.getHostCountBySearch('hostname',input.word) elif input.ops == '2': hostcount = models.getHostCountBySearchIp(input.word) elif input.ops == '5': hostcount = models.getHostCountBySearch('port',input.word) elif input.ops == '6': hostcount = models.getHostCountBySearch('status',input.word) elif input.ops == '7': hostcount = models.getHostCountBySearch('bandwidth',input.word) elif input.ops == '8': hostcount = models.getHostCountBySearch('uses',input.word) elif input.ops == '9': hostcount = models.getHostCountBySearch('os',input.word) elif input.ops == '10': hostcount = models.getHostCountBySearch('company',input.word) elif input.ops == '11': hostcount = models.getHostCountBySearch('hardwareinfo',input.word) elif input.ops == '12': hostcount = models.getHostCountBySearch('other',input.word) elif input.ops == '13': hostcount = models.getHostCountBySearch('modifyman',input.word) pages = int(hostcount / pagesize) # page_count if (hostcount % pagesize): pages += 1 #page_count if input.page: page = int(input.page) else: page = 1 offset = pagesize * (page - 1) # offset if input.ops == '1': pagerows = models.getPageBySearch('hostname',input.word,str(offset),str(pagesize)) elif input.ops == '2': pagerows = models.getPageBySearchIp(input.word,str(offset),str(pagesize)) elif input.ops == '5': pagerows = models.getPageBySearch('port',input.word,str(offset),str(pagesize)) elif input.ops == '6': pagerows = models.getPageBySearch('status',input.word,str(offset),str(pagesize)) elif input.ops == '7': pagerows = models.getPageBySearch('bandwidth',input.word,str(offset),str(pagesize)) elif input.ops == '8': pagerows = models.getPageBySearch('uses',input.word,str(offset),str(pagesize)) elif input.ops == '9': pagerows = models.getPageBySearch('os',input.word,str(offset),str(pagesize)) elif input.ops == '10': pagerows = models.getPageBySearch('company',input.word,str(offset),str(pagesize)) elif input.ops == '11': pagerows = models.getPageBySearch('hardwareinfo',input.word,str(offset),str(pagesize)) elif input.ops == '12': pagerows = models.getPageBySearch('other',input.word,str(offset),str(pagesize)) elif input.ops == '13': pagerows = models.getPageBySearch('modifyman',input.word,str(offset),str(pagesize)) newhosts=[] for h in pagerows: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['statusid'] = h['status'] h['status'] = base.getStatus(h['status']) newhosts.append(h) ops = int(input.ops) #page Nav if hostcount <= pagesize: page_nav = u"共 <b>%s</b> 条记录" % (hostcount) elif page == 1: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>下一页</a> | <a href='/search?ops=%d&word=%s&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page+1,ops,input.word,pages,page,pages,hostcount) elif page == pages: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>上一页</a> | <a href='/search?ops=%d&word=%s&page=1'>首页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page-1,ops,input.word,page,pages,hostcount) else: page_nav = u"<a href='/search?ops=%d&word=%s&page=%d'>下一页</a> | <a href='/search?ops=%d&word=%s&page=%d'>上一页</a> | <a href='/search?ops=%d&word=%s&page=1'>首页</a> | <a href='/search?ops=%d&word=%s&page=%d'>尾页</a> | (%d / %d) , 共 <b>%d</b> 条记录" % (ops,input.word,page+1,ops,input.word,page-1,ops,input.word,ops,input.word,pages,page,pages,hostcount) if web.ctx.session.privilege == 0: return render.main(newhosts,pages,page,page_nav) else: return render.main_admin(newhosts,pages,page,page_nav) if input.ops == '1': result = models.searchHostName(input.content) return result
def GET(self): if not base.logged(): raise web.seeother('/') if web.ctx.session.privilege != 2: return base.code("<script language='javascript'>alert('您没有足够的权限,拒绝访问 !');window.history.back(-1);</script>") all_hosts = models.getAllHosts() new_hosts=[] for h in all_hosts: h['project'] = base.getProject(h['project']) h['city'] = base.getCity(h['city']) h['idc'] = base.getIDC(h['idc']) h['status'] = base.getStatus(h['status']) new_hosts.append(h) # Export host data wbk = xlwt.Workbook(encoding='utf-8') style = xlwt.XFStyle() style2 = xlwt.XFStyle() font = xlwt.Font() font2 = xlwt.Font() font2.bold = True font.name = 'SimSum' style.alignment.wrap=1 style.font = font style2.font = font2 sheet = wbk.add_sheet('hosts') # Define excel header names sheet.write(0,0,'主机标识', style2) sheet.write(0,1,'所属项目', style2) sheet.write(0,2,'所在城市', style2) sheet.write(0,3,'所在IDC', style2) sheet.write(0,4,'地址一', style2) sheet.write(0,5,'地址二', style2) sheet.write(0,6,'地址三', style2) sheet.write(0,7,'登录端口', style2) sheet.write(0,8,'所属公司', style2) sheet.write(0,9,'带宽', style2) sheet.write(0,10,'用途', style2) sheet.write(0,11,'状态', style2) sheet.write(0,12,'操作系统', style2) sheet.write(0,13,'内存(GB)', style2) sheet.write(0,14,'CPU(核心)', style2) sheet.write(0,15,'磁盘(GB)', style2) sheet.write(0,16,'购买时间', style2) sheet.write(0,17,'质保时间', style2) sheet.write(0,18,'硬件详细信息', style2) sheet.write(0,19,'备注', style2) # Start export row = 1 for i in new_hosts: sheet.write(row,0,i['hostname']) sheet.write(row,1,i['project']) sheet.write(row,2,i['city']) sheet.write(row,3,i['idc']) sheet.col(4).width = 0x0d00 + 3000 sheet.col(5).width = 0x0d00 + 3000 sheet.col(6).width = 0x0d00 + 3000 sheet.write(row,4,'IP:'+i['addr1_ip']+'\nNETMASK:'+i['addr1_netmask']+'\nGATEWAY:'+i['addr1_gateway']+'\nLINE:'+i['addr1_line'], style) sheet.write(row,5,'IP:'+i['addr2_ip']+'\nNETMASK:'+i['addr2_netmask']+'\nGATEWAY:'+i['addr2_gateway']+'\nLINE:'+i['addr2_line'], style) sheet.write(row,6,'IP:'+i['addr3_ip']+'\nNETMASK:'+i['addr3_netmask']+'\nGATEWAY:'+i['addr3_gateway']+'\nLINE:'+i['addr3_line'], style) sheet.write(row,7,i['port']) sheet.write(row,8,i['company']) sheet.write(row,9,i['bandwidth']) sheet.write(row,10,i['uses']) sheet.write(row,11,i['status']) sheet.write(row,12,i['os']) sheet.write(row,13,i['memory']) sheet.write(row,14,i['cpu']) sheet.write(row,15,i['disk']) sheet.write(row,16,i['buytime']) sheet.write(row,17,i['servicetime']) sheet.write(row,18,i['hardwareinfo']) sheet.write(row,19,i['other']) row += 1 wbk.save('download/hosts.xls') file = 'hosts.xls' return base.DownLoad(file)