def l(self, uuid): mindex = index.manage(sharedir=forbanshareroot, forbanglobal=forbanpath) dloot = loot.loot(dynpath=os.path.join(forbanpath,"var")) html = htmlheader html += """<br/> <br/> <br /> <div class="left inner"> <h2>Files available in loot %s </h2>""" % dloot.getname(uuid) html += htmlnav html += "<table>" html += "<tr><td>Filename</td><td>Fetch</td></tr>" for fileinindex in mindex.search("^((?!forban).)*$", uuid): filei = fileinindex.rsplit(",",1)[0] if re.search('/\.',filei): continue if re.search('^\+\.',filei): continue html += "<tr>" sourcev4 = dloot.getipv4(uuid) sourcev6 = dloot.getipv6(uuid) size = tools.convertbytes(mindex.getfilesize(filename=filei,uuid=uuid)) html += """<td>%s (%s)</td><td><a href="/s/?g=%s&f=b64e">get</a></td> """ % (filei,size,base64e.encode(filei)) html += "</tr>" html += "</table>" html += htmlfooter return html
def l(self, uuid): mindex = index.manage(sharedir=forbanshareroot, forbanglobal=forbanpath) dloot = loot.loot(dynpath=os.path.join(forbanpath, "var")) html = htmlheader html += """<br/> <br/> <br /> <div class="left inner"> <h2>Files available in loot %s </h2>""" % dloot.getname( uuid) html += htmlnav html += "<table>" html += "<tr><td>Filename</td><td>Fetch</td></tr>" tempindex = mindex.search("^((?!forban).)*$", uuid) tempindex.sort(key=string.lower) for fileinindex in tempindex: filei = fileinindex.rsplit(",", 1)[0] if re.search('/\.', filei): continue if re.search('^\+\.', filei): continue html += "<tr>" sourcev4 = dloot.getipv4(uuid) sourcev6 = dloot.getipv6(uuid) size = tools.convertbytes( mindex.getfilesize(filename=filei, uuid=uuid)) html += """<td>%s (%s)</td><td><a href="/s/?g=%s&f=b64e">get</a></td> """ % ( filei, size, base64e.encode(filei)) html += "</tr>" html += "</table>" html += htmlfooter return html
def totalfilesize (self, uuid=None, prettyprint = True): if uuid is None: return False cachepath = os.path.join(self.lootdir, uuid, "cache","forban","index") if not os.path.exists(cachepath): return False totalvalue = 0 f = open (cachepath, "r") for line in f.readlines(): val = line.rsplit(",",1)[1].rstrip('\n') totalvalue = totalvalue + int(val) f.close() if prettyprint is False: return totalvalue else: return tools.convertbytes(totalvalue)
def totalfilesize(self, uuid=None, prettyprint=True): if uuid is None: return False cachepath = os.path.join(self.lootdir, uuid, "cache", "forban", "index") if not os.path.exists(cachepath): return False totalvalue = 0 f = open(cachepath, "r") for line in f.readlines(): val = line.rsplit(",", 1)[1].rstrip('\n') totalvalue = totalvalue + int(val) f.close() if prettyprint is False: return totalvalue else: return tools.convertbytes(totalvalue)