예제 #1
0
파일: script.py 프로젝트: kidasse/pyRevit
    def savesettings(self, sender, args):
        if self.verbose_rb.IsChecked:
            logger.set_verbose_mode()
        if self.debug_rb.IsChecked:
            logger.set_debug_mode()

        user_config.core.checkupdates = self.checkupdates_cb.IsChecked
        user_config.core.verbose = self.verbose_rb.IsChecked
        user_config.core.debug = self.debug_rb.IsChecked
        user_config.core.filelogging = self.filelogging_cb.IsChecked
        user_config.core.bincache = self.bincache_rb.IsChecked
        user_config.core.compilecsharp = self.compilecsharp_cb.IsChecked
        user_config.core.compilevb = self.compilevb_cb.IsChecked
        user_config.core.loadbeta = self.loadbetatools_cb.IsChecked

        if isinstance(self.extfolders_lb.ItemsSource, list):
            user_config.core.userextensions = filter_null_items(
                self.extfolders_lb.ItemsSource)
        else:
            user_config.core.userextensions = []

        user_config.save_changes()

        self.update_addinfiles()
        self.Close()
예제 #2
0
    def remove_pkg_config(self):
        """
        Removes the installed extension configuration.
        """

        user_config.remove_section(self.ext_dirname)
        user_config.save_changes()
예제 #3
0
파일: script.py 프로젝트: ShaperGZ/pyRevit
    def savesettings(self, sender, args):
        """Callback method for saving pyRevit settings
        """

        # update the logging system changes first and update.
        if self.verbose_rb.IsChecked:
            logger.set_verbose_mode()
        if self.debug_rb.IsChecked:
            logger.set_debug_mode()

        # set config values to values set in ui items
        user_config.core.checkupdates = self.checkupdates_cb.IsChecked
        user_config.core.verbose = self.verbose_rb.IsChecked
        user_config.core.debug = self.debug_rb.IsChecked
        user_config.core.filelogging = self.filelogging_cb.IsChecked
        user_config.core.bincache = self.bincache_rb.IsChecked
        user_config.core.compilecsharp = self.compilecsharp_cb.IsChecked
        user_config.core.compilevb = self.compilevb_cb.IsChecked
        user_config.core.requiredhostbuild = self.requiredhostbuild_tb.Text

        try:
            min_freespace = int(self.minhostdrivefreespace_tb.Text)
            user_config.core.minhostdrivefreespace = min_freespace
        except ValueError:
            logger.error('Minimum free space value must be an integer.')
            user_config.core.minhostdrivefreespace = 0

        user_config.core.loadbeta = self.loadbetatools_cb.IsChecked
        user_config.core.startuplogtimeout = self.startup_log_timeout.Text
        user_config.core.rocketmode = self.rocketmode_cb.IsChecked

        # set extension folders from the list, after cleanup empty items
        if isinstance(self.extfolders_lb.ItemsSource, list):
            user_config.core.userextensions = \
                coreutils.filter_null_items(self.extfolders_lb.ItemsSource)
        else:
            user_config.core.userextensions = []

        # set usage logging configs
        user_config.usagelogging.active = self.usagelogging_cb.IsChecked
        user_config.usagelogging.logfilepath = self.usagelogfile_tb.Text
        user_config.usagelogging.logserverurl = self.usagelogserver_tb.Text

        # output settings
        output.set_stylesheet(self.cur_stylesheet_tb.Text)
        if self.cur_stylesheet_tb.Text != output.get_default_stylesheet():
            user_config.core.outputstylesheet = self.cur_stylesheet_tb.Text
        else:
            user_config.core.remove_option('outputstylesheet')

        # save all new values into config file
        user_config.save_changes()

        # set dynamo compatibility mode
        addinfiles.set_dynamocompat(self.dynamocompatmode_cb.IsChecked)
        # update usage logging and addin files
        self.update_usagelogging()
        self.update_addinfiles()
        self.Close()
예제 #4
0
def save_config():
    """Save pyRevit config.

    Scripts should call this to save any changes they have done to their
    config section object received from script.get_config() method.
    """
    from pyrevit.userconfig import user_config
    user_config.save_changes()
예제 #5
0
    def toggle_package(self):
        """
        Disables/Enables package in pyRevit configuration so it won't be loaded
        in the next session.
        """

        self.config.disabled = not self.config.disabled
        user_config.save_changes()
예제 #6
0
def _filelogging_config_upgrade():
    """ Upgrades local files and settings per this commit changes.
    commit message:   Added file handler to logger
    commit hash:      d5c1cb548bfc08530d9f8b6ba9899e8f46f1d631
    """

    try:
        assert user_config.core.filelogging
    except:
        user_config.core.filelogging = False
        user_config.save_changes()
예제 #7
0
def _loadbeta_config_upgrade():
    """ Upgrades local files and settings per this commit changes.
    commit message:   Added support for __beta__ Issue# 155
    commit hash:      d1237aa50a430f86a9362af5c2471c16254fd20e
    """

    try:
        assert user_config.core.loadbeta
    except:
        user_config.core.loadbeta = False
        user_config.save_changes()
예제 #8
0
 def save_pkg_settings(self, sender, args):
     try:
         self.selected_pkg.ext_pkg.config.private_repo = self.privaterepo_cb.IsChecked
         self.selected_pkg.ext_pkg.config.username = self.repousername_tb.Text
         self.selected_pkg.ext_pkg.config.password = self.repopassword_tb.Text
         user_config.save_changes()
         self.Close()
     except Exception as pkg_sett_save_err:
         logger.error(
             'Error saving extension package settings. | {}'.format(
                 pkg_sett_save_err))
예제 #9
0
def reset_config():
    """Reset pyRevit config.

    Script should call this to reset any saved configuration by removing section related to current script
    """
    from pyrevit.userconfig import user_config
    script_cfg_postfix = 'config'

    user_config.remove_section(EXEC_PARAMS.command_name +
                                   script_cfg_postfix)
    user_config.save_changes()
예제 #10
0
def _startuplogtimeout_config_upgrade():
    """ Upgrades local files and settings per this commit changes.
    commit message:   Updated settings window to allow adjusting the startup window timeout
    commit hash:      75ffba6d19e98862a28d5d180345c124df696246
    """

    try:
        assert user_config.core.startuplogtimeout
    except:
        user_config.core.startuplogtimeout = 0
        user_config.save_changes()
예제 #11
0
파일: script.py 프로젝트: voyansi/pyRevit
    def save_pkg_settings(self, sender, args):
        """Reads package configuration from UI and saves to package config
        """

        try:
            self.selected_pkg.ext_pkg.config.private_repo = \
                self.privaterepo_cb.IsChecked
            self.selected_pkg.ext_pkg.config.username = \
                self.repousername_tb.Text
            self.selected_pkg.ext_pkg.config.password = \
                self.repopassword_pb.Password
            user_config.save_changes()
            self.Close()
        except Exception as pkg_sett_save_err:
            logger.error('Error saving extension package settings.'
                         ' | {}'.format(pkg_sett_save_err))
예제 #12
0
    def config(self):
        """
        Returns a valid config manager for this extension. All config parameters will be saved in user config file.

        Returns:
            pyrevit.coreutils.configparser.PyRevitConfigSectionParser: Config section handler
        """

        try:
            return user_config.get_section(self.ext_dirname)
        except:
            cfg_section = user_config.add_section(self.ext_dirname)
            self.config.disabled = not self._enable_default
            self.config.private_repo = self.builtin
            self.config.username = self.config.password = ''
            user_config.save_changes()
            return cfg_section
예제 #13
0
파일: script.py 프로젝트: tatlin/pyRevit
    def save_settings(self, sender, args):
        """Callback method for saving pyRevit settings"""
        self.reload_requested = \
            self._save_core_options() or self.reload_requested
        self.reload_requested = \
            self._save_engines() or self.reload_requested
        self.reload_requested = \
            self._save_user_extensions_list() or self.reload_requested
        self.reload_requested = \
            self._save_uiux() or self.reload_requested
        self.reload_requested = \
            self._save_telemetry() or self.reload_requested

        # save all new values into config file
        user_config.save_changes()

        # update addin files
        self.update_addinfiles()
        self.Close()
        # if reload requested by any of the save methods, then reload
        if self.reload_requested:
            self._reload()
예제 #14
0
def reset_config(section=None):
    """Reset pyRevit config.

    Script should call this to reset any save configuration by removing
    section related to current script.

    Args:
        section (str, optional): config section name
    """
    from pyrevit.userconfig import user_config
    if not section:
        script_cfg_postfix = 'config'
        section = EXEC_PARAMS.command_name + script_cfg_postfix
    elif section in [TargetApps.Revit.PyRevitConsts.ConfigsCoreSection]:
        raise PyRevitException(
            'Can not remove internal config section: {}'.format(section))

    try:
        user_config.remove_section(section)
        user_config.save_changes()
    except Exception:
        mlogger.debug('Failed resetting config for %s (%s)',
                      EXEC_PARAMS.command_name, section)
예제 #15
0
folder and also pyrevit.plugins.extpackages to check whether an extension is active or not.
"""

from pyrevit import PyRevitException, EXEC_PARAMS
from pyrevit.coreutils.logger import get_logger
from pyrevit.userconfig import user_config

if not EXEC_PARAMS.doc_mode:
    try:
        if user_config.core.bincache:
            from pyrevit.extensions.cacher_bin import is_cache_valid, get_cached_extension, update_cache
        else:
            from pyrevit.extensions.cacher_asc import is_cache_valid, get_cached_extension, update_cache
    except AttributeError:
        user_config.core.bincache = True
        user_config.save_changes()
        from pyrevit.extensions.cacher_bin import is_cache_valid, get_cached_extension, update_cache

from pyrevit.extensions.parser import parse_dir_for_ext_type, get_parsed_extension, parse_comp_dir
from pyrevit.extensions.genericcomps import GenericUICommand
from pyrevit.extensions.components import Extension, LibraryExtension

from pyrevit.plugins.extpackages import is_ext_package_enabled

logger = get_logger(__name__)


def _update_extension_syspaths(ui_ext, lib_ext_list):
    for lib_ext in lib_ext_list:
        ui_ext.add_syspath(lib_ext.directory)
예제 #16
0
def setup_telemetry(session_id=None):
    """Sets up the telemetry default config and environment values."""

    # make sure session id is availabe
    if not session_id:
        session_id = sessioninfo.get_session_uuid()

    # PYREVIT TELEMETRY -------------------------------------------------------
    # utc timestamp
    telemetry_utc_timestamp = user_config.telemetry_utc_timestamp
    set_telemetry_utc_timestamp(telemetry_utc_timestamp)

    # global telemetry toggle
    telemetry_state = user_config.telemetry_status
    set_telemetry_state(telemetry_state)

    # read or setup default values for file telemetry
    # default file path and name for telemetry
    telemetry_file_dir = user_config.telemetry_file_dir
    set_telemetry_file_dir(telemetry_file_dir)

    # check file telemetry config and setup destination
    if not telemetry_file_dir or coreutils.is_blank(telemetry_file_dir):
        # if no config is provided, disable output
        disable_telemetry_to_file()
    # if config exists, create new telemetry file under the same address
    elif telemetry_state:
        if op.isdir(telemetry_file_dir):
            telemetry_file_name = \
                FILE_LOG_FILENAME_TEMPLATE.format(PYREVIT_FILE_PREFIX,
                                                  session_id,
                                                  FILE_LOG_EXT)
            # if directory is valid
            telemetry_fullfilepath = \
                op.join(telemetry_file_dir, telemetry_file_name)
            set_telemetry_file_path(telemetry_fullfilepath)
            # setup telemetry file or disable if failed
            try:
                _setup_default_logfile(telemetry_fullfilepath)
            except Exception as write_err:
                mlogger.error(
                    'Telemetry is active but log file location '
                    'is not accessible. | %s', write_err)
                disable_telemetry_to_file()
        else:
            # if not, show error and disable telemetry
            mlogger.error('Provided telemetry address does not exits or is '
                          'not a directory. Telemetry disabled.')
            disable_telemetry_to_file()

    # read or setup default values for server telemetry
    telemetry_server_url = user_config.telemetry_server_url

    # check server telemetry config and setup destination
    if not telemetry_server_url or coreutils.is_blank(telemetry_server_url):
        # if no config is provided, disable output
        disable_telemetry_to_server()
    else:
        # if config exists, setup server logging
        set_telemetry_server_url(telemetry_server_url)

    # set telemetry script types
    set_telemetry_include_hooks(user_config.telemetry_include_hooks)

    # APP TELEMETRY ------------------------------------------------------------
    # setup default value for telemetry global switch
    apptelemetry_state = user_config.apptelemetry_status
    set_apptelemetry_state(apptelemetry_state)

    # read or setup default values for server telemetry
    apptelemetry_server_url = user_config.apptelemetry_server_url

    # check server telemetry config and setup destination
    if not apptelemetry_server_url \
            or coreutils.is_blank(apptelemetry_server_url):
        # if no config is provided, disable output
        disable_apptelemetry_to_server()
    else:
        # if config exists, setup server logging
        set_apptelemetry_server_url(apptelemetry_server_url)

    # setup events
    new_telemetry_handler = EventTelemetry(session_id)
    telemetry_handler = get_apptelemetry_handler()
    if telemetry_handler:
        # clear existing
        telemetry_events.unregister_all_event_telemetries(telemetry_handler)

    set_apptelemetry_handler(new_telemetry_handler)
    # register handlers only if telemetry system is active
    if apptelemetry_state:
        apptelemetry_event_flags = get_apptelemetry_event_flags()
        # re-register events with new telemetry_handler
        telemetry_events.register_event_telemetry(new_telemetry_handler,
                                                  apptelemetry_event_flags)

    user_config.save_changes()
예제 #17
0
 def toggle_ext_pkg(self, sender, args):
     self.selected_pkg.ext_pkg.config.disabled = not self.selected_pkg.ext_pkg.config.disabled
     user_config.save_changes()
     self.Close()
     load_session()
예제 #18
0
 def save_config():
     from pyrevit.userconfig import user_config
     user_config.save_changes()