def handleStopOnError(self, e): """Handles the stop on error parameter, prints the standard message and calls exist.""" colorTool = ColorTool() colorTool.cPrintln(colorTool.OK, " > Stop on error enabled (for more information call bake with -vv or -vvv)") colorTool.cPrintln(colorTool.FAIL, " >> " + e._reason) os._exit(1)
def _do_download(self, env, source, name, forceDownload): """ Recursive download function, do the download for each target module. """ srcDirTmp = name if source.attribute('module_directory').value : srcDirTmp = source.attribute('module_directory').value env.start_source(name, srcDirTmp) rt = source.check_version(env) if forceDownload: try: # when forced download, removes the repository if it exists if os.path.isdir(env.srcdir): shutil.rmtree(env.srcdir) except OSError as e: env._logger.commands.write('Could not remove source files' ' %s for module: %s \n Error: %s\n' % (env.srcdir, env._module_name, str(e))) aditionalModule=False if source.attribute('additional-module'): aditionalModule = source.attribute('additional-module').value if os.path.isdir(env.srcdir) and not aditionalModule : colorTool = ColorTool() if env._logger._verbose == 0: colorTool.cPrint(colorTool.OK, "(Nothing to do, source directory already exists) - ") else: colorTool.cPrintln(colorTool.OK, " >>> No actions needed, the source directory for " + self._name + " already exists.") sys.stdout.write (" If you want to update the module, use update instead download, or, if you want a fresh copy," + os.linesep +" either remove it from the source directory, or use the --force_download option.") if self._source.attribute('new_variable').value != '': elements = env.replace_variables(self._source.attribute('new_variable').value).split(";") env.add_variables(elements) env.end_source() else: try: source.download(env) if self._source.attribute('patch').value != '': self._build.threat_patch(env, self._source.attribute('patch').value) if self._source.attribute('new_variable').value != '': elements = env.replace_variables(self._source.attribute('new_variable').value).split(";") env.add_variables(elements) if self._source.attribute('post_download').value != '': self._source.perform_post_download(env) finally: env.end_source() for child, child_name in source.children(): self._do_download(env, child, os.path.join(name, child_name))
def printResult(self, env, operation, result): """Prints the result of the operation.""" colorTool = ColorTool() resultStr = "OK" color = colorTool.OK if result == self.FAIL: resultStr = "Problem" color = colorTool.FAIL if env._logger._verbose > 0: print colorTool.cPrintln(color, " >> " + operation + " " + self._name + " - " + resultStr) else: colorTool.cPrintln(color, resultStr)
def printResult(self, env, operation, result): """Prints the result of the operation.""" colorTool = ColorTool() resultStr = "OK" color=colorTool.OK if result == self.FAIL: resultStr = "Problem" color=colorTool.FAIL if env._logger._verbose > 0: print() colorTool.cPrintln(color, " >> " + operation + " " + self._name + " - " +resultStr) else: colorTool.cPrintln(color, resultStr)