Ejemplo n.º 1
0
def main(config_path: str, no_roots: bool = False, verbose: bool = False):
    _require_root()

    if os.path.isdir(config_path):
        setup_filename = os.path.join(config_path, 'setup.yaml')
    else:
        setup_filename = config_path

    if not os.path.isfile(setup_filename):
        raise click.ClickException(
            'The file {} does not exist.'.format(setup_filename))
    if not setup_filename[setup_filename.rfind('.') + 1:] in ('yaml', 'yml'):
        raise click.ClickException(
            'The file {} has an unsupported extension. '
            'Supported extensions are *.yaml and *.yml.'.format(
                setup_filename))

    config_dir = os.path.dirname(setup_filename)

    if no_roots and random.SystemRandom().randrange(0, 100) == 42:
        print('🎶 https://youtu.be/PUdyuKaGQd4 🎶'
              )  # *Totally no easter 🥚*

    log.success('🚀 Performing your setup.', bold=True)

    setup = config.Setup(config_dir)
    setup.load_plugins()
    setup.load_config_file(setup_filename)

    setup.perform(indent=not (no_roots or verbose), verbose=verbose)

    log.success('✓ Setup completed.', bold=True)
Ejemplo n.º 2
0
def test_real():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    assert os.path.isfile('/tmp/ubup-download-v0.1.0')
    assert os.path.isfile('/tmp/ubup-download-latest')
Ejemplo n.º 3
0
def test_real():
    with tempfile.TemporaryDirectory() as tempdir:
        setup = config.Setup(tempdir)
        setup.load_plugins()
        setup.load_config_str(_REAL_CONFIG)
        setup.perform()
        assert os.listdir(tempdir) == ['test.txt']
Ejemplo n.º 4
0
def test_real():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    output = subprocess.check_output(
        ['bash', '-c', 'flatpak remotes | grep flathub']).decode('utf-8')
    assert output.find('flathub') != -1
Ejemplo n.º 5
0
def test_real():
    with tempfile.TemporaryDirectory() as tempdir:
        setup = config.Setup(tempdir)
        setup.load_plugins()
        setup.load_config_str(_REAL_CONFIG)
        setup.perform()
        assert os.path.isdir(os.path.join(tempdir, 'test/a/b/c/d'))
        assert os.path.isdir(os.path.join(tempdir, 'test/foo'))
        assert os.path.isdir(os.path.join(tempdir, 'bar'))
Ejemplo n.º 6
0
def test_real():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    output = subprocess.check_output(
        ['bash', '-c',
         'flatpak list | grep org.freedesktop.Platform']).decode('utf-8')
    assert output.find('org.freedesktop.Platform') != -1
Ejemplo n.º 7
0
def test_real():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    check_command = [
        'bash', '-c', 'dpkg --get-selections | grep -v deinstall | grep cowsay'
    ]
    output = subprocess.check_output(check_command).decode('utf-8')
    assert output.find('cowsay') != -1
Ejemplo n.º 8
0
def test_real():
    with tempfile.TemporaryDirectory() as tempdir:
        with open(os.path.join(tempdir, 'test01.sh'), 'w') as file:
            file.write('#!/bin/bash\ntouch result01.txt')
        with open(os.path.join(tempdir, 'test02.sh'), 'w') as file:
            file.write('#!/bin/bash\ntouch result02.txt')

        setup = config.Setup(tempdir)
        setup.load_plugins()
        setup.load_config_str(_REAL_CONFIG)
        setup.perform()
        assert set(os.listdir(tempdir)) == {
            'test01.sh', 'test02.sh', 'result01.txt', 'result02.txt'
        }
Ejemplo n.º 9
0
def test_real():
    setup = config.Setup(data_path=ASSETS_PATH)
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    check_command = ['bash', '-c', 'snap list | grep hello-world']
    output = subprocess.check_output(check_command).decode('utf-8')
    assert output.find('hello-world') != -1
    check_command = ['bash', '-c', 'snap list | grep snapcraft']
    output = subprocess.check_output(check_command).decode('utf-8')
    assert output.find('snapcraft') != -1
    check_command = ['bash', '-c', 'snap list | grep hello-world-cli']
    output = subprocess.check_output(check_command).decode('utf-8')
    assert output.find('hello-world-cli') != -1
Ejemplo n.º 10
0
def test_real():
    test_files = ('abc.txt', 'foo.txt', 'bar.txt', 'holy.xyz', 'moly')
    with tempfile.TemporaryDirectory() as tempdir:
        for filename in test_files:
            os.mknod(os.path.join(tempdir, filename))
        target1_dir = os.path.join(tempdir, 'target1')
        os.mkdir(target1_dir)
        target2_dir = os.path.join(tempdir, 'target2')
        os.mkdir(target2_dir)
        setup = config.Setup(tempdir)
        setup.load_plugins()
        setup.load_config_str(_REAL_CONFIG)
        setup.perform()
        assert set(
            os.listdir(target1_dir)) == {'abc.txt', 'foo.txt', 'bar.txt'}
        assert set(os.listdir(target2_dir)) == {
            'moly',
        }
Ejemplo n.º 11
0
def test_real():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_REAL_CONFIG)
    setup.perform()
    assert PPAsHelper().is_ppa_installed('alexlarsson/flatpak')
Ejemplo n.º 12
0
def test_mock():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_MOCK_CONFIG)
Ejemplo n.º 13
0
def test_load_advanced_config():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_ADVANCED_CONFIG)
Ejemplo n.º 14
0
def test_load_simple_config():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_SIMPLE_CONFIG)
Ejemplo n.º 15
0
def test_load_minimalistic_config():
    setup = config.Setup()
    setup.load_plugins()
    setup.load_config_str(_MINIMALISTIC_CONFIG)