Exemplo n.º 1
0
 def setUp(self):
     f = DummyFile(fname)
     self.server = StreamServer(('127.0.0.1', PORT),
                                BTFileHandler,
                                tfile=f,
                                allow_range=True)
     self.server.run()
Exemplo n.º 2
0
    def setUp(self):

        f = tempfile.NamedTemporaryFile(delete=False)
        s = os.urandom(TEST_FILE_SIZE)
        f.write(s)
        self.fname = f.name
        f.close()

        size = os.stat(self.fname).st_size
        fmap = Peer_Request(0, 2000)
        self.tf_size = size
        fname = os.path.split(self.fname)[1]
        self.client = DummyClient(self.fname, 0)
        self.file = BTFile(fname, '/tmp', 1, size, fmap, piece_size,
                           self.client.request)
        self.client.serve(self.file)
        self.server = StreamServer(('127.0.0.1', 5001), BTFileHandler,
                                   self.file)
        self.t = Thread(target=self.server.handle_request)
        self.t.start()