示例#1
0
文件: compress.py 项目: SenadI/tea
def seven_zip(archive, items, self_extracting=False):
    """Create a 7z archive"""
    if not isinstance(items, (list, tuple)):
        items = [items]
    if self_extracting:
        return er(_get_sz(), 'a', '-ssw', '-sfx', archive, *items)
    else:
        return er(_get_sz(), 'a', '-ssw', archive, *items)
示例#2
0
文件: compress.py 项目: delicb/tea
def seven_zip(archive, items, self_extracting=False):
    """Create a 7z archive"""
    if not isinstance(items, (list, tuple)):
        items = [items]
    if self_extracting:
        return er(_get_sz(), 'a', '-ssw', '-sfx', archive, *items)
    else:
        return er(_get_sz(), 'a', '-ssw', archive, *items)
示例#3
0
def setup(module, target='zip', output_path=None, data_dir=None):
    dist = os.path.abspath('dist')
    try:
        if target == 'zip':
            assert er(
                'setup.py', 'install', '--no-compile', '--install-lib',
                os.path.join(dist, 'lib'), '--install-scripts',
                os.path.join(dist),
                *(['--install-data',
                   os.path.join(dist, data_dir)]
                  if data_dir is not None else []))
            with shell.goto(dist) as ok:
                assert ok
                assert compress.mkzip('%s.zip' % module,
                                      glob.glob(os.path.join('lib', '*')))
                assert shell.remove('lib')
        elif target == 'exe':
            assert er(
                'setup.py', 'install', '--no-compile', '--install-lib',
                os.path.join(dist, 'lib', 'python'), '--install-scripts',
                os.path.join(dist, 'scripts'),
                *(['--install-data',
                   os.path.join(dist, data_dir)]
                  if data_dir is not None else []))
            with shell.goto(dist) as ok:
                assert ok

                modules = list(
                    filter(os.path.exists, ['lib', 'scripts'] +
                           ([data_dir] if data_dir is not None else [])))
                assert compress.seven_zip('%s.exe' % module,
                                          modules,
                                          self_extracting=True)
                # Cleanup
                for module in modules:
                    assert shell.remove(module)
        if output_path is not None:
            output_path = os.path.abspath(output_path)
            if output_path != dist:
                if not os.path.isdir(output_path):
                    assert shell.mkdir(output_path)
                for filename in shell.search(dist, '*'):
                    output = os.path.join(
                        output_path,
                        filename.replace(dist, '', 1).strip('\\/'))
                    assert shell.move(filename, output)
        return 0
    except AssertionError as e:
        print(e)
        return 1
    finally:
        # Cleanup
        if output_path != dist:
            shell.remove(dist)
        if os.path.isdir('build'):
            shell.remove('build')
示例#4
0
文件: setup.py 项目: delicb/tea
def setup(module, target='zip', output_path=None, data_dir=None):
    dist = os.path.abspath('dist')
    try:
        if target == 'zip':
            assert er('setup.py', 'install', '--no-compile',
                      '--install-lib',     os.path.join(dist, 'lib'),
                      '--install-scripts', os.path.join(dist),
                      *(['--install-data',    os.path.join(dist, data_dir)]
                        if data_dir is not None else []))
            with shutil.goto(dist) as ok:
                assert ok
                assert compress.mkzip('%s.zip' % module,
                                      glob.glob(os.path.join('lib', '*')))
                assert shutil.remove('lib')
        elif target == 'exe':
            assert er('setup.py', 'install', '--no-compile',
                      '--install-lib',     os.path.join(dist, 'lib', 'python'),
                      '--install-scripts', os.path.join(dist, 'scripts'),
                      *(['--install-data',    os.path.join(dist, data_dir)]
                        if data_dir is not None else []))
            with shutil.goto(dist) as ok:
                assert ok

                modules = list(filter(os.path.exists,
                                      ['lib', 'scripts'] + (
                                          [data_dir] if data_dir is not None
                                          else [])))
                assert compress.seven_zip('%s.exe' % module, modules,
                                          self_extracting=True)
                # Cleanup
                for module in modules:
                    assert shutil.remove(module)
        if output_path is not None:
            output_path = os.path.abspath(output_path)
            if output_path != dist:
                if not os.path.isdir(output_path):
                    assert shutil.mkdir(output_path)
                for filename in shutil.search(dist, '*'):
                    output = os.path.join(output_path,
                                          filename.replace(dist, '', 1)
                                                  .strip('\\/'))
                    assert shutil.move(filename, output)
        return 0
    except AssertionError as e:
        print(e)
        return 1
    finally:
        # Cleanup
        if output_path != dist:
            shutil.remove(dist)
        if os.path.isdir('build'):
            shutil.remove('build')
示例#5
0
def test_execute_and_report():
    assert er(sys.executable, "-c", "import sys; sys.exit(0)")
    assert not er(sys.executable, "-c", "import sys; sys.exit(1)")
    assert not er(sys.executable, "-c", "import sys; sys.exit(-1)")
    assert not er(sys.executable, "-c", "import sys; sys.exit(2)")
示例#6
0
def test_execute_and_report():
    assert er(sys.executable, '-c', 'import sys; sys.exit(0)')
    assert not er(sys.executable, '-c', 'import sys; sys.exit(1)')
    assert not er(sys.executable, '-c', 'import sys; sys.exit(-1)')
    assert not er(sys.executable, '-c', 'import sys; sys.exit(2)')
示例#7
0
文件: setup.py 项目: alefnula/tea
def setup(module, target="zip", output_path=None, data_dir=None):
    dist = os.path.abspath("dist")
    try:
        if target == "zip":
            assert er(
                "setup.py",
                "install",
                "--no-compile",
                "--install-lib",
                os.path.join(dist, "lib"),
                "--install-scripts",
                os.path.join(dist),
                *(
                    ["--install-data", os.path.join(dist, data_dir)]
                    if data_dir is not None
                    else []
                ),
            )
            with shell.goto(dist) as ok:
                assert ok
                assert compress.mkzip(
                    "%s.zip" % module, glob.glob(os.path.join("lib", "*"))
                )
                assert shell.remove("lib")
        elif target == "exe":
            assert er(
                "setup.py",
                "install",
                "--no-compile",
                "--install-lib",
                os.path.join(dist, "lib", "python"),
                "--install-scripts",
                os.path.join(dist, "scripts"),
                *(
                    ["--install-data", os.path.join(dist, data_dir)]
                    if data_dir is not None
                    else []
                ),
            )
            with shell.goto(dist) as ok:
                assert ok

                modules = list(
                    filter(
                        os.path.exists,
                        ["lib", "scripts"]
                        + ([data_dir] if data_dir is not None else []),
                    )
                )
                assert compress.seven_zip(
                    "%s.exe" % module, modules, self_extracting=True
                )
                # Cleanup
                for module in modules:
                    assert shell.remove(module)
        if output_path is not None:
            output_path = os.path.abspath(output_path)
            if output_path != dist:
                if not os.path.isdir(output_path):
                    assert shell.mkdir(output_path)
                for filename in shell.search(dist, "*"):
                    output = os.path.join(
                        output_path, filename.replace(dist, "", 1).strip("\\/")
                    )
                    assert shell.move(filename, output)
        return 0
    except AssertionError as e:
        print(e)
        return 1
    finally:
        # Cleanup
        if output_path != dist:
            shell.remove(dist)
        if os.path.isdir("build"):
            shell.remove("build")
示例#8
0
文件: compress.py 项目: SenadI/tea
def seven_unzip(archive, output):
    """Extract a 7z archive"""
    return er(_get_sz(), 'x', archive, '-o%s' % output, '-aoa')
示例#9
0
文件: compress.py 项目: delicb/tea
def seven_unzip(archive, output):
    """Extract a 7z archive"""
    return er(_get_sz(), 'x', archive, '-o%s' % output, '-aoa')
示例#10
0
文件: compress.py 项目: alefnula/tea
def seven_unzip(archive, output):
    """Extract a 7z archive."""
    return er(_get_sz(), "x", archive, "-o%s" % output, "-aoa")