示例#1
0
def clear_model_cache(collab_cache_model):
    """Clear caches for given collaboration cache model

    Args:
        collab_cache_model (bim360.CollabCacheModel): cache model to clear
    """
    if isinstance(collab_cache_model, CollabCacheModel):
        cm = collab_cache_model
        mlogger.debug('Deleting %s', cm.model_path)
        try:
            if op.exists(cm.model_path):
                os.remove(cm.model_path)
        except Exception as cmdel_ex:
            mlogger.error('Error deleting model cache @ %s | %s',
                          cm.model_path, str(cmdel_ex))

        mlogger.debug('Deleting %s', cm.model_backup_path)
        try:
            if op.exists(cm.model_backup_path):
                coreutils.fully_remove_dir(cm.model_backup_path)
        except Exception as cmbdel_ex:
            mlogger.error('Error deleting model backup @ %s | %s',
                          cm.model_backup_path, str(cmbdel_ex))

        mlogger.debug('Deleting %s', cm.central_cache_model_path)
        try:
            if op.exists(cm.central_cache_model_path):
                os.remove(cm.central_cache_model_path)
        except Exception as ccmdel_ex:
            mlogger.error('Error deleting central model cache @ %s | %s',
                          cm.central_cache_model_path, str(ccmdel_ex))
示例#2
0
def _remove_extpkg(extpkg, remove_dependencies=True):
    if extpkg.is_removable:
        dir_to_remove = extpkg.is_installed
        if dir_to_remove:
            fully_remove_dir(dir_to_remove)
            extpkg.remove_pkg_config()
            mlogger.info('Successfully removed extension from: %s',
                         dir_to_remove)
        else:
            raise PyRevitPluginRemoveException('Can not find installed path.')
    else:
        raise PyRevitPluginRemoveException('Extension does not have url '
                                           'and can not be installed later.')

    if remove_dependencies:
        dg = get_dependency_graph()
        mlogger.info('Removing dependencies for %s', extpkg.name)
        for dep_pkg_name in extpkg.dependencies:
            dep_pkg = get_ext_package_by_name(dep_pkg_name)
            if dep_pkg and not dg.has_installed_dependents(dep_pkg_name):
                _remove_extpkg(dep_pkg, remove_dependencies=True)