Beispiel #1
0
 def archive_callback(wk):
     if not wk.isArchived():
         log.error('[fTestFunc] wk not archive')
         return
     with open(name, 'rb') as fp:
         newmd5 = util.md5_for_file(fp)
     os.remove(name)
     if md5 != newmd5:
         log.error('[fTestFunc] md5 not match, n={}, {} ({})'.format(npf, newmd5, md5))
     else:
         log.info('[fTestFunc] n=%d', npf)
     return
Beispiel #2
0
 def archive_callback(wk):
     if not wk.isArchived():
         log.error('[fTestFunc] wk not archive')
         return
     with open(name, 'rb') as fp:
         newmd5 = util.md5_for_file(fp)
     os.remove(name)
     if md5 != newmd5:
         log.error('[fTestFunc] md5 not match, n={}, {} ({})'.format(
             npf, newmd5, md5))
     # else:
     #     log.info('[fTestFunc] n=%d', npf)
     return
Beispiel #3
0
 def archive_callback(wk):
     if not wk.isArchived():
         log.error('[mTestFunc] wk not archive')
         return
     with open(name, 'wb') as ff:
         ff.write(fp.getvalue())
     with open(name, 'rb') as ff:
         newmd5 = util.md5_for_file(ff)
     os.remove(name)
     if md5 != newmd5:
         log.error('[mTestFunc] md5 not match, n={}, {}'.format(npf, newmd5))
     else:
         log.info('[mTestFunc] n=%d', npf)
     return
Beispiel #4
0
 def archive_callback(wk):
     if not wk.isArchived():
         log.error('[mTestFunc] wk not archive')
         return
     with open(name, 'wb') as ff:
         ff.write(fp.getvalue())
     with open(name, 'rb') as ff:
         newmd5 = util.md5_for_file(ff)
     os.remove(name)
     if md5 != newmd5:
         log.error('[mTestFunc] md5 not match, n={}, {}'.format(
             npf, newmd5))
     else:
         log.info('[mTestFunc] n=%d', npf)
     return
Beispiel #5
0
 def test_miniaxel(self):
     print 'test_miniaxel'
     out_file = r'out_file'
     test_cases = [
         ['mini', '-n', '5', '-r', Test_miniaxel.url],
         ['mini', '-n', '2', '-r', Test_miniaxel.url],
         ['mini', '-n', '1', '-r', Test_miniaxel.url],
         ['mini', '-n', '5', '-r', Test_miniaxel.url],
     ]
     for argv in test_cases:
         try:
             miniaxel.main(argv)
             with open(out_file, 'rb') as fp:
                 md5 = util.md5_for_file(fp)
             self.assertTrue(Test_miniaxel.orig_md5 == md5)
         except Exception as e:
             print e
         finally:
             if os.path.exists(out_file):
                 os.remove(out_file)
Beispiel #6
0
def miniaxel_test(self):
    from vavava import util
    url = r'http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-gpl-5.1.31.msi'
    orig_md5 = r'140c4a7c9735dd3006a877a9acca3c31'
    out_file = r'out_file'
    test_cases = [
        ['mini', '-n', '5', '-r', url],
        ['mini', '-n', '2', '-r', url],
        ['mini', '-n', '1', '-r', url],
        ['mini', '-n', '5', '-r', url],
    ]
    for argv in test_cases:
        try:
            from miniaxel import main as _main
            _main(argv)
            with open(out_file, 'rb') as fp:
                md5 = util.md5_for_file(fp)
            self.assertTrue(orig_md5 == md5)
        except Exception as e:
            print e
        finally:
            if os.path.exists(out_file):
                os.remove(out_file)
Beispiel #7
0
def miniaxel_test(self):
    from vavava import util
    url = r'http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-gpl-5.1.31.msi'
    orig_md5 = r'140c4a7c9735dd3006a877a9acca3c31'
    out_file = r'out_file'
    test_cases = [
        ['mini', '-n', '5', '-r', url],
        ['mini', '-n', '2', '-r', url],
        ['mini', '-n', '1', '-r', url],
        ['mini', '-n', '5', '-r', url],
    ]
    for argv in test_cases:
        try:
            from miniaxel import main as _main
            _main(argv)
            with open(out_file, 'rb') as fp:
                md5 = util.md5_for_file(fp)
            self.assertTrue(orig_md5 == md5)
        except Exception as e:
            print e
        finally:
            if os.path.exists(out_file):
                os.remove(out_file)
Beispiel #8
0
    dlvs = []
    for i, url in enumerate(urls):
        dlvideo = VUrlTask(url, 0, 3, './tmp', bar=bar, log=log)
        dlvs.append(dlvideo)
    try:
        ws.serve()
        ws.addTasks(dlvs)
        while len(dlvs) > 0:
            for i, dlv in enumerate(dlvs):
                if dlv.isArchived() or dlv.isError():
                    del dlvs[i]
            _sleep(1)
    except KeyboardInterrupt:
        pass
    except Exception as e:
        log.exception(e)
    finally:
        ws.setToStop()
        ws.join()


if __name__ == '__main__':
    main()
    print '============== check'
    name = './tmp/小姜老师课堂.flv'
    with open(name, 'r') as fp:
        mm = util.md5_for_file(fp)
        print mm
        assert '8d3f6b0d51f0c2532e82dba9c6c933a4' == mm
    os.remove(name)
    os.rmdir('./tmp')
Beispiel #9
0
    dlvs = []
    for i, url in enumerate(urls):
        dlvideo = VUrlTask(url, 0, 3, './tmp', bar=bar, log=log)
        dlvs.append(dlvideo)
    try:
        ws.serve()
        ws.addTasks(dlvs)
        while len(dlvs) > 0:
            for i, dlv in enumerate(dlvs):
                if dlv.isArchived() or dlv.isError():
                    del dlvs[i]
            _sleep(1)
    except KeyboardInterrupt:
        pass
    except Exception as e:
        log.exception(e)
    finally:
        ws.setToStop()
        ws.join()


if __name__ == '__main__':
    main()
    print '============== check'
    name = './tmp/小姜老师课堂.flv'
    with open(name, 'r') as fp:
        mm = util.md5_for_file(fp)
        print mm
        assert '8d3f6b0d51f0c2532e82dba9c6c933a4' == mm
    os.remove(name)
    os.rmdir('./tmp')