def check(self): """ It performs the check on the system and verifies that all the dependencies of this Swirl can be satisfied. :rtype: bool :return: True if the check passes False otherwise. The list of missing dependencies can be retrieved with :meth:`getError` """ returnValue = True # this method of using rpath is not totaly correct but it's faster # so for the moment we have to live with this for swF in self.swirl.execedFiles: rpath = swF.rpaths + self.extraPath + utils.getLDLibraryPath( swF.env) for swf_dep in [ swF ] + self.swirl.getListSwirlFilesDependentStatic(swF): for dep in swf_dep.staticDependencies: if not PluginManager.getPathToLibrary(dep, rpath=rpath): self.missingDeps.add(dep) returnValue = False for dynamic_dep in swF.dynamicDependencies: if not os.path.exists(dynamic_dep.path): self.missingDeps = self.missingDeps.union( dynamic_dep.provides) returnValue = False return returnValue
def searchModules(self): """ It searches for missing dependencies using the 'module' command line. :meth:`check` should be called before this :rtype: string :return: with a human readable list of module which can satisfy missing dependencies """ # loop through all the modules retDict = {} (output, retval) = utils.getOutputAsList( ["bash", "-c", "module -t avail 2>&1"]) if retval: print("Unable to run module command, verify it\'s in the path.") return "" for module in output: # in the output there are some paths! remove them e.g. "/opt/module/blabla:" if ':' in module: continue # remove (default) module = module.split("(default)")[0] (output, retval) = utils.getOutputAsList( ["bash", "-c", "module show " + module + " 2>&1"]) if retval: #print "Unable to fetch module information: \'module show " + module + "\'" # all module which depend on another module return 1 pass for line in output: if 'LD_LIBRARY_PATH' in line: # we found another path to scan path = line.split('LD_LIBRARY_PATH')[1] path = [i.strip() for i in path.split(":")] #strip PluginManager.systemPath = path # update path for dep in self.missingDeps: if PluginManager.getPathToLibrary(dep, False): #we found a candidate for this missing dependency if module not in retDict: retDict[module] = [] retDict[module].append(dep.getName()) retStr = "" for mod in retDict: retStr += " " + mod + " satisfies " num_deps = len(retDict[mod]) if num_deps == len(self.missingDeps): retStr += "all " retStr += "" + str(num_deps) + " dependencies:\n" # print the deps retStr += " " + "\n ".join(retDict[mod]) + "\n" return retStr
def searchModules(self): """ It searches for missing dependencies using the 'module' command line. :meth:`check` should be called before this :rtype: string :return: with a human readable list of module which can satisfy missing dependencies """ # loop through all the modules retDict = {} (output, retval) = utils.getOutputAsList(["bash", "-c", "module -t avail 2>&1"]) if retval: print "Unable to run module command, verify it\'s in the path." return "" for module in output : # in the output there are some paths! remove them e.g. "/opt/module/blabla:" if ':' in module: continue # remove (default) module = module.split("(default)")[0] (output, retval) = utils.getOutputAsList(["bash", "-c", "module show " + module + " 2>&1"]) if retval: #print "Unable to fetch module information: \'module show " + module + "\'" # all module which depend on another module return 1 pass for line in output: if 'LD_LIBRARY_PATH' in line: # we found another path to scan path = line.split('LD_LIBRARY_PATH')[1] path = [i.strip() for i in path.split(":")] #strip PluginManager.systemPath = path # update path for dep in self.missingDeps: if PluginManager.getPathToLibrary(dep, False): #we found a candidate for this missing dependency if module not in retDict: retDict[module] = [] retDict[module].append(dep.getName()) retStr = "" for mod in retDict: retStr += " " + mod + " satisfies " num_deps = len(retDict[mod]) if num_deps == len(self.missingDeps): retStr += "all " retStr += "" + str(num_deps) + " dependencies:\n" # print the deps retStr += " " + "\n ".join(retDict[mod]) + "\n" return retStr
def checkHash(self): """check if any dep was modified since the swirl file creation (using checksuming) """ self.error = [] depList = self.swirl.getDependencies() returnValue = True for dep in depList: path = PluginManager.getPathToLibrary(dep) if not path: continue hash = getHash(path, dep.pluginName) if not hash in dep.hashList: self.error.append(dep.depname) returnValue = False print dep.depname, " computed ", hash, " originals ", dep.hashList return returnValue
def checkHash(self, verbose=False): """ It checks if any dependency was modified since the swirl file creation (using checksumming) :type verbose: bool :param verbose: if True it will generate more verbose error message :rtype: bool :return: True if the check passes False otherwise. The list of modified dependencies can be retrieved with :meth:getError() """ self.error = [] pathCache = [] returnValue = True for dep in self.swirl.getDependencies(): path = PluginManager.getPathToLibrary(dep) if not path: # error ` tmpStr = str(dep) if verbose: tmpStr += " unable to find its file" self.error.append(tmpStr) returnValue = False continue if path in pathCache: #we already did this file continue hash = getHash(path, dep.type) pathCache.append(path) swirlProvider = self.swirl.getSwirlFileByProv(dep) if not swirlProvider: self.error.append("SwirlFile has unresolved dependency " + str(dep) \ + " the hash can not be verified") returnValue = False if hash != swirlProvider.md5sum : tmpStr = str(dep) if verbose: tmpStr += " wrong hash (computed " + hash + " originals " + \ swirlProvider.md5sum + ")" self.error.append(tmpStr) returnValue = False return returnValue
def checkHash(self, verbose=False): """ It checks if any dependency was modified since the swirl file creation (using checksumming) :type verbose: bool :param verbose: if True it will generate more verbose error message :rtype: bool :return: True if the check passes False otherwise. The list of modified dependencies can be retrieved with :meth:getError() """ self.error = [] pathCache = [] returnValue = True for dep in self.swirl.getDependencies(): path = PluginManager.getPathToLibrary(dep) if not path: # error ` tmpStr = str(dep) if verbose: tmpStr += " unable to find its file" self.error.append(tmpStr) returnValue = False continue if path in pathCache: #we already did this file continue hash = getHash(path, dep.type) pathCache.append(path) swirlProvider = self.swirl.getSwirlFileByProv(dep) if not swirlProvider: self.error.append("SwirlFile has unresolved dependency " + str(dep) \ + " the hash can not be verified") returnValue = False if hash != swirlProvider.md5sum: tmpStr = str(dep) if verbose: tmpStr += " wrong hash (computed " + hash + " originals " + \ swirlProvider.md5sum + ")" self.error.append(tmpStr) returnValue = False return returnValue
def check(self): """ It performs the check on the system and verifies that all the dependencies of this Swirl can be satisfied. :rtype: bool :return: True if the check passes False otherwise. The list of missing dependencies can be retrieved with :meth:`getError` """ returnValue = True # this method of using rpath is not totaly correct but it's faster # so for the moment we have to live with this for swF in self.swirl.execedFiles: rpath = swF.rpaths + self.extraPath + utils.getLDLibraryPath(swF.env) for swf_dep in [swF] + self.swirl.getListSwirlFilesDependentStatic(swF): for dep in swf_dep.staticDependencies: if not PluginManager.getPathToLibrary(dep, rpath = rpath): self.missingDeps.add(dep) returnValue = False for dynamic_dep in swF.dynamicDependencies: if not os.path.exists(dynamic_dep.path): self.missingDeps = self.missingDeps.union(dynamic_dep.provides) returnValue = False return returnValue