Esempio n. 1
0
 def test_ulozto(self):
     url='http://www.ulozto.cz/xEtqWa87/jachyme-hod-ho-do-stroje-1974-mp4'
     cls=find_matching_plugin(url)
     try:
         import adecaptcha
         self.assertTrue(cls)
         loader=HTTPLoader(url, 0, cls)
         loader.init()
     except ImportError:
         print >>sys.stderr, 'WARNIG - adecaptcha not install ulozto plugin will not be available'
Esempio n. 2
0
 def test_ulozto(self):
     url = 'http://www.ulozto.cz/xEtqWa87/jachyme-hod-ho-do-stroje-1974-mp4'
     cls = find_matching_plugin(url)
     try:
         import adecaptcha
         self.assertTrue(cls)
         loader = HTTPLoader(url, 0, cls)
         loader.init()
     except ImportError:
         print >> sys.stderr, 'WARNIG - adecaptcha not install ulozto plugin will not be available'
Esempio n. 3
0
 def test(self):
     f=DummyFile(fname)
     piece_size=1024
     c=HTTPLoader(URL, 0)
     c.init()
     first=c.load_piece(0, piece_size)
     self.assertEqual(len(first.data), piece_size)
     self.assertEqual(first.piece,0)
     self.assertEqual(first.type,'video/x-msvideo')
     self.assertEqual(first.total_size, f.size)
     
     piece_size=2048*1024
     last_piece=f.size // piece_size
     
     buf=StringIO()
     tmp_file=tempfile.mktemp()
     base,tmp_file=os.path.split(tmp_file)
     htfile=HTFile(tmp_file, base, f.size, piece_size, lambda a,b: self.fail('Should not need prioritize'))
     for piece in xrange(last_piece+1):
         print "Piece %d"%piece
         p=c.load_piece(piece, piece_size)
         self.assertTrue(p.data)
         if piece!=last_piece:
             self.assertEqual(len(p.data), piece_size)
         if piece==last_piece:
             self.assertEqual(len(p.data), f.size % piece_size)
             
         buf.write(p.data)
         htfile.update_piece(piece, p.data)
     
     
     data=buf.getvalue()
     with f.create_cursor() as reader:
         ref=reader.read()
         
     self.assertEqual(data, ref, "Diffrent")
     
     buf=StringIO()
     with htfile.create_cursor() as reader:
         while True:
             d=reader.read()
             if not d:
                 break
             buf.write(d)
     data2=buf.getvalue() 
     self.assertEqual(len(data2),len(ref))    
     self.assertEqual(data2, ref, "Different")
Esempio n. 4
0
    def test(self):
        f = DummyFile(fname)
        piece_size = 1024
        c = HTTPLoader(URL, 0)
        c.init()
        first = c.load_piece(0, piece_size)
        self.assertEqual(len(first.data), piece_size)
        self.assertEqual(first.piece, 0)
        self.assertEqual(first.type, 'video/x-msvideo')
        self.assertEqual(first.total_size, f.size)

        piece_size = 2048 * 1024 / 2
        last_piece = f.size // piece_size

        tmp_file = tempfile.mktemp()
        base, tmp_file = os.path.split(tmp_file)
        htfile = HTFile(tmp_file, base, f.size, piece_size,
                        lambda a, b: self.fail('Should not need prioritize'))
        pool = Pool(piece_size, [c],
                    htfile.update_piece,
                    speed_limit=MyResolver.SPEED_LIMIT)

        def gen_loader(url, i):
            return HTTPLoader(url, i)

        for i in xrange(1, 3):
            pool.add_worker_async(i, gen_loader, (URL, i))
        for i in xrange(last_piece + 1):
            pool.add_piece(i, 10 - i)
        while not htfile.is_complete:
            time.sleep(1)
            print htfile.pieces

        with f.create_cursor() as reader:
            ref = reader.read()

        buf = StringIO()
        with htfile.create_cursor() as reader:
            while True:
                d = reader.read()
                if not d:
                    break
                buf.write(d)
        data2 = buf.getvalue()
        self.assertEqual(len(data2), len(ref))
        self.assertEqual(data2, ref, "Different")
Esempio n. 5
0
 def test(self):
     f=DummyFile(fname)
     piece_size=1024
     c=HTTPLoader(URL, 0)
     first=c.load_piece(0, piece_size)
     self.assertEqual(len(first.data), piece_size)
     self.assertEqual(first.piece,0)
     self.assertEqual(first.type,'video/x-msvideo')
     self.assertEqual(first.total_size, f.size)
     
     piece_size=2048*1024/2
     last_piece=f.size // piece_size
     
     tmp_file=tempfile.mktemp()
     base,tmp_file=os.path.split(tmp_file)
     htfile=HTFile(tmp_file, base, f.size, piece_size, lambda a,b: self.fail('Should not need prioritize'))
     pool=Pool(piece_size, [c], htfile.update_piece, speed_limit=MyResolver.SPEED_LIMIT)
     def gen_loader(url,i):
         return HTTPLoader(url, i)
     for i in xrange(1,3):
         pool.add_worker_async(i, gen_loader, (URL,i))
     for i in xrange(last_piece+1):
         pool.add_piece(i, 10-i)
     while not htfile.is_complete:
         time.sleep(1)
         print htfile.pieces
     
     with f.create_cursor() as reader:
         ref=reader.read()
     
     buf=StringIO()
     with htfile.create_cursor() as reader:
         while True:
             d=reader.read()
             if not d:
                 break
             buf.write(d)
     data2=buf.getvalue() 
     self.assertEqual(len(data2),len(ref))    
     self.assertEqual(data2, ref, "Different")
Esempio n. 6
0
    def test(self):
        f = DummyFile(fname)
        piece_size = 1024
        c = HTTPLoader(URL, 0)
        c.init()
        first = c.load_piece(0, piece_size)
        self.assertEqual(len(first.data), piece_size)
        self.assertEqual(first.piece, 0)
        self.assertEqual(first.type, 'video/x-msvideo')
        self.assertEqual(first.total_size, f.size)

        piece_size = 2048 * 1024
        last_piece = f.size // piece_size

        buf = StringIO()
        tmp_file = tempfile.mktemp()
        base, tmp_file = os.path.split(tmp_file)
        htfile = HTFile(tmp_file, base, f.size, piece_size,
                        lambda a, b: self.fail('Should not need prioritize'))
        for piece in xrange(last_piece + 1):
            print "Piece %d" % piece
            p = c.load_piece(piece, piece_size)
            self.assertTrue(p.data)
            if piece != last_piece:
                self.assertEqual(len(p.data), piece_size)
            if piece == last_piece:
                self.assertEqual(len(p.data), f.size % piece_size)

            buf.write(p.data)
            htfile.update_piece(piece, p.data)

        data = buf.getvalue()
        with f.create_cursor() as reader:
            ref = reader.read()

        self.assertEqual(data, ref, "Diffrent")

        buf = StringIO()
        with htfile.create_cursor() as reader:
            while True:
                d = reader.read()
                if not d:
                    break
                buf.write(d)
        data2 = buf.getvalue()
        self.assertEqual(len(data2), len(ref))
        self.assertEqual(data2, ref, "Different")
Esempio n. 7
0
 def gen_loader(url, i):
     return HTTPLoader(url, i)