Пример #1
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = os.path.join(os.getcwdu(),"dest")

        try:
            shutil.rmtree(self.destdir)
        except:
            pass
        os.mkdir(self.destdir)
        
        # Create tree with 6 chunks
        self.chunks = []
        for i in range(0,6+1):
            chunk = chr(i) * 1024
            self.chunks.append(chunk)
            
        self.hashes = {}
        self.hashes[(7,7)] = '\x00' * 20
        for i in range(0,6+1):
            hash = sha(self.chunks[i]).digest()
            self.hashes[(i,i)] = hash
        self.hashes[(0,1)] = sha(self.hashes[(0,0)]+self.hashes[(1,1)]).digest()
        self.hashes[(2,3)] = sha(self.hashes[(2,2)]+self.hashes[(3,3)]).digest()
        self.hashes[(4,5)] = sha(self.hashes[(4,4)]+self.hashes[(5,5)]).digest()
        self.hashes[(6,7)] = sha(self.hashes[(6,6)]+self.hashes[(7,7)]).digest()
        
        self.hashes[(0,3)] = sha(self.hashes[(0,1)]+self.hashes[(2,3)]).digest()
        self.hashes[(4,7)] = sha(self.hashes[(4,5)]+self.hashes[(6,7)]).digest()
        
        self.hashes[(0,7)] = sha(self.hashes[(0,3)]+self.hashes[(4,7)]).digest()
Пример #2
0
    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])
Пример #3
0
    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])
Пример #4
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)
        
        self.cond = Condition()
        
        self.peer1port = 1234
        self.peer1 = UDPListener(self,self.peer1port)
        self.peer1.start()

        self.destdir = "."
        
        self.udpsendport = random.randint(14001,14999) #

        time.sleep(2) # let server threads start
Пример #5
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = '.'

        f = open("liveinput.dat","wb")
        self.nchunks = 1017
        for i in range(0,self.nchunks):
            data = chr((ord('a')+i)%256) * 1024
            f.write(data)
        f.close()

        self.livesourceinput = "liveinput.dat"
        self.filename = "storage.dat"
Пример #6
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = '.'

        f = open("liveinput.dat", "wb")
        self.nchunks = 1017
        for i in range(0, self.nchunks):
            data = chr((ord('a') + i) % 256) * 1024
            f.write(data)
        f.close()

        self.livesourceinput = "liveinput.dat"
        self.filename = "storage.dat"
Пример #7
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.cond = Condition()

        self.peer1port = 1234
        self.peer1 = UDPListener(self, self.peer1port)
        self.peer1.start()

        self.destdir = "."

        self.udpsendport = random.randint(14001, 14999)  #

        time.sleep(2)  # let server threads start
Пример #8
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = '.'

        f = open("liveinput.dat","wb")
        self.nchunks = 1017
        for i in range(0,self.nchunks):
            data = chr((ord('0')+i)%256) * 1024
            f.write(data)
        f.close()

        self.livesourceinput = "liveinput.dat"
        self.filename = "storage.dat"

        self.urlfilename = "swarm.url"
        self.livesigalg = ord(POPT_LSA_ECDSAP256SHA256)

        self.debug = True
Пример #9
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = '.'

        f = open("liveinput.dat", "wb")
        self.nchunks = 1017
        for i in range(0, self.nchunks):
            data = chr((ord('0') + i) % 256) * 1024
            f.write(data)
        f.close()

        self.livesourceinput = "liveinput.dat"
        self.filename = "storage.dat"

        self.urlfilename = "swarm.url"
        self.livesigalg = ord(POPT_LSA_ECDSAP256SHA256)

        self.debug = True
Пример #10
0
    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")
Пример #11
0
    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")
Пример #12
0
    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")
Пример #13
0
    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")
Пример #14
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.destdir = os.path.join(os.getcwdu(), "dest")

        try:
            shutil.rmtree(self.destdir)
        except:
            pass
        os.mkdir(self.destdir)

        # Create tree with 6 chunks
        self.chunks = []
        for i in range(0, 6 + 1):
            chunk = chr(i) * 1024
            self.chunks.append(chunk)

        self.hashes = {}
        self.hashes[(7, 7)] = '\x00' * 20
        for i in range(0, 6 + 1):
            hash = sha(self.chunks[i]).digest()
            self.hashes[(i, i)] = hash
        self.hashes[(0, 1)] = sha(self.hashes[(0, 0)] +
                                  self.hashes[(1, 1)]).digest()
        self.hashes[(2, 3)] = sha(self.hashes[(2, 2)] +
                                  self.hashes[(3, 3)]).digest()
        self.hashes[(4, 5)] = sha(self.hashes[(4, 4)] +
                                  self.hashes[(5, 5)]).digest()
        self.hashes[(6, 7)] = sha(self.hashes[(6, 6)] +
                                  self.hashes[(7, 7)]).digest()

        self.hashes[(0, 3)] = sha(self.hashes[(0, 1)] +
                                  self.hashes[(2, 3)]).digest()
        self.hashes[(4, 7)] = sha(self.hashes[(4, 5)] +
                                  self.hashes[(6, 7)]).digest()

        self.hashes[(0, 7)] = sha(self.hashes[(0, 3)] +
                                  self.hashes[(4, 7)]).digest()
Пример #15
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.statshttpport = 8091
Пример #16
0
    def setUpPreSession(self):
        TestAsServer.setUpPreSession(self)

        self.statshttpport = 8091