def setUpPreSession(self): TestAsNPeers.setUpPreSession(self) # Setup peer0 as source self.peers[0].destdir = '.' self.vodinputsize = 1017 * 1024 + 17 f = open("vodinput.dat", "wb") for i in range(0, self.vodinputsize / 1024): data = chr((ord('a') + i) % 256) * 1024 f.write(data) tail = 'x' * 17 f.write(tail) f.close() self.peers[0].filename = "vodinput.dat" # Pre hash check and checkpoint sdef = SwiftDef() sdef.add_content(self.peers[0].filename) sdef.finalize(self.peers[0].binpath) self.swarmid = sdef.get_id() # save roothash # Start peer1 as VOD downloader self.peers[1].destdir = '.' #self.peers[1].usegtest = False #self.peers[1].binpath = os.path.join("..","Debug","SwiftPPSP.exe") # For CMDGW communication for peer1 self.buffer = '' self.stop = False
def setUpPreSession(self): TestAsServer.setUpPreSession(self) #self.cmdport = None self.httpport = None self.scandir = "seeder2" self.progress = True self.setUpScanDir() try: shutil.rmtree(self.scandir) except: pass os.mkdir(self.scandir) # Create content for i in range(len(self.filelist)): fn = self.filelist[i][0] s = self.filelist[i][1] f = open(fn, "wb") data = '#' * s f.write(data) f.close() # Pre hash check and checkpoint them sdef = SwiftDef() sdef.add_content(fn) sdef.finalize(self.binpath) self.filelist[i][2] = sdef.get_id() # save roothash for i in range(len(self.filelist)): print >> sys.stderr, "test: Configured from filelist", binascii.hexlify( self.filelist[i][2])
def setUpPreSession(self): TestAsNPeers.setUpPreSession(self) # Setup peer0 as source self.peers[0].destdir = '.' self.vodinputsize = 1017*1024+17 f = open("vodinput.dat","wb") for i in range(0,self.vodinputsize/1024): data = chr((ord('a')+i)%256) * 1024 f.write(data) tail = 'x' * 17 f.write(tail) f.close() self.peers[0].filename = "vodinput.dat" # Pre hash check and checkpoint sdef = SwiftDef() sdef.add_content(self.peers[0].filename) sdef.finalize(self.peers[0].binpath) self.swarmid = sdef.get_id() # save roothash # Start peer1 as VOD downloader self.peers[1].destdir = '.' #self.peers[1].usegtest = False #self.peers[1].binpath = os.path.join("..","Debug","SwiftPPSP.exe") # For CMDGW communication for peer1 self.buffer = '' self.stop = False
def setUpPreSession(self): TestAsServer.setUpPreSession(self) #self.cmdport = None self.httpport = None self.scandir = "seeder2" self.progress = True self.setUpScanDir() try: shutil.rmtree(self.scandir) except: pass os.mkdir(self.scandir) # Create content for i in range(len(self.filelist)): fn = self.filelist[i][0] s = self.filelist[i][1] f = open(fn,"wb") data = '#' * s f.write(data) f.close() # Pre hash check and checkpoint them sdef = SwiftDef() sdef.add_content(fn) sdef.finalize(self.binpath) self.filelist[i][2] = sdef.get_id() # save roothash for i in range(len(self.filelist)): print >>sys.stderr,"test: Configured from filelist",binascii.hexlify(self.filelist[i][2])
def setUpPreSession(self): TestAsServer.setUpPreSession(self) self.destdir = tempfile.mkdtemp() print >>sys.stderr,"test: destdir is",self.destdir self.setUpFileList() idx = self.filelist[0][0].find("/") specprefix = self.filelist[0][0][0:idx] prefixdir = os.path.join(self.destdir,specprefix) os.mkdir(prefixdir) sdef = SwiftDef() # Create content for fn,s in self.filelist: osfn = fn.replace("/",os.sep) fullpath = os.path.join(self.destdir,osfn) f = open(fullpath,"wb") data = fn[len(specprefix)+1] * s f.write(data) f.close() sdef.add_content(fullpath,fn) self.specfn = sdef.finalize(self.binpath,destdir=self.destdir) f = open(self.specfn,"rb") self.spec = f.read() f.close() self.swarmid = sdef.get_id() print >>sys.stderr,"test: setUpPreSession: roothash is",binascii.hexlify(self.swarmid) self.mfdestfn = os.path.join(self.destdir,binascii.hexlify(self.swarmid)) shutil.copyfile(self.specfn,self.mfdestfn) shutil.copyfile(self.specfn+".mhash",self.mfdestfn+".mhash") shutil.copyfile(self.specfn+".mbinmap",self.mfdestfn+".mbinmap")
def setUpPreSession(self): TestAsServer.setUpPreSession(self) self.httpport = None self.zerosdir = os.path.join(os.getcwd(), "zeros2") self.exitwait = 36 self.progress = True self.setUpZerosDir() try: shutil.rmtree(self.zerosdir) except: pass os.mkdir(self.zerosdir) # Create content for i in range(len(self.filelist)): fn = self.filelist[i][0] s = self.filelist[i][1] f = open(fn, "wb") data = '#' * s f.write(data) f.close() # Pre hash check and checkpoint them sdef = SwiftDef() sdef.add_content(fn) sdef.finalize(self.binpath) self.filelist[i][2] = sdef.get_id() # save roothash # Hack: now copy to <roothash>[.mhash|.mbinmap] files such that zerostate works for i in range(len(self.filelist)): print >> sys.stderr, "test: Configuring", binascii.hexlify( self.filelist[i][2]) srcfile = self.filelist[i][0] dstfile = os.path.join(self.zerosdir, binascii.hexlify(self.filelist[i][2])) shutil.copyfile(srcfile, dstfile) shutil.copyfile(srcfile + ".mhash", dstfile + ".mhash") shutil.copyfile(srcfile + ".mbinmap", dstfile + ".mbinmap")
def setUpPreSession(self): TestAsServer.setUpPreSession(self) self.destdir = tempfile.mkdtemp() print >> sys.stderr, "test: destdir is", self.destdir self.setUpFileList() idx = self.filelist[0][0].find("/") specprefix = self.filelist[0][0][0:idx] prefixdir = os.path.join(self.destdir, specprefix) os.mkdir(prefixdir) sdef = SwiftDef() # Create content for fn, s in self.filelist: osfn = fn.replace("/", os.sep) fullpath = os.path.join(self.destdir, osfn) f = open(fullpath, "wb") data = fn[len(specprefix) + 1] * s f.write(data) f.close() sdef.add_content(fullpath, fn) self.specfn = sdef.finalize(self.binpath, destdir=self.destdir) f = open(self.specfn, "rb") self.spec = f.read() f.close() self.swarmid = sdef.get_id() print >> sys.stderr, "test: setUpPreSession: roothash is", binascii.hexlify( self.swarmid) self.mfdestfn = os.path.join(self.destdir, binascii.hexlify(self.swarmid)) shutil.copyfile(self.specfn, self.mfdestfn) shutil.copyfile(self.specfn + ".mhash", self.mfdestfn + ".mhash") shutil.copyfile(self.specfn + ".mbinmap", self.mfdestfn + ".mbinmap")
def setUpPreSession(self): TestAsServer.setUpPreSession(self) self.httpport = None self.zerosdir = os.path.join(os.getcwd(),"zeros2") self.exitwait = 36 self.progress = True self.setUpZerosDir() try: shutil.rmtree(self.zerosdir) except: pass os.mkdir(self.zerosdir) # Create content for i in range(len(self.filelist)): fn = self.filelist[i][0] s = self.filelist[i][1] f = open(fn,"wb") data = '#' * s f.write(data) f.close() # Pre hash check and checkpoint them sdef = SwiftDef() sdef.add_content(fn) sdef.finalize(self.binpath) self.filelist[i][2] = sdef.get_id() # save roothash # Hack: now copy to <roothash>[.mhash|.mbinmap] files such that zerostate works for i in range(len(self.filelist)): print >>sys.stderr,"test: Configuring",binascii.hexlify(self.filelist[i][2]) srcfile = self.filelist[i][0] dstfile = os.path.join(self.zerosdir,binascii.hexlify(self.filelist[i][2])) shutil.copyfile(srcfile,dstfile) shutil.copyfile(srcfile+".mhash",dstfile+".mhash") shutil.copyfile(srcfile+".mbinmap",dstfile+".mbinmap")
def setUpPreSession(self): TestAsNPeers.setUpPreSession(self) # Setup peer0 as source self.peers[0].destdir = '.' #self.peers[0].destdir = tempfile.mkdtemp() self.peers[0].zerosdir = os.path.join(os.getcwd(),'seeddump') try: shutil.rmtree(self.peers[0].zerosdir) except: print_exc() os.mkdir(self.peers[0].zerosdir) print >>sys.stderr,"test: destdir is",self.peers[0].zerosdir # Create a multi-file swarm self.setUpFileList() idx = self.filelist[0][0].find("/") specprefix = self.filelist[0][0][0:idx] prefixdir = os.path.join(self.peers[0].zerosdir,specprefix) os.mkdir(prefixdir) sdef = SwiftDef() self.vodinputsize = 0L # Create content for fn,s in self.filelist: osfn = fn.replace("/",os.sep) fullpath = os.path.join(self.peers[0].zerosdir,osfn) f = open(fullpath,"wb") data = fn[len(specprefix)+1] * s f.write(data) f.close() print >>sys.stderr,"test: Creating",fullpath,fn sdef.add_content(fullpath,fn) self.specfn = sdef.finalize(self.peers[0].binpath,destdir=self.peers[0].zerosdir) f = open(self.specfn,"rb") self.spec = f.read() f.close() self.swarmid = sdef.get_id() print >>sys.stderr,"test: setUpPreSession: roothash is",binascii.hexlify(self.swarmid) self.mfdestfn = os.path.join(self.peers[0].zerosdir,binascii.hexlify(self.swarmid)) print >>sys.stderr,"test: setUpPreSession: copy to",self.mfdestfn shutil.copyfile(self.specfn,self.mfdestfn) shutil.copyfile(self.specfn+".mhash",self.mfdestfn+".mhash") shutil.copyfile(self.specfn+".mbinmap",self.mfdestfn+".mbinmap") # Start peer1 as VOD downloader self.peers[1].destdir = 'clientdump' try: shutil.rmtree(self.peers[1].destdir) except: pass os.mkdir(self.peers[1].destdir) #self.peers[1].usegtest = False #self.peers[1].binpath = os.path.join("..","Debug","SwiftPPSP.exe") #self.peers[0].debug = True #self.peers[1].debug = False # For CMDGW communication for peer1 self.buffer = '' self.stop = False
def setUpPreSession(self): TestAsNPeers.setUpPreSession(self) # Setup peer0 as source self.peers[0].destdir = '.' #self.peers[0].destdir = tempfile.mkdtemp() self.peers[0].zerosdir = os.path.join(os.getcwd(), 'seeddump') try: shutil.rmtree(self.peers[0].zerosdir) except: print_exc() os.mkdir(self.peers[0].zerosdir) print >> sys.stderr, "test: destdir is", self.peers[0].zerosdir # Create a multi-file swarm self.setUpFileList() idx = self.filelist[0][0].find("/") specprefix = self.filelist[0][0][0:idx] prefixdir = os.path.join(self.peers[0].zerosdir, specprefix) os.mkdir(prefixdir) sdef = SwiftDef() self.vodinputsize = 0L # Create content for fn, s in self.filelist: osfn = fn.replace("/", os.sep) fullpath = os.path.join(self.peers[0].zerosdir, osfn) f = open(fullpath, "wb") data = fn[len(specprefix) + 1] * s f.write(data) f.close() print >> sys.stderr, "test: Creating", fullpath, fn sdef.add_content(fullpath, fn) self.specfn = sdef.finalize(self.peers[0].binpath, destdir=self.peers[0].zerosdir) f = open(self.specfn, "rb") self.spec = f.read() f.close() self.swarmid = sdef.get_id() print >> sys.stderr, "test: setUpPreSession: roothash is", binascii.hexlify( self.swarmid) self.mfdestfn = os.path.join(self.peers[0].zerosdir, binascii.hexlify(self.swarmid)) print >> sys.stderr, "test: setUpPreSession: copy to", self.mfdestfn shutil.copyfile(self.specfn, self.mfdestfn) shutil.copyfile(self.specfn + ".mhash", self.mfdestfn + ".mhash") shutil.copyfile(self.specfn + ".mbinmap", self.mfdestfn + ".mbinmap") # Start peer1 as VOD downloader self.peers[1].destdir = 'clientdump' try: shutil.rmtree(self.peers[1].destdir) except: pass os.mkdir(self.peers[1].destdir) #self.peers[1].usegtest = False #self.peers[1].binpath = os.path.join("..","Debug","SwiftPPSP.exe") #self.peers[0].debug = True #self.peers[1].debug = False # For CMDGW communication for peer1 self.buffer = '' self.stop = False