def render_content(self, ctx, seg): try: stat = eval(open('/usr/local/tcs/tums/rrd/dindex.nid').read()) except: return ctx.tag[tags.h3[tags.img(src="/images/system.png"), " Disk Utilisation"], tags.br, "No statistics have been generated."] #unpack it home = stat['home'] shares = stat['shares'] mail = stat['mail'] homeTotal = sum([int(i) for i in home.values()]) sharesTotal = sum([int(i) for i in shares.values()]) mailTotal = sum([int(i) for i in mail.values()]) return ctx.tag[ tags.h3[tags.img(src="/images/system.png"), " Disk Utilisation"], tags.br, tags.h3["Home folders"], tags.hr, self.pieChartImg(home), PageHelpers.dataTable(['User', 'Utilisation'], self.refilterTable(home, homeTotal)), tags.h3["Shared folders"], tags.hr, self.pieChartImg(shares), PageHelpers.dataTable(['Folder', 'Utilisation'], self.refilterTable(shares, sharesTotal)), tags.h3["Mailboxes"], tags.hr, self.pieChartImg(mail), PageHelpers.dataTable(['Mailbox', 'Utilisation'], self.refilterTable(mail, mailTotal)), ]
def generateReport(): return [ tags.a(href=url.root.child('TelReport').child( 'Overview').child(self.day).child(self.month).child( self.year))["Back to Overview"], tags.h3['Outbound'], PageHelpers.dataTable(outHeader, outData, sortable=False), tags.br, tags.h3['Inbound'], PageHelpers.dataTable(inHeader, inData, sortable=False) ]
def render_content(self, ctx, data): blacklist = [] j = 0 for i in self.sysconf.Mail.get('blacklist', []): blacklist.append([ i, tags. a(href=url.root.child("Mailserver").child("BDelete").child(j), onclick="return confirm('%s');" % self.text.eximConfirmDelete)[tags.img(src="/images/ex.png")] ]) j += 1 whitelist = [] j = 0 for i in self.sysconf.Mail.get('whitelist', []): whitelist.append([ i, tags. a(href=url.root.child("Mailserver").child("WDelete").child(j), onclick="return confirm('%s');" % self.text.eximConfirmDelete)[tags.img(src="/images/ex.png")] ]) j += 1 return ctx.tag[ tags.h2[tags.img(src="/images/mailsrv.png"), " Email Server Config"], PageHelpers.TabSwitcher( ((self.text.eximTabMail, 'panelMail'), (self.text.eximTabRelay, 'panelRelay'), (self.text.eximTabHubbed, 'panelHubbed'), (self.text.eximTabLocal, 'panelLocal'), (self.text.eximTabBlocked, 'panelBlack'), (self.text.eximTabWhitelist, 'panelWhite'))), tags.div(id="panelMail", _class="tabPane" )[tags.directive('form mailConfig')], tags.div(id="panelRelay", _class="tabPane" )[tags.directive('form mailRelay')], tags.div(id="panelHubbed", _class="tabPane" )[tags.directive('form mailHubbed')], tags.div(id="panelLocal", _class="tabPane" )[tags.directive('form mailLocal')], tags.div(id="panelBlack", _class="tabPane")[ PageHelpers.dataTable([self.text.eximAddr, ''], blacklist), tags.h3[self.text.eximAddBlacklist], tags.directive('form mailBlacklist')], tags.div(id="panelWhite", _class="tabPane")[ PageHelpers.dataTable([self.text.eximAddrOrHost, ''], whitelist ), tags.h3[self.text.eximAddWhitelist], tags.directive('form mailWhitelist')], PageHelpers.LoadTabSwitcher()]
def returnMonthView(dayData): """ Returns the details for a particular month""" flatBlocks = [] date = datetime.date(self.year, self.month, 1).strftime("%h %Y") tsite = "" for rows in dayData: tsite = rows[6] flatBlocks.append(( tags.a(href=url.root.child("ProxyUse").child("ShowHost").child(rows[2]).child(self.year).child(self.month).child('0'))[rows[1]], rows[4], "%0.2fMB" % (rows[0]/(1024*1024)), )) return ctx.tag[ tags.h3[ tags.img(src="/images/stock-download.png"), "Web Usage - Hosts who visited %s during %s" % (tsite, date) ], tags.a(href=url.root.child("ProxyUse"))["Back to overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month))["Back to month overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month).child(self.day))["Back to day overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowSites").child(self.year).child(self.month).child('0'))["Back to sites overview"], tags.br, tags.br, PageHelpers.dataTable([('str', 'Host'), ('str', 'Username'), ('int', 'Total Traffic')], flatBlocks, sortable=True) ]
def formatTable(routes): rtab = [] for l in routes.split('\n'): if not l.strip(): continue ln = l.split() src = ln[0] data = {'via': '', 'device': '', 'type': ''} t = "" for n in ln: if t: data[t] = n if n == 'via': t = 'via' data['type'] = "Static" elif n == 'dev': t = 'device' if not data['type']: data['type'] = "Connected" else: t = "" print data if "kernel" in l: data['type'] = "System" rtab.append([ src, data['via'], data['device'], data['type'], ]) return ctx.tag[PageHelpers.dataTable( ['Destination', 'Next hop', 'Interface', 'Type'], rtab), ]
def render_content(self, ctx, data): Utils.log.msg('%s opened Tools/Webserver' % (self.avatarId.username)) H = self.sysconf.General.get('http', {}) hosts = [] #hosts.append(('[default]', H.get('defaults',{}).get('DocumentRoot', "/var/www/localhost/htdocs/"))) for host, v in H.get('vhosts', {}).items(): hosts.append((host, v.get('DocumentRoot', '<Misconfigured>'), tags.a(href="Edit/%s/" % host)["Edit"])) return ctx.tag[ tags.h3[tags.img(src="/images/networking_section.png"), " Webserver"], PageHelpers.TabSwitcher(( ('Webserver Vhosts', 'panelVhost'), ('Webserver Default', 'panelDefault'), )), tags.div(id="panelVhost", _class="tabPane")[ tags.h3["Webserver Vhosts"], PageHelpers.dataTable( ["Domain", "Content Directory", ''], hosts, sortable=True), tags.h3["Add Vhost"], tags.directive('form addVhost')], tags.div(id="panelDefault", _class="tabPane")[ tags.h3["Default vhost"], ], PageHelpers.LoadTabSwitcher()]
def returnMonthView(monthData): # Construct some sensible data. dateBlocks = {} order = [] for rows in monthData: yearMonth = "%s - %s" % (rows[0].year, rows[0].month) if yearMonth in dateBlocks: dateBlocks[yearMonth][0] += rows[1] dateBlocks[yearMonth][1] += rows[2] else: order.append(yearMonth) dateBlocks[yearMonth] = [rows[1], rows[2]] # flatten the dictionary flatBlocks = [] for date in order: values = dateBlocks[date] year = int(date.split()[0]) day = int(date.split()[1]) month = int(date.split()[2]) flatBlocks.append( (tags.a(href=url.root.child("ProxyUse").child("ShowDays"). child(year).child(day).child(month))[datetime.date( year, month, 1).strftime("%h %Y")], "%0.2fMB" % (values[0] / (1024 * 1024)), values[1])) return ctx.tag[ tags.h3[tags.img(src="/images/stock-download.png"), "Proxy Usage - Month Overview"], PageHelpers.dataTable( ['Date', 'Total Traffic', 'Sites Visited'], flatBlocks)]
def render_content(self, ctx, data): dir = os.listdir('/usr/local/tcs/tums/profiles/') dir.sort() tab = [] for l in dir: if l[-3:] == ".py": name = l[:-3].replace('_', ' ').capitalize() tab.append((name, [ tags.a(href="copy/%s" % l)["Copy"], " ", tags. a(href="#", onclick= "showElement('ren'); getElement('rename-source').value = '%s'; return false;" % name)["Rename"], " ", tags. a(href="delete/%s" % (l), onclick= "return confirm('Are you sure you want to delete this profile?');", title="Delete this profile")[tags.img( src="/images/ex.png")] ])) return ctx.tag[tags.h3[tags.img(src="/images/netdrive.png"), " Configuration Profiles"], PageHelpers.dataTable(['Profile Name', ""], tab), tags.br, tags.div(id="ren", style="display:none;" )[tags.directive('form rename')]]
def render_content(self, ctx, data): return ctx.tag[ tags.h2[tags.img(src='/images/srvman.png'), self.text.compHeading], tags.h3[self.text.compHeadingList], PageHelpers.dataTable([self.text.compName, ''], self.getComputers( )), tags.h3[self.text.compHeadingAdd], tags.directive('form addComputer'), ]
def render_content(self, ctx, data): return ctx.tag[ tags.h3[tags.img(src="/images/cluster.png"), " "], PageHelpers.dataTable(['',""], tab), tags.br, tags.div(id="ren", style="display:none;")[ tags.directive('form renameDomain') ] ]
def render_content(self, ctx, data): tab = [] return ctx.tag[ tags.h3[tags.img(src="/images/cluster.png"), " Services"], PageHelpers.dataTable( ['Service Description', "RC Script", "Process Identifier"], tab ), tags.br, tags.div(id="ren", style="display:none;" )[tags.directive('form rename')]]
def render_content(self, ctx, data): records = [] if not self.sysconf.General['zones'][self.domain]['records']: records = self.parseZone() for rec in self.sysconf.General['zones'][self.domain]['records']: # Ditch duplicates automatically if rec not in records: records.append(rec) # Save parsed records G = self.sysconf.General G['zones'][self.domain]['records'] = records self.sysconf.General = G # Make the table rnum = 0 nrecords = [] for r in records: l = r.split() if len(l)>3 and "MX" in r: # Has MX thisRec = [l[0], l[1], l[3], l[2]] else: thisRec = l thisRec.append("") thisRec.append(tags.a(href="Delete/%s/"%rnum)["Delete"]) rnum += 1 nrecords.append(thisRec) return ctx.tag[ tags.h3[tags.img(src="/images/networking_section.png"), " Editing zone %s" % self.domain], PageHelpers.TabSwitcher(( ('Records', 'panelDNSRecs'), ('Add Record', 'panelDNSAdd'), ('Edit Options', 'panelDNSOpt'), )), tags.div(id="panelDNSRecs", _class="tabPane")[ PageHelpers.dataTable(["Host", "Type", "Data", "Priority", ""], nrecords, sortable = True ), ], tags.div(id="panelDNSAdd", _class="tabPane")[ tags.h3["Add new record"], tags.directive('form addRecord'), ], tags.div(id="panelDNSOpt", _class="tabPane")[ tags.h3["Edit zone options"], tags.directive('form editZone') ], PageHelpers.LoadTabSwitcher() ]
def returnPage(res): return ctx.tag[ tags.directive('form searchCache'), tags.h3["Search results"], PageHelpers.dataTable( (('str', 'Category'), ('str', 'Filename'), ('int', 'Hits'), ('int', 'Size'), ('', '')), [(i[0], i[1], i[2] or 0, Utils.intToH(i[3] or 0), tags.a(href=url.root.child('Squid'). child('Flush').child(i[1]))[tags.img( src='/images/ex.png')]) for i in res], sortable=True)]
def processResult(res): headerDialed = ["Call Date", "Duration", "User", "Dialed Number"] headerRec = ["Call Date", "Duration", "User", "Source Number"] dataDialed = [] dataRec = [] for entry in res: if entry['dcontext'][0:8] == 'userProv': dataDialed.append([ str(entry['calldate']), entry['duration'], entry['src'], entry['dst'] ]) else: #XXX Add recieved log pass return [ tags.h3["Dialed Calls"], PageHelpers.dataTable(headerDialed, dataDialed), tags.br, tags.h3["Received Calls"], PageHelpers.dataTable(headerRec, dataRec), ]
def render_content(self, ctx, data): squidData = self.getData() return ctx.tag[tags.h2[tags.img(src='/images/proxy.png'), " Web Proxy"], PageHelpers.TabSwitcher(( ('Proxy setup', 'panelProxySetup'), ('Allowed Domains', 'panelAdom'), ('Blocked Domains', 'panelBdom'), ('Allowed Destination', 'panelAdest'), ('Allowed Computers', 'panelAcomp'), )), tags.div(id="panelProxySetup", _class="tabPane")[ tags.h3["Proxy setup"], tags.directive('form authentication'), ], tags.div(id="panelAdom", _class="tabPane")[ tags.h3["Allowed Domains"], PageHelpers.dataTable(['Domain', ''], squidData[0]), tags.h3["Add Domain"], tags.directive('form addDomain'), ], tags.div(id="panelBdom", _class="tabPane")[ tags.h3["Blocked Domains"], PageHelpers.dataTable(['Domain', ''], squidData[3]), tags.h3["Add Domain"], tags.directive('form addBlock'), ], tags.div(id="panelAdest", _class="tabPane")[ tags.h3["Allowed Destination Networks"], PageHelpers. dataTable(['IP Address/Network', ''], squidData[1]), tags.h3["Add IP address or network"], tags.directive('form addDest'), ], tags.div(id="panelAcomp", _class="tabPane")[ tags.h3["Allowed Computers"], PageHelpers. dataTable(['IP Address/Network', ''], squidData[2]), tags.h3["Add IP address or network"], tags.directive('form addHost'), ], PageHelpers.LoadTabSwitcher()]
def render_content(self, ctx, data): wanDevices = self.sysconf.WANDevices wanTable = [] pppDevs = self.getPeers() for iface, detail in wanDevices.items(): if iface in pppDevs: peerStatus = tags.a( href=url.root.child("PPP").child("Disconnect").child( iface), title="Connected: Click to disconnect.")[tags.img( src='/images/connect.png')] else: peerStatus = tags.a( href=url.root.child("PPP").child("Connect").child(iface), title="Disconnected: Click to connect.")[tags.img( src='/images/noconnect.png')] options = "" if detail.get('pppd', None): if 'defaultroute' in detail['pppd']: options += "Default Route" if self.sysconf.LocalRoute == iface: options += "Local Only Route" type = "PPP" if detail.get('plugins', None): if detail['plugins'] == "pppoe": type = "PPPoE" wanTable.append(( peerStatus, iface, detail.get('link', ''), detail.get('username', ''), detail.get('password', ''), # XXX Remove Me! type, options, tags.a(href=url.root.child("PPP").child("Delete").child(iface)) [tags.img(src="/images/ex.png")])) return ctx.tag[tags.h3[tags.img(src="/images/netdrive.png"), " PPPoE Interfaces"], PageHelpers.dataTable([ '', 'Interface', 'Link', 'Username', 'Password', 'Type', 'Options', '' ], wanTable), tags.br, tags.h3["Add PPP Interface"], tags.directive('form addPPP')]
def eximq(stdout): table = [] for l in stdout.split('\n'): line = l.strip().split() if line: num, vol, old, new, domain = tuple(line) table.append((domain, num, vol, old, new, tags.a(href="/auth/MailQueue/Flush/%s/" % domain)["Resend"])) return ctx.tag[tags.h3["Domain queue"], PageHelpers.dataTable(('Domain', 'Number', 'Volume', 'Oldest', 'Newest', ''), table, sortable=True)]
def render_content(self, ctx, data): plugins = [] for k,v in self.db[5].plugins.items(): modPtr, name, version = v plugins.append([ name, version, "Waps/"+k, tags.a(title= "Uninstall %s" % name, href="Delete/%s/" % k)[tags.img(src="/images/ex.png")] ]) return ctx.tag[ tags.h3[tags.img(src="/images/netdrive.png"), " Applications"], PageHelpers.dataTable(['Module Name', 'Version', 'Install Location', ''], plugins), tags.h3["Install Application"], tags.directive('form addApp') ]
def render_content(self, ctx, data): headings = [ ('Set', 'set'), ('Description', 'desc'), ('Type', 'type'), ('Destination', 'dest'), ('Source', 'fileset'), ('Excluded', 'exclude'), ('Notifications', 'mailto'), ('', 'options') ] backups = self.sysconf.Backup backupRows = [] remap = { 'smb': 'Windows Share', 'usb': 'USB Drive', 'path': 'Local path' } for k,v in backups.items(): backupRows.append([ k, v['desc'], remap[v['type']], v['dest'], ','.join(v.get('fileset', [])), ','.join(v.get('exclude', [])), ','.join(v.get('mailto', [])), [ tags.a( href="Delete/%s/" % k, onclick="return confirm('Are you sure you want to delete this backup set?');" )[tags.img(src='/images/ex.png')], " ", tags.a(href="Edit/%s/" % k)[tags.img(src='/images/edit.png')], " ", tags.a(href="Execute/%s/" % k)[tags.img(src='/images/start.png')], ] ]) return ctx.tag[ tags.h3[tags.img(src="/images/netdrive.png"), " Backups"], PageHelpers.dataTable([h[0] for h in headings], backupRows), tags.h3['Add Backup'], tags.directive('form addSet'), ]
def rendt(proc): comps = [] for i in proc.split('\n'): if i.strip('\n'): name = i.split(':')[0].strip('$') comps.append([name, tags.a(href=url.root.child("Domain").child("DeleteComp").child(name), onclick="return confirm('%s');" % self.text.compConfirm)[tags.img(src="/images/ex.png")]]) Utils.log.msg('%s opened Tools/Computers' % (self.avatarId.username)) return ctx.tag[ tags.h3[tags.img(src='/images/srvman.png'), self.text.compHeading], tags.h3[self.text.compHeadingList], PageHelpers.dataTable([self.text.compName, ''], comps, sortable=True), tags.h3[self.text.compHeadingAdd], tags.directive('form addComputer'), ]
def renderer(ps): for k, v in xen.items(): if v['lva']: disk = "%sGB in %s/%s-disk" % (v['disk'], v['lva'], k) else: disk = "%sGB in %s" % ( v['disk'], os.path.join(xenconf.get('home', '/home/xen/'), 'domains', k, 'disk.img')) if k in doms: status = "Running" else: if k in ps: status = "Building..." else: status = "Stopped" xenServers.append( (k, status, v['memory'], disk, v['dist'], v['ip'] or 'DHCP', tags.a(href="Edit/%s/" % k)["Edit"])) return ctx.tag[ tags.h3[tags.img(src="/images/networking_section.png"), " Xen"], PageHelpers.TabSwitcher(( ('Xen Servers', 'panelXenServ'), ('Xen Configuration', 'panelXenConf'), )), tags.div(id="panelXenServ", _class="tabPane") [tags.h3["Xen Servers"], PageHelpers.dataTable([ 'Name', 'Status', 'Memory', 'Disk', 'Distribution', 'IP', '' ], xenServers, sortable=True), tags.h3["Create new image"], tags.directive('form newXen'), tags. p["Note that images will take a long time to create. The status will read 'Building...' until it is completed"]], tags.div(id="panelXenConf", _class="tabPane")[ tags.h3["Xen Configuration"], tags.directive('form xenConf')], PageHelpers.LoadTabSwitcher()]
def render_content(self, ctx, data): leases = self.sysconf.DHCP.get('leases', {}) statics = [] for ip, hostmac in leases.items(): statics.append((ip, hostmac[0], hostmac[1])) statics.sort() sharenets = [] for sharenet, defin in self.sysconf.DHCP.get('sharenets', {}).items(): sharenets.append( (sharenet, defin['domain'], self.sysconf.EthernetDevices[sharenet]['ip'], tags.a(href="Delnet/%s/" % sharenet)[tags.img(src="/images/ex.png")])) return ctx.tag[ tags.h3[tags.img(src="/images/netdrive.png"), " DHCP"], PageHelpers.TabSwitcher(( ('DHCP Settings', 'panelSettings'), ('Static Leases', 'panelLeases'), ('Shared Networks', 'panelAltnet'), )), tags.div(id="panelLeases", _class="tabPane")[ tags.table(cellspacing=0, _class='listing')[tags.thead( background="/images/gradMB.png")[tags.tr[ tags.th["IP Address"], tags.th["Hostname"], tags.th["MAC Address"], tags.th[""], ]], tags.tbody[[ tags.tr[tags.td[i[0]], tags.td[i[1]], tags.td[i[2]], tags.td[tags.a( href="Delete/%s/" % i[0])[tags.img(src="/images/ex.png")]]] for i in statics ], ]], tags.br, tags.h3["Add Static Lease"], tags.directive('form addStatic')], tags.div(id="panelSettings", _class="tabPane" )[tags.directive('form confDhcp')], tags.div(id="panelAltnet", _class="tabPane")[ PageHelpers.dataTable( ("Interface", "Domain", "Network", ""), sharenets), tags.h3["Add DHCP Network"], tags.directive('form addNet')], PageHelpers.LoadTabSwitcher()]
def returnDayView(dayData): """ Returns the details for a particular day""" flatBlocks = [] date = datetime.date(self.year, self.month, self.day).strftime("%d %h %Y") for rows in dayData: flatBlocks.append(( "%0.2fMB" % (rows[0]/(1024*1024)), tags.a(href=url.root.child("ProxyUse").child("ShowSiteHost").child(rows[2]).child(self.year).child(self.month).child(self.day))[rows[1]] )) return ctx.tag[ tags.h3[ tags.img(src="/images/stock-download.png"), "Web Usage - Sites visited on %s" % (date) ], tags.a(href=url.root.child("ProxyUse"))["Back to overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month))["Back to month overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month).child(self.day))["Back to day overview"], tags.br, tags.br, PageHelpers.dataTable([('int', 'Total Traffic'), ('istr', 'Site')], flatBlocks, sortable=True) ]
def render_drives(self, ctx, data): drives = self.getMaps() return ctx.tag[ tags.h3[tags.img(src="/images/netdrive.png"), " Network Drives"], PageHelpers.dataTable(["Login Group", "Drive Letter", "Share Path", ""], [ [ i[0], i[1], i[2], tags.a( href="DeleteMap/%s/" % i[1], onclick="return confirm('Are you sure you want to delete this drive?');" )[tags.img(src="/images/ex.png")] ] for i in drives], sortable=True ), tags.h3["Add Network Drive"], tags.directive('form addDrive') ]
def returnMonthView(monthData): """ Returns days in this month for which we have data""" flatBlocks = [] for rows in monthData: date = '/'.join([ str(i) for i in (rows[0].year, rows[0].month, rows[0].day) ]) flatBlocks.append( (tags.a(href=url.root.child("ProxyUse").child( "ShowDays").child(date))[rows[0].strftime("%d %h %Y")], "%0.2fMB" % (rows[1] / (1024 * 1024)), rows[2])) return ctx.tag[ tags.h3[ tags.img(src="/images/stock-download.png"), "Web Usage - Month overview for %s" % datetime.date(self.year, self.month, 1).strftime("%h %Y")], tags.a(href=url.root.child("ProxyUse"))["Back to overview"], " ", tags.br, tags.br, PageHelpers.dataTable( ['Date', 'Total Traffic', 'Sites Visited'], flatBlocks)]
def returnMonthIPView(dayData): """ Returns the details for a particular day""" flatBlocks = [] for rows in dayData: flatBlocks.append(( tags.a(href=url.root.child("ProxyUse").child("ShowHost").child(rows[3]).child(self.year).child(self.month))[rows[2]], rows[5], "%0.2fMB" % (rows[0]/(1024*1024)), int(rows[1]) )) return ctx.tag[ tags.h3[ tags.img(src="/images/stock-download.png"), "Web Usage - Per user statistics for %s" % datetime.date(self.year, self.month, 1).strftime("%h %Y") ], tags.a(href=url.root.child("ProxyUse"))["Back to overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month))["Back to month overview"], tags.br, tags.br, PageHelpers.dataTable([('str', 'Host'), ('str', 'Username'), ('int', 'Total Traffic'), ('int', 'Sites Visited')], flatBlocks, sortable=True) ]
def renderFragment(ret, error=False): if error: print ret return ctx.tag["Error 1"] connections = [] for con in ret.split('\n'): m = regex.match(con) if m: tup = m.groups() if tup[0] == tup[2]: # boring continue connections.append(list(tup)+[ tags.a(href="#addRule", onclick="populateRule('%s', '%s', '%s', '%s');" % (tup))[ "Create Rule" ] ]) return ctx.tag[ PageHelpers.dataTable(["Destination IP", "Destination Port", "Source IP", "Source Port", ""], connections) ]
def returnMonthView(monthData): """ Returns days in this month for which we have data""" flatBlocks = [] for rows in monthData: flatBlocks.append(( tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(rows[0].year).child(rows[0].month).child(rows[0].day))[ rows[0].strftime("%d %h %Y") ], "%0.2fMB" % (rows[1]/(1024*1024)), rows[2] )) return ctx.tag[ tags.h3[ tags.img(src="/images/stock-download.png"), "Web Usage - Month overview for %s" % datetime.date(self.year, self.month, 1).strftime("%h %Y") ], tags.a(href=url.root.child("ProxyUse"))["Back to overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowDays").child(self.year).child(self.month).child("0"))["Month host overview"], " ", tags.a(href=url.root.child("ProxyUse").child("ShowSites").child(self.year).child(self.month).child("0"))["Month sites overview"], " ", tags.br, tags.br, PageHelpers.dataTable([('cdate', 'Date'), ('int', 'Total Traffic'), ('int', 'Sites Visited')], flatBlocks, sortable=True) ]
def render_content(self, ctx, data): mq = WebUtils.system('getent passwd | grep Computer') def gotResult(proc): comps = [] for i in proc.split('\n'): if i.strip('\n'): name = i.split(':')[0].strip('$') comps.append([name, tags.a(href=url.root.child("Computers").child("Delete").child(name), onclick="return confirm('%s');" % self.text.compConfirm)[tags.img(src="/images/ex.png")]]) return comps res = wait(mq) yield res mq = res.getResult() getComputers = gotResult(mq) Utils.log.msg('%s opened Tools/Computers' % (self.avatarId.username)) yield ctx.tag[ tags.h3[tags.img(src='/images/srvman.png'), self.text.compHeading], tags.h3[self.text.compHeadingList], PageHelpers.dataTable([self.text.compName, ''], getComputers, sortable=True), tags.h3[self.text.compHeadingAdd], tags.directive('form addComputer'), ]
def generateRep(): userPie = PageHelpers.GraphObject("userPieTel", "pie") #userPie.options["HtmlText"] = True userPie.options["grid"] = { "verticalLines": False, "horizontalLines": False, "outlineWidth": 0 } userPie.options["xaxis"] = {"showLabels": False} userPie.options["yaxis"] = {"showLabels": False} userPie.options["legend"] = { "show": True } #"position": "se", "backgroundColor": "#D2E8FF"} for user, ent in totals.items(): userPie.defineDataSet(user, self.getName(user)) userPie[user] = ent['tot'][1] data.append([ tags.a(href=url.root.child('TelReport').child( "User").child(user).child(self.day).child( self.month).child(self.year))[user], self.getName(user), self.genDuration(ent['out'][1]), ent['out'][2], self.genDuration(ent['rec'][1]), ent['rec'][2], self.genDuration(ent['que'][1]), ent['que'][2], self.genDuration(ent['tot'][1]), ent['tot'][2], ]) return [ tags.h3["Overview Telephone Stats"], userPie, PageHelpers.dataTable(header, data, sortable=True) ]