예제 #1
0
def release():
    """
    Bump version and run clean,freeze,...,upload
    """
    require_existing_project()
    version = SETTINGS['version']
    next_version = _get_next_version(version)
    release_version = prompt_for_value('Release version', default=next_version)
    activate_profile('release')
    SETTINGS['version'] = release_version
    log_level = _LOG.level
    if log_level == logging.NOTSET:
        _LOG.setLevel(logging.WARNING)
    try:
        clean()
        freeze()
        if is_windows() and _has_windows_codesigning_certificate():
            sign()
        installer()
        if (is_windows() and _has_windows_codesigning_certificate()) or \
            is_arch_linux() or is_fedora():
            sign_installer()
        repo()
    finally:
        _LOG.setLevel(log_level)
    upload()
    base_json = 'src/build/settings/base.json'
    update_json(path(base_json), {'version': release_version})
    _LOG.info('Also, %s was updated with the new version.', base_json)
예제 #2
0
def freeze(debug=False):
    """
    Compile your application to a standalone executable
    """
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X:
    if is_windows():
        from fbs.freeze.windows import freeze_windows
        freeze_windows(debug=debug)
    elif is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
    elif is_linux():
        if is_ubuntu():
            from fbs.freeze.ubuntu import freeze_ubuntu
            freeze_ubuntu(debug=debug)
        elif is_arch_linux():
            from fbs.freeze.arch import freeze_arch
            freeze_arch(debug=debug)
        elif is_fedora():
            from fbs.freeze.fedora import freeze_fedora
            freeze_fedora(debug=debug)
        else:
            from fbs.freeze.linux import freeze_linux
            freeze_linux(debug=debug)
    else:
        raise RuntimeError('Unsupported OS')
예제 #3
0
def freeze(debug=False):
    """
    Compile your application to a standalone executable
    """
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise RuntimeError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable)
예제 #4
0
def findConfigFilePath() -> str:
    """
    Looks for config file from default location.
    Diffrent behaviour per platform
    If found one -> returns path, otherwise
    returns None.

    If correct path found -> function caches the result

    Windows:
    1) AppData\\Local\\STManager
    2) \\User\\.stmanager

    Linux:
    1) /home/.config/STManager
    2) /home/.stmanager

    Other:
    Throws error
    """
    if ConfigPaths.CONFIG_FILE_PATH:
        return ConfigPaths.CONFIG_FILE_PATH

    p = pathlib.Path.home()

    if platform.is_windows():
        # look for config file in appData
        if os.path.exists(found := p.joinpath(
                "AppData",
                "Local",
                "STManager",
                ConfigPaths.CONFIG_FILE_FILENAME,
        )):
예제 #5
0
파일: __init__.py 프로젝트: mherrmann/fbs
def release(version=None):
    """
    Bump version and run clean,freeze,...,upload
    """
    require_existing_project()
    if version is None:
        curr_version = SETTINGS['version']
        next_version = _get_next_version(curr_version)
        release_version = prompt_for_value('Release version',
                                           default=next_version)
    elif version == 'current':
        release_version = SETTINGS['version']
    else:
        release_version = version
    if not is_valid_version(release_version):
        if not is_valid_version(version):
            raise FbsError(
                'The release version of your app is invalid. It should be '
                'three\nnumbers separated by dots, such as "1.2.3". '
                'You have: "%s".' % release_version)
    activate_profile('release')
    SETTINGS['version'] = release_version
    log_level = _LOG.level
    if log_level == logging.NOTSET:
        _LOG.setLevel(logging.WARNING)
    try:
        clean()
        freeze()
        if is_windows() and _has_windows_codesigning_certificate():
            sign()
        installer()
        if (is_windows() and _has_windows_codesigning_certificate()) or \
            is_arch_linux() or is_fedora():
            sign_installer()
        if _repo_is_supported():
            repo()
    finally:
        _LOG.setLevel(log_level)
    upload()
    base_json = 'src/build/settings/base.json'
    update_json(path(base_json), {'version': release_version})
    _LOG.info('Also, %s was updated with the new version.', base_json)
예제 #6
0
def installer():
    """
    Create an installer for your app
    """
    require_existing_project()
    if not exists(path('${freeze_dir}')):
        raise FbsError(
            'It seems your app has not yet been frozen. Please run:\n'
            '    fbs freeze')
    linux_distribution_not_supported_msg = \
        "Your Linux distribution is not supported, sorry. " \
        "You can run `fbs buildvm` followed by `fbs runvm` to start a Docker " \
        "VM of a supported distribution."
    try:
        installer_fname = SETTINGS['installer']
    except KeyError:
        if is_linux():
            raise FbsError(linux_distribution_not_supported_msg)
        raise
    out_file = join('target', installer_fname)
    msg_parts = ['Created %s.' % out_file]
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        app_name = SETTINGS['app_name']
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
            install_cmd = 'sudo dpkg -i ' + out_file
            remove_cmd = 'sudo dpkg --purge ' + app_name
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
            install_cmd = 'sudo pacman -U ' + out_file
            remove_cmd = 'sudo pacman -R ' + app_name
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
            install_cmd = 'sudo dnf install ' + out_file
            remove_cmd = 'sudo dnf remove ' + app_name
        else:
            raise FbsError(linux_distribution_not_supported_msg)
        msg_parts.append(
            'You can for instance install it via the following command:\n'
            '    %s\n'
            'This places it in /opt/%s. To uninstall it again, you can use:\n'
            '    %s' % (install_cmd, app_name, remove_cmd))
    else:
        raise FbsError('Unsupported OS')
    _LOG.info(' '.join(msg_parts))
예제 #7
0
 def test_freeze_installer(self):
     freeze()
     if is_mac():
         executable = path('${freeze_dir}/Contents/MacOS/${app_name}')
     elif is_windows():
         executable = path('${freeze_dir}/${app_name}.exe')
     else:
         executable = path('${freeze_dir}/${app_name}')
     self.assertTrue(exists(executable), executable + ' does not exist')
     installer()
     self.assertTrue(exists(path('target/${installer}')))
예제 #8
0
파일: __init__.py 프로젝트: hhy5277/fbs
def installer():
    """
    Create an installer for your app
    """
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    else:
        raise RuntimeError('Unsupported OS')
예제 #9
0
 def __init__(self):
     self._resource_locator = self._create_resource_locator()
     # Many Qt classes require a QApplication to have been instantiated.
     # Do this here, before everything else, to achieve this:
     self.app
     # We don't build as a console app on Windows, so no point in installing
     # the SIGINT handler:
     if not is_windows():
         self._signal_wakeup_handler = SignalWakeupHandler(self.app)
         self._signal_wakeup_handler.install()
     if self.app_icon:
         self.app.setWindowIcon(self.app_icon)
예제 #10
0
 def __init__(self):
     if self.excepthook:
         self.excepthook.install()
     # Many Qt classes require a QApplication to have been instantiated.
     # Do this here, before everything else, to achieve this:
     self.app
     # We don't build as a console app on Windows, so no point in installing
     # the SIGINT handler:
     if not is_windows():
         self._signal_wakeup_handler = \
             SignalWakeupHandler(self.app, self._qt_binding.QAbstractSocket)
         self._signal_wakeup_handler.install()
     if self.app_icon:
         self.app.setWindowIcon(self.app_icon)
예제 #11
0
파일: __init__.py 프로젝트: mherrmann/fbs
def sign():
    """
    Sign your app, so the user's OS trusts it
    """
    require_frozen_app()
    if is_windows():
        from fbs.sign.windows import sign_windows
        sign_windows()
        _LOG.info('Signed all binary files in %s and its subdirectories.',
                  relpath(path('${freeze_dir}'), path('.')))
    elif is_mac():
        _LOG.info('fbs does not yet implement `sign` on macOS.')
    else:
        _LOG.info('This platform does not support signing frozen apps.')
예제 #12
0
 def test_freeze_installer(self):
     freeze()
     if is_mac():
         executable = path('${freeze_dir}/Contents/MacOS/${app_name}')
     elif is_windows():
         executable = path('${freeze_dir}/${app_name}.exe')
     else:
         executable = path('${freeze_dir}/${app_name}')
     self.assertTrue(exists(executable), executable + ' does not exist')
     installer()
     self.assertTrue(exists(path('target/${installer}')))
     if is_linux():
         applications_dir = path('target/installer/usr/share/applications')
         self.assertEqual(['MyApp.desktop'], listdir(applications_dir))
         with open(join(applications_dir, 'MyApp.desktop')) as f:
             self.assertIn('MyApp', f.read())
예제 #13
0
파일: __init__.py 프로젝트: mherrmann/fbs
def freeze(debug=False):
    """
    Compile your code to a standalone executable
    """
    require_existing_project()
    if not _has_module('PyInstaller'):
        raise FbsError("Could not find PyInstaller. Maybe you need to:\n"
                       "    pip install PyInstaller==3.4")
    version = SETTINGS['version']
    if not is_valid_version(version):
        raise FbsError(
            'Invalid version detected in settings. It should be three\n'
            'numbers separated by dots, such as "1.2.3". You have:\n\t"%s".\n'
            'Usually, this can be fixed in src/build/settings/base.json.' %
            version)
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise FbsError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable)
예제 #14
0
def freeze(debug=False):
    """
    Compile your code to a standalone executable
    """
    require_existing_project()
    if not _has_module('PyInstaller'):
        raise FbsError(
            "Could not find PyInstaller. Maybe you need to:\n"
            "    pip install PyInstaller==3.4"
        )
    # Import respective functions late to avoid circular import
    # fbs <-> fbs.freeze.X.
    app_name = SETTINGS['app_name']
    if is_mac():
        from fbs.freeze.mac import freeze_mac
        freeze_mac(debug=debug)
        executable = 'target/%s.app/Contents/MacOS/%s' % (app_name, app_name)
    else:
        executable = join('target', app_name, app_name)
        if is_windows():
            from fbs.freeze.windows import freeze_windows
            freeze_windows(debug=debug)
            executable += '.exe'
        elif is_linux():
            if is_ubuntu():
                from fbs.freeze.ubuntu import freeze_ubuntu
                freeze_ubuntu(debug=debug)
            elif is_arch_linux():
                from fbs.freeze.arch import freeze_arch
                freeze_arch(debug=debug)
            elif is_fedora():
                from fbs.freeze.fedora import freeze_fedora
                freeze_fedora(debug=debug)
            else:
                from fbs.freeze.linux import freeze_linux
                freeze_linux(debug=debug)
        else:
            raise FbsError('Unsupported OS')
    _LOG.info(
        "Done. You can now run `%s`. If that doesn't work, see "
        "https://build-system.fman.io/troubleshooting.", executable
    )
예제 #15
0
def open_playlist(path_to_playlist):
    logger.info('open_playlist...')

    try:
        set_default_arrangements(path_to_playlist)
    except Exception as e:
        logger.error("open_playlist - Cannot set default arrangements: %s" %
                     str(e))

    try:
        if is_windows():
            path_to_propresenter = "C:\\Program Files (x86)\\Renewed Vision\\ProPresenter 6\\ProPresenter.exe"
            subprocess.Popen([path_to_propresenter, path_to_playlist],
                             creationflags=DETACHED_PROCESS)
        elif is_mac():
            path_to_propresenter = '/Applications/ProPresenter 6.app'
            subprocess.Popen(
                ['open', '-a', path_to_propresenter, path_to_playlist])
    except Exception as e:
        logger.error('open_playlist - Cannot open playlist: %s' % str(e))
예제 #16
0
def sign_installer():
    """
    Sign installer, so the user's OS trusts it
    """
    if is_mac():
        _LOG.info('fbs does not yet implement `sign_installer` on macOS.')
        return
    if is_ubuntu():
        _LOG.info('Ubuntu does not support signing installers.')
        return
    require_installer()
    if is_windows():
        from fbs.sign_installer.windows import sign_installer_windows
        sign_installer_windows()
    elif is_arch_linux():
        from fbs.sign_installer.arch import sign_installer_arch
        sign_installer_arch()
    elif is_fedora():
        from fbs.sign_installer.fedora import sign_installer_fedora
        sign_installer_fedora()
    _LOG.info('Signed %s.', join('target', SETTINGS['installer']))
예제 #17
0
파일: build.py 프로젝트: akiphumi/SDTest
def code_signing():
    app_name = AppInfo().app_name()
    path_cert = project_dir + 'src\\freeze\\base\\' + app_name + '.pfx'
    path_program_exe = project_dir + 'target\\' + app_name + '\\' + app_name + '.exe'
    path_program_installer = project_dir + 'target\\' + app_name + 'Setup.exe'
    code_signing_timestamp_url = "http://timestamp.comodoca.com/authenticode"

    # Code Signing for Windows executable
    if platform.is_windows():
        cert_password = prompt_for_value(
            'Password for your code signing certificate', default='')

        if exists(path_program_exe) and exists(path_cert):
            os.system('signtool sign /f "' + path_cert + '" ' + '/p ' +
                      cert_password + ' /t ' + code_signing_timestamp_url +
                      ' /d "' + app_name + '" ' + path_program_exe)

        if exists(path_program_installer) and exists(path_cert):
            os.system('signtool sign /f "' + path_cert + '" ' + '/p ' +
                      cert_password + ' /t ' + code_signing_timestamp_url +
                      ' /d "' + app_name + '" ' + path_program_installer)
예제 #18
0
def installer():
    """
    Create an installer for your app
    """
    require_existing_project()
    out_file = join('target', SETTINGS['installer'])
    msg_parts = ['Created %s.' % out_file]
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        app_name = SETTINGS['app_name']
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
            install_cmd = 'sudo dpkg -i ' + out_file
            remove_cmd = 'sudo dpkg --purge ' + app_name
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
            install_cmd = 'sudo pacman -U ' + out_file
            remove_cmd = 'sudo pacman -R ' + app_name
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
            install_cmd = 'sudo dnf install ' + out_file
            remove_cmd = 'sudo dnf remove ' + app_name
        else:
            raise FbsError('Unsupported Linux distribution')
        msg_parts.append(
            'You can for instance install it via the following command:\n'
            '    %s\n'
            'This places it in /opt/%s. To uninstall it again, you can use:\n'
            '    %s' % (install_cmd, app_name, remove_cmd))
    else:
        raise FbsError('Unsupported OS')
    _LOG.info(' '.join(msg_parts))
예제 #19
0
def installer():
    """
    Create an installer for your app
    """
    if is_windows():
        from fbs.installer.windows import create_installer_windows
        create_installer_windows()
    elif is_mac():
        from fbs.installer.mac import create_installer_mac
        create_installer_mac()
    elif is_linux():
        if is_ubuntu():
            from fbs.installer.ubuntu import create_installer_ubuntu
            create_installer_ubuntu()
        elif is_arch_linux():
            from fbs.installer.arch import create_installer_arch
            create_installer_arch()
        elif is_fedora():
            from fbs.installer.fedora import create_installer_fedora
            create_installer_fedora()
        else:
            raise RuntimeError('Unsupported Linux distribution')
    else:
        raise RuntimeError('Unsupported OS')
예제 #20
0
def _has_windows_codesigning_certificate():
    assert is_windows()
    from fbs.sign.windows import _CERTIFICATE_PATH
    return exists(path(_CERTIFICATE_PATH))
예제 #21
0
def createConfigFile() -> str:
    """
    Creates config file and returns its location.
    Expects that the config file does not exist
    """
    userDirPath = pathlib.Path.home()

    if platform.is_windows():
        defautlDataPath = userDirPath.joinpath("AppData", "Local")
    elif platform.is_linux():
        defautlDataPath = userDirPath.joinpath(".config")
    else:
        from utils.DialogCollection import errorOccured

        errorOccured("Platform is not known. App is not supported on your"
                     "platform")
        raise RuntimeError(
            "Platform is not known. App is not supported on your"
            "platform")

    if os.path.exists(defautlDataPath):
        # creating folder and empty config file
        defautlDataPath = defautlDataPath.joinpath("STManager")
        configPath = defautlDataPath
    else:
        # creating folder and empty config file
        altDataPath = userDirPath.joinpath(".stmanager")
        configPath = altDataPath

    try:
        os.mkdir(configPath)
    except FileExistsError:
        pass

    configPath = configPath.joinpath(ConfigPaths.CONFIG_FILE_FILENAME)

    try:
        from utils.DialogCollection import getFolderPath, askNewUser

        photoDirectory = getFolderPath()

        newLogin, newPassword = askNewUser()

        while newLogin is None or newPassword is None:
            newLogin, newPassword = askNewUser()

        newConfigFileContent = {
            "configuration": {
                "loggedUser": newLogin,
                "scanner_mode": False,
                "savePath": photoDirectory,
            },
            "userData": [{
                "username": newLogin,
                "password": newPassword,
                "created": time.strftime("%d-%m-%Y-%H_%M_%S"),
                "items": [],
            }],
        }

        with open(configPath, "w") as configFile:
            configFile.write(json.dumps(newConfigFileContent))
        return configPath
    except PermissionError:
        from utils.DialogCollection import errorOccured

        errorOccured("Cannot create config file!! Check the permissions "
                     "for the application")
        return None
예제 #22
0
from PyQt5 import QtWidgets
from PyQt5.QtCore import QEvent
from PyQt5.QtGui import QDragEnterEvent, QDropEvent, QIcon
from PyQt5.QtNetwork import QAbstractSocket
from PyQt5.QtWidgets import QMainWindow, QLineEdit, QApplication
from fbs_runtime.application_context import cached_property, _QtBinding
from fbs_runtime.application_context.PyQt5 import ApplicationContext
from fbs_runtime.platform import is_windows, is_mac

from gui.open_playlist import Ui_MainWindow
from set_default_arrangement import set_default_arrangements

DETACHED_PROCESS = 8

home = expanduser('~')
if is_windows():
    log_filepath = os.path.join(home, 'AppData\\Local\\open-pro6plx')
else:
    log_filepath = os.path.join(home, 'Library/Logs/open-pro6plx')
os.makedirs(log_filepath, exist_ok=True)
log_filename = os.path.join(log_filepath, 'debug.log')
logging.basicConfig(filename=log_filename, filemode='a', level=logging.INFO)

logger = logging.getLogger()


class MainWindow(QMainWindow):
    @staticmethod
    def browse_slot():
        file_name, _ = QtWidgets.QFileDialog().getOpenFileName(
            filter='*.pro6plx')