def __init__(self, parent=None): super().__init__(parent) self._application = Application.getInstance() self._container_registry = self._application.getContainerRegistry() self._plugin_registry = self._application.getPluginRegistry() #JSON files that keep track of all installed packages. self._user_package_management_file_path = None self._bundled_package_management_file_path = None for search_path in Resources.getSearchPaths(): candidate_bundled_path = os.path.join(search_path, "bundled_packages.json") if os.path.exists(candidate_bundled_path): self._bundled_package_management_file_path = candidate_bundled_path for search_path in (Resources.getDataStoragePath(), Resources.getConfigStoragePath()): candidate_user_path = os.path.join(search_path, "packages.json") if os.path.exists(candidate_user_path): self._user_package_management_file_path = candidate_user_path if self._user_package_management_file_path is None: #Doesn't exist yet. self._user_package_management_file_path = os.path.join( Resources.getDataStoragePath(), "packages.json") self._bundled_package_dict = {} # A dict of all bundled packages self._installed_package_dict = {} # A dict of all installed packages self._to_remove_package_set = set( ) # A set of packages that need to be removed at the next start self._to_install_package_dict = { } # A dict of packages that need to be installed at the next start
def __init__(self, application, parent = None): super().__init__(parent) self._application = application self._container_registry = self._application.getContainerRegistry() self._plugin_registry = self._application.getPluginRegistry() #JSON files that keep track of all installed packages. self._user_package_management_file_path = None #type: str self._bundled_package_management_file_paths = [] #type: List[str] for search_path in Resources.getSearchPaths(): candidate_bundled_path = os.path.join(search_path, "bundled_packages.json") if os.path.exists(candidate_bundled_path): Logger.log("i", "Found bundled packages location: {location}".format(location = search_path)) self._bundled_package_management_file_paths.append(candidate_bundled_path) for search_path in (Resources.getDataStoragePath(), Resources.getConfigStoragePath()): candidate_user_path = os.path.join(search_path, "packages.json") if os.path.exists(candidate_user_path): self._user_package_management_file_path = candidate_user_path if self._user_package_management_file_path is None: #Doesn't exist yet. self._user_package_management_file_path = os.path.join(Resources.getDataStoragePath(), "packages.json") self._installation_dirs_dict = {"plugins": os.path.abspath(Resources.getStoragePath(Resources.Plugins))} # type: Dict[str, str] self._bundled_package_dict = {} # A dict of all bundled packages self._installed_package_dict = {} # A dict of all installed packages self._to_remove_package_set = set() # A set of packages that need to be removed at the next start self._to_install_package_dict = {} # A dict of packages that need to be installed at the next start
def _getUpgradeTasks(self): exclude_folders = ["old", "cache", "plugins"] for old_configuration_type, storage_paths in self._storage_paths.items( ): storage_path_prefixes = set( Resources.getSearchPaths()) #Set removes duplicates. storage_path_prefixes.add(Resources.getConfigStoragePath()) storage_path_prefixes.add(Resources.getDataStoragePath()) for prefix in storage_path_prefixes: for storage_path in storage_paths: path = os.path.join(prefix, storage_path) for configuration_file in self._getFilesInDirectory( path, exclude_paths=exclude_folders): yield UpgradeTask( storage_path=path, file_name=configuration_file, configuration_type=old_configuration_type)