Exemple #1
0
 def testGetWithDir(self):
     tmpdir = utils.get_tmp_dir()
     origpath = os.path.join(tmpdir, 'testGetWithDir')
     os.mkdir(origpath)
     dstpath = utils.get(origpath)
     self.assertTrue(dstpath.endswith('/'))
     self.assertTrue(os.path.isdir(dstpath))
Exemple #2
0
    def testInstallFromDir(self):
        class MockInstallHost:
            def __init__(self):
                self.commands = []

            def run(self, command):
                if command == "grep autodir= /etc/autotest.conf":
                    result= hosts.CmdResult()
                    result.stdout = "autodir=/usr/local/autotest\n"
                    return result
                else:
                    self.commands.append(command)

            def send_file(self, src, dst):
                self.commands.append("send_file: %s %s" % (src,
                                                           dst))

        host = MockInstallHost()
        tmpdir = utils.get_tmp_dir()
        self.autotest.get(tmpdir)
        self.autotest.install(host)
        self.assertEqual(host.commands[0],
                         'mkdir -p /usr/local/autotest')
        self.assertTrue(host.commands[1].startswith('send_file: /tmp/'))
        self.assertTrue(host.commands[1].endswith(
                '/ /usr/local/autotest'))
Exemple #3
0
 def testGetWithDir(self):
     tmpdir = utils.get_tmp_dir()
     origpath = os.path.join(tmpdir, 'testGetWithDir')
     os.mkdir(origpath)
     dstpath = utils.get(origpath)
     self.assertTrue(dstpath.endswith('/'))
     self.assertTrue(os.path.isdir(dstpath))
Exemple #4
0
 def testGetWithOpenFile(self):
     tmpdir = utils.get_tmp_dir()
     tmppath = os.path.join(tmpdir, 'testfile')
     tmpfile = file(tmppath, 'w')
     print >> tmpfile, 'Test string'
     tmpfile.close()
     tmpfile = file(tmppath)
     newtmppath = utils.get(tmpfile)
     self.assertEqual(file(newtmppath).read(), 'Test string\n')
Exemple #5
0
 def testGetWithOpenFile(self):
     tmpdir = utils.get_tmp_dir()
     tmppath = os.path.join(tmpdir, 'testfile')
     tmpfile = file(tmppath, 'w')
     print >> tmpfile, 'Test string'
     tmpfile.close()
     tmpfile = file(tmppath)
     newtmppath = utils.get(tmpfile)
     self.assertEqual(file(newtmppath).read(), 'Test string\n')
def get_subtitle(cid):
    url = config.COMMENT_URL.format(str(cid))
    print_info('Comment url: ' + url)
    input = utils.get_tmp_dir() + '/tmp.xml'
    output = utils.get_tmp_dir() + '/tmp.ass'

    local_file = open(input, "w")
    local_file.write(utils.get_url_content(url))
    local_file.close()

    Danmaku2ASS(input,
                output,
                config.WIDTH,
                config.HEIGHT,
                font_size=config.FONT_SIZE,
                text_opacity=config.TEXT_OPACITY,
                is_reduce_comments=config.IS_REDUCE_COMMENTS,
                duration_marquee=config.DURATION_MARQUEE,
                duration_still=config.DURATION_STILL)
    return output
    def testInstallFromDir(self):
        class MockInstallHost:
            def __init__(self):
                self.commands = []

            def run(self, command):
                if command == "grep autodir= /etc/autotest.conf":
                    result = hosts.CmdResult()
                    result.stdout = "autodir=/usr/local/autotest\n"
                    return result
                else:
                    self.commands.append(command)

            def send_file(self, src, dst):
                self.commands.append("send_file: %s %s" % (src, dst))

        host = MockInstallHost()
        tmpdir = utils.get_tmp_dir()
        self.autotest.get(tmpdir)
        self.autotest.install(host)
        self.assertEqual(host.commands[0], 'mkdir -p /usr/local/autotest')
        self.assertTrue(host.commands[1].startswith('send_file: /tmp/'))
        self.assertTrue(host.commands[1].endswith('/ /usr/local/autotest'))
Exemple #8
0
                        help="specify file or dir")
    parser.add_argument('-t',
                        '--thread_count',
                        type=int,
                        default=cpu_count() * 2,
                        help="specify threadCount,default is cpu_count*2")
    parser.add_argument(
        '-E',
        '--epub_version',
        type=str,
        default="2",
        help=
        "specify EPUB version to unpack to: 2, 3 or A (for automatic) or F for Force to EPUB2, default is 2"
    )
    args = parser.parse_args()
    config = Config()

    config.source = args.source
    config.epub_version = args.epub_version
    config.thread_count = args.thread_count

    return config


config = build_param()
config.bundle_dir = utils.get_bundle_dir()
config.tmp_dir = utils.get_tmp_dir()
config.kindlegen_bin = utils.kindle_gen_bin(config.bundle_dir)
print(config)
main(config)
 def setUp(self):
     self.data = test_utils.load_test_dataset()
     self.tmp_path = test_utils.get_tmp_dir()