How to use the fbs.path function in fbs

To help you get started, we’ve selected a few fbs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
def _has_windows_codesigning_certificate():
    assert is_windows()
    from fbs.sign.windows import _CERTIFICATE_PATH
    return exists(path(_CERTIFICATE_PATH))
github mherrmann / fbs / fbs / builtin_commands / _docker.py View on Github external
def buildvm(name):
    """
    Build a Linux VM. Eg.: buildvm ubuntu
    """
    require_existing_project()
    build_dir = path('target/%s-docker-image' % name)
    if exists(build_dir):
        rmtree(build_dir)
    src_root = 'src/build/docker'
    available_vms = set(listdir(default_path(src_root)))
    if exists(path(src_root)):
        available_vms.update(listdir(path(src_root)))
    if name not in available_vms:
        raise FbsError(
            'Could not find %s. Available VMs are:%s' %
            (name, ''.join(['\n * ' + vm for vm in available_vms]))
        )
    src_dir = src_root + '/' + name
    for path_fn in default_path, path:
        _copy(path_fn, src_dir, build_dir)
    settings = SETTINGS['docker_images'].get(name, {})
    for path_fn in default_path, path:
github mherrmann / fbs / fbs / installer / mac / __init__.py View on Github external
def create_installer_mac():
    app_name = SETTINGS['app_name']
    dest = path('target/${installer}')
    dest_existed = exists(dest)
    if dest_existed:
        dest_bu = dest + '.bu'
        replace(dest, dest_bu)
    try:
        check_call([
            join(dirname(__file__), 'create-dmg', 'create-dmg'),
            '--volname', app_name,
            '--app-drop-link', '170', '10',
            '--icon', app_name + '.app', '0', '10',
            dest,
            path('${freeze_dir}')
        ], stdout=DEVNULL)
    except:
        if dest_existed:
            replace(dest_bu, dest)
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
def clean():
    """
    Remove previous build outputs
    """
    try:
        rmtree(path('target'))
    except FileNotFoundError:
        return
    except OSError:
        # In a docker container, target/ may be mounted so we can't delete it.
        # Delete its contents instead:
        for f in listdir(path('target')):
            fpath = join(path('target'), f)
            if isdir(fpath):
                rmtree(fpath, ignore_errors=True)
            elif isfile(fpath):
                remove(fpath)
            elif islink(fpath):
                unlink(fpath)
github mherrmann / fbs / fbs / builtin_commands / _gpg / __init__.py View on Github external
key = _snip(
        result.stdout,
        "revocation certificate stored as '/root/.gnupg/openpgp-revocs.d/",
        ".rev'",
        include_bounds=False
    )
    pubkey = _snip(result.stdout,
                   '-----BEGIN PGP PUBLIC KEY BLOCK-----\n',
                   '-----END PGP PUBLIC KEY BLOCK-----\n')
    privkey = _snip(result.stdout,
                    '-----BEGIN PGP PRIVATE KEY BLOCK-----\n',
                    '-----END PGP PRIVATE KEY BLOCK-----\n')
    makedirs(path(_DEST_DIR), exist_ok=True)
    pubkey_dest = _DEST_DIR + '/' + _PUBKEY_NAME
    Path(path(pubkey_dest)).write_text(pubkey)
    Path(path(_DEST_DIR + '/' + _PRIVKEY_NAME)).write_text(privkey)
    update_json(path(BASE_JSON), {'gpg_key': key, 'gpg_name': name})
    update_json(path(SECRET_JSON), {'gpg_pass': passphrase})
    _LOG.info(
        'Done. Created %s and ...%s. Also updated %s and ...secret.json with '
        'the values you provided.', pubkey_dest, _PRIVKEY_NAME, BASE_JSON
    )
github mherrmann / fbs / fbs / freeze / mac.py View on Github external
def freeze_mac(debug=False):
    if not exists(path('target/Icon.icns')):
        _generate_iconset()
        run(['iconutil', '-c', 'icns', path('target/Icon.iconset')], check=True)
    args = []
    if not (debug or SETTINGS['show_console_window']):
        args.append('--windowed')
    args.extend(['--icon', path('target/Icon.icns')])
    bundle_identifier = SETTINGS['mac_bundle_identifier']
    if bundle_identifier:
        args.extend([
            '--osx-bundle-identifier', bundle_identifier
        ])
    run_pyinstaller(args, debug)
    _remove_unwanted_pyinstaller_files()
    _fix_sparkle_delta_updates()
    _generate_resources()
github mherrmann / fbs / fbs / installer / linux.py View on Github external
def generate_installer_files():
    if exists(path('target/installer')):
        rmtree(path('target/installer'))
    copytree(path('${freeze_dir}'), path('target/installer/opt/${app_name}'))
    _generate_installer_resources()
    # Special handling of the .desktop file: Replace AppName by actual name.
    apps_dir = path('target/installer/usr/share/applications')
    rename(
        join(apps_dir, 'AppName.desktop'),
        join(apps_dir, SETTINGS['app_name'] + '.desktop')
    )
    _generate_icons()
github mherrmann / fbs / fbs / builtin_commands / __init__.py View on Github external
def run():
    """
    Run your app from source
    """
    require_existing_project()
    if not _has_module('PyQt5') and not _has_module('PySide2'):
        raise FbsError(
            "Couldn't find PyQt5 or PySide2. Maybe you need to:\n"
            "    pip install PyQt5==5.9.2 or\n"
            "    pip install PySide2==5.12.2"
        )
    env = dict(os.environ)
    pythonpath = path('src/main/python')
    old_pythonpath = env.get('PYTHONPATH', '')
    if old_pythonpath:
        pythonpath += os.pathsep + old_pythonpath
    env['PYTHONPATH'] = pythonpath
    subprocess.run([sys.executable, path(SETTINGS['main_module'])], env=env)
github mherrmann / fbs / fbs / freeze / windows.py View on Github external
def _restore_corrupted_python_dlls():
    # PyInstaller <= 3.4 somehow corrupts python3*.dll - see:
    # https://github.com/pyinstaller/pyinstaller/issues/2526
    # Restore the uncorrupted original:
    python_dlls = (
        'python%s.dll' % sys.version_info.major,
        'python%s%s.dll' % (sys.version_info.major, sys.version_info.minor)
    )
    for dll_name in python_dlls:
        try:
            remove(path('${freeze_dir}/' + dll_name))
        except FileNotFoundError:
            pass
        else:
            copy(_find_on_path(dll_name), path('${freeze_dir}'))