Example #1
0
def _perform_onsessionload_ops():
    # clear the cached engines
    if not _clear_running_engines():
        mlogger.debug('No Engine Manager exists...')

    # check for updates
    if user_config.core.get_option('autoupdate', default_value=False) \
            and not _check_autoupdate_inprogress():
        mlogger.info('Auto-update is active. Attempting update...')
        _set_autoupdate_inprogress(True)
        updater.update_pyrevit()
        _set_autoupdate_inprogress(False)

    # once pre-load is complete, report environment conditions
    uuid_str = sessioninfo.new_session_uuid()
    sessioninfo.report_env()

    # reset the list of assemblies loaded under pyRevit session
    sessioninfo.set_loaded_pyrevit_assemblies([])

    # asking usagelog module to setup the usage logging system
    # (active or not active)
    setup_usage_logfile(uuid_str)

    # apply Upgrades
    upgrade.upgrade_existing_pyrevit()
Example #2
0
def _perform_onsessionloadstart_ops():
    # clear the cached engines
    if not _clear_running_engines():
        mlogger.debug('No Engine Manager exists...')

    # check for updates
    if user_config.auto_update \
            and not _check_autoupdate_inprogress():
        mlogger.info('Auto-update is active. Attempting update...')
        _set_autoupdate_inprogress(True)
        updater.update_pyrevit()
        _set_autoupdate_inprogress(False)

    # once pre-load is complete, report environment conditions
    uuid_str = sessioninfo.new_session_uuid()
    sessioninfo.report_env()

    # reset the list of assemblies loaded under pyRevit session
    sessioninfo.set_loaded_pyrevit_assemblies([])

    # init executor
    runtime_types.ScriptExecutor.Initialize()

    # init routes
    routes.init()

    # asking telemetry module to setup the telemetry system
    # (active or not active)
    telemetry.setup_telemetry(uuid_str)

    # apply Upgrades
    upgrade.upgrade_existing_pyrevit()

    # setup hooks
    hooks.setup_hooks()
Example #3
0
def update_pyrevit():
    """Update pyrevit and its extension repositories."""
    if _check_connection():
        third_party_updated = False
        pyrevit_updated = False
        pyrevit_has_coreupdates = has_core_updates()
        thirdparty_repos = get_thirdparty_ext_repos()

        logger.debug('List of thirdparty repos to be updated: %s',
                     thirdparty_repos)

        # update third-party extensions first, one by one
        for repo_info in thirdparty_repos:
            logger.debug('Updating repo: %s', repo_info.directory)
            try:
                upped_repo_info = update_repo(repo_info)
                logger.info(':inbox_tray: Successfully updated: %s to %s',
                            upped_repo_info.name,
                            upped_repo_info.last_commit_hash[:7])
                third_party_updated = True
            except Exception:
                logger.info(
                    'Can not update repo: %s (Run in debug to see why)',
                    repo_info.name)

        # now update pyrevit repo and reload
        pyrevit_repo = versionmgr.get_pyrevit_repo()
        if pyrevit_repo:
            if not pyrevit_has_coreupdates:
                logger.debug('Updating pyrevit repo: %s',
                             pyrevit_repo.directory)
                try:
                    upped_pyrevit_repo_info = update_repo(pyrevit_repo)
                    logger.info(':inbox_tray: Successfully updated: %s to %s',
                                upped_pyrevit_repo_info.name,
                                upped_pyrevit_repo_info.last_commit_hash[:7])
                    pyrevit_updated = True
                except Exception as err:
                    logger.info(
                        'Can not update pyrevit repo '
                        '(Run in debug to see why) | %s', err)
                # perform upgrade tasks
                logger.info('Upgrading settings...')
                upgrade.upgrade_existing_pyrevit()
        if not pyrevit_has_coreupdates:
            if third_party_updated or pyrevit_updated:
                # now reload pyrevit
                from pyrevit.loader import sessionmgr
                sessionmgr.reload_pyrevit()
            else:
                logger.info('pyRevit and extensions seem to be up-to-date.')
        else:
            from pyrevit import script
            output = script.get_output()
            output.print_html(COREUPDATE_MESSAGE.format(home=HOME_DIR))
            logger.debug('Core updates. Skippin update and reload.')
    else:
        logger.warning('No internet access detected. Skipping update.')
Example #4
0
def _perform_onsessionload_ops():
    # the loader dll addon, does not create an output window
    # if an output window is not provided, create one
    if FIRST_LOAD:
        _setup_output_window()

    # once pre-load is complete, report environment conditions
    _report_env()

    # apply Upgrades
    upgrade_existing_pyrevit()
Example #5
0
def _perform_onsessionload_ops():
    # the loader dll addon, does not create an output window
    # if an output window is not provided, create one
    if FIRST_LOAD:
        _setup_output_window()

    # once pre-load is complete, report environment conditions
    uuid_str = sessioninfo.new_session_uuid()
    sessioninfo.report_env()

    # asking usagelog module to setup the usage logging system (active or not active)
    setup_usage_logfile(uuid_str)

    # apply Upgrades
    upgrade_existing_pyrevit()
Example #6
0
def _perform_onsessionload_ops():
    # clear the cached engines
    if not _clear_running_engines():
        logger.debug('No Engine Manager exists...')

    # once pre-load is complete, report environment conditions
    uuid_str = sessioninfo.new_session_uuid()
    sessioninfo.report_env()

    # reset the list of assemblies loaded under pyRevit session
    sessioninfo.set_loaded_pyrevit_assemblies([])

    # asking usagelog module to setup the usage logging system
    # (active or not active)
    setup_usage_logfile(uuid_str)

    # apply Upgrades
    upgrade_existing_pyrevit()
Example #7
0
if __name__ == '__main__':
    # collect a list of all repos to be updates
    if _check_connection():
        pyrevit_repo = updater.get_pyrevit_repo()
        thirdparty_repos = updater.get_thirdparty_ext_repos()

        logger.debug('List of thirdparty repos to be updated: {}'.format(
            thirdparty_repos))

        for thirdparty_repo_info in thirdparty_repos:
            _update_repo(thirdparty_repo_info)

        if not updater.has_core_updates():
            _update_repo(pyrevit_repo)
            # perform upgrade tasks
            logger.info('Upgrading settings...')
            upgrade.upgrade_existing_pyrevit()

            # Call pyRevit reload command to reload pyRevit
            # The reason to call the command instead of using sessionmgr module
            # to realod is that the repo has been just updatedm so all
            # modules need to be re-imported again in a clean engine.
            from pyrevit.loader.sessionmgr import execute_command
            execute_command(PYREVIT_CORE_RELOAD_COMMAND_NAME)
        else:
            output = script.get_output()
            output.print_html(COREUPDATE_MESSAGE.format(home=HOME_DIR))
            logger.debug('Core updates. Skippin update and reload.')
    else:
        logger.warning('No internet access detected. Skipping update.')