def _getEvalOrder( self ): try: tmpList = [ self._cwdConfPath, self._userConfPath, self._machineConfPath, self._defaultConfPath ] except OSError as e: logging.error( e ) logging.error( 'Problem with current working directory detected!' ) raise SystemExit() if self._addPaths: resultList = [ tmpList[0] ] for path in self._addPaths: resultList.append( path ) resultList.append( tmpList[1:] ) resultList = FastScript.flattenList( resultList ) logging.debug( 'full list: %s', resultList ) else: resultList = tmpList return resultList
def getBuildDependencies(project, recursive=False): """ For now this simply calls getBuildDependenciesFromPkgInfo(), ignoring the case that the pkgInfo.py might not be present. Note: Unlike getDependencies(), the result of this function is a flat (non-nested) list. """ from ToolBOSCore.Storage.PkgInfo import getPkgInfoContent Any.requireIsTextNonEmpty(project) try: resultList = getPkgInfoContent(project)['buildDepends'] except (AssertionError, IOError, KeyError): resultList = [] if recursive: depList = getDependencies(project, recursive=True) depList = FastScript.flattenList(depList) for dep in depList: if dep.startswith('sit://'): try: buildDepList = getPkgInfoContent( SIT.strip(dep))['buildDepends'] except (AssertionError, IOError, KeyError): buildDepList = [] if buildDepList: resultList.append(buildDepList) resultList = FastScript.reduceList(resultList) return resultList
def getFlatDependencies(canonicalPaths, cache=None, sitPath=None): """ Resolves all dependencies recursively and converts them to a flat set of overall dependencies. This function might be handy to determine all SIT packages that need to transferred to another site. """ cache = {} if cache is None else cache sitPath = SIT.getPath() if sitPath is None else sitPath Any.requireIsIterable(canonicalPaths) Any.requireIsDict(cache) Any.requireIsTextNonEmpty(sitPath) result = set() for canonicalPath in canonicalPaths: requireIsCanonicalPath(canonicalPath) result.add('sit://' + canonicalPath) deps = getDependencies(canonicalPath, recursive=True, cache=cache, systemPackages=False, sitPath=sitPath) flatDeps = FastScript.flattenList(deps) for item in flatDeps: result.add(item) return result
def _getEvalOrder(addPaths=None): """ Returns an ordered list with paths to configfiles (in search order). First element: Highest priority (user's home dir.) Last element: Lowest priority (default shipped with ToolBOS SDK) To search in non-standard locations provide a list 'addPaths'. Its path entries will be searched right after ./ToolBOS.conf. """ if addPaths is not None: Any.requireIsListNonEmpty(addPaths) try: tmpList = [ getSettingsFile_cwd(), getSettingsFile_user(), getSettingsFile_machine(), getSettingsFile_default() ] except OSError as details: # may be raised by os.getcwd() if there is a problem with the CWD # e.g. NFS problem or directory deleted by another process # # continuing to work in such situation is dangerous, we really should # stop in such case logging.error(details) logging.error('Problem with current working directory detected!') raise SystemExit() if addPaths: resultList = [tmpList[0]] for path in addPaths: resultList.append([os.path.join(path, settingsFile)]) resultList.append(tmpList[1:]) resultList = FastScript.flattenList(resultList) # logging.debug( 'full list: %s', resultList ) else: resultList = tmpList return resultList
def areAllDependenciesInstalled(project, dependencyList=None): """ Checks and returns a boolean if all dependencies of a project are present in the SIT. It will also return 'False' if the dependencies could not be queried at all or if there are some errors. So receiving a 'True' status is quite reliable. 'project' must be in canonical form, e.g. 'Libraries/Serialize/3.0'. If 'dependencyList' (an optionally nested list of dependencies) is specified it will be used as a cache instead of querying the dependency tree from the slower filesystem. If such 'dependencyList' is provided but is an empty list then always 'True' will be returned. """ Any.requireIsTextNonEmpty(project) #Any.requireIsList( dependencyList ) if (isinstance(dependencyList, list)) and len(dependencyList) == 0: return True if not dependencyList: try: dependencyList = getDependencies(project, True) except RuntimeError: # e.g. unable to retrieve dependencies return False urlList = FastScript.reduceList(FastScript.flattenList(dependencyList)) for url in urlList: try: if not isInstalled(url): return False except ValueError as details: logging.error(details) raise ValueError('unable to check install status of %s' % project) return True