Esempio n. 1
0
def move_installer(cfg: configparser.ConfigParser):
    installer_file = f"{cfg.get('Application', 'name')}_{cfg.get('Application', 'version')}.exe"
    installer_dir = os.path.join(get_current_modules_dir(), 'build', 'nsis')
    dist_dir = os.path.join(get_current_modules_dir(), 'dist')

    try:
        if not os.path.exists(dist_dir):
            os.mkdir(dist_dir)
            print('Created dist directory:', dist_dir)
    except Exception as e:
        print('Could not create dist directory:', e)
        return

    # Move installer
    try:
        dist_file = os.path.join(dist_dir, installer_file)

        if os.path.exists(dist_file):
            os.remove(dist_file)

        shutil.move(os.path.join(installer_dir, installer_file), dist_file)
        print('Moved installer file to:', dist_file)
    except Exception as e:
        print('Could not move installer file:', e)
        return

    rem_build_dir()
Esempio n. 2
0
def main():
    rem_build_dir()

    # Pip wheel config Pipfile
    pip_lock_file = os.path.join(get_current_modules_dir(), 'Pipfile.lock')

    # Temporary config file to create during build process
    build_cfg = os.path.join(get_current_modules_dir(),
                             'pfad_aeffchen_build.cfg')

    if not os.path.exists(CFG_FILE) or not os.path.exists(pip_lock_file):
        print('Pip or nsis cfg file not found ', CFG_FILE, pip_lock_file)
        return

    cfg = configparser.ConfigParser(allow_no_value=True)

    with open(CFG_FILE, 'r') as f:
        cfg.read_file(f)

    with open(pip_lock_file, 'r') as f:
        pip = json.load(f)

    update_nsis_pypi_wheels(cfg, pip)

    with open(build_cfg, 'w') as f:
        cfg.write(f)

    print('Written updated Nsis build configuration to:', build_cfg)

    args = ['pynsist', build_cfg]
    p = Popen(args=args)
    p.wait()

    if p.returncode != 0:
        print('PyNsist could not build installer!')
        return

    move_installer(cfg)

    # Rename and move temporary build cfg
    try:
        build_cfg_dist = os.path.join(
            get_current_modules_dir(), 'dist',
            f"build_cfg_{cfg.get('Application', 'version')}.cfg")

        if os.path.exists(build_cfg_dist):
            os.remove(build_cfg_dist)

        shutil.move(build_cfg, build_cfg_dist)
    except Exception as e:
        print('Could not move temporary Nsis build configuration:', e)
Esempio n. 3
0
def main():
    start_time = time.time()
    output_dir = Path(r'D:\temp\crypto_test')
    scene = Path(
        r'z:\__Audi\__Konfigurator\__A5_Familie\XXXXX_RS5_PA_NeMo\C_3D-Daten\AU49X_A5PA_2020_04_ND_F_01_20190910_POLY\AU49X_A5PA_2020_04_ND_F_01_20190910_POLY.csb'
    )
    mod_dir = get_current_modules_dir()
    psd_creation_module = Path(mod_dir) / 'maya_mod/run_create_psd.py'
    psd_file = output_dir / f'{scene.stem}.psd'
    c = CreateCryptomattes(output_dir, scene, logger=LOGGER)
    c.create_cryptomattes()

    try:
        process = run_module_in_standalone(
            psd_creation_module.as_posix(),  # Path to module to run
            psd_file.as_posix(),
            output_dir.as_posix(),
            'iff',  # Args
            Path(mod_dir).as_posix()  # Environment dir
        )
        process.wait()
    except Exception as e:
        LOGGER.error(e)

    LOGGER.info(f'Finished in {time.time() - start_time:.4f}s')
Esempio n. 4
0
def main():
    # Setup log
    setup_aeffchen_log()

    # Prepare a multiprocess logging queue
    logging_queue = Queue(-1)

    # This will move all handlers from LOGGER to the queue listener
    log_listener = setup_log_queue_listener(LOGGER, logging_queue)
    # Start log queue listener in it's own thread
    log_listener.start()

    mod_dir = get_current_modules_dir()
    LOGGER.info('Modules directory: %s', mod_dir)

    # Set version file if we are in Dev environment
    set_version(mod_dir)

    # Get version info
    version = read_version(mod_dir)
    LOGGER.debug('Running version: %s', version)

    app = PfadAeffchenApp(mod_dir, version, LOGGER, logging_queue,
                          log_listener)
    result = app.exec_()
    LOGGER.debug('---------------------------------------')
    LOGGER.debug('Qt application finished with exitcode %s', result)

    log_listener.stop()
    logging.shutdown()
    sys.exit()
Esempio n. 5
0
def rem_build_dir():
    build_dir = os.path.join(get_current_modules_dir(), 'build')

    if not os.path.exists(build_dir):
        return

    try:
        shutil.rmtree(build_dir)
        print('Removed build directory:', build_dir)
    except Exception as e:
        print('Could not remove build directory:', e)
Esempio n. 6
0
def get_translation():
    # get one of supported languages
    os.environ.setdefault('LANGUAGE', get_ms_windows_language())

    locale_dir = os.path.join(get_current_modules_dir(), 'locale')
    return translation('pfad_aeffchen', localedir=locale_dir)
Esempio n. 7
0
import configparser
import json
import os
import shutil
from subprocess import Popen

from modules.setup_paths import get_current_modules_dir

# Nsis Config file to read wheels from
# needs to be manually updated if new packages required!
CFG_FILE = os.path.join(get_current_modules_dir(), 'nsi', 'pfad_aeffchen.cfg')


def update_nsis_pypi_wheels(cfg: configparser.ConfigParser, pip: dict):
    str_wheels: str = cfg.get('Include', 'pypi_wheels')
    str_wheels: list = str_wheels.split('\n')
    cfg_wheels = dict()

    print('Nsis wheels:', str_wheels)
    print('Pip wheels: ',
          [f'{n}{v.get("version")}' for n, v in pip['default'].items()])

    # Compare Nsis and Pip wheel versions and update cfg_wheels dict with pip versions
    for wheel in str_wheels:
        wheel_name, wheel_version = wheel.split('==')
        cfg_wheels[wheel_name] = wheel_version

        if wheel_name.casefold() in pip['default']:
            pip_version = pip['default'][wheel_name.casefold()].get(
                'version')  # Get the pip version
            if pip_version is None or pip_version == '*':