def excepthook(type, exc_msg, tb): cfg = self.recipe.cfg sys.excepthook = sys.__excepthook__ if cfg.debugRecipeExceptions: lines = traceback.format_exception(type, exc_msg, tb) print string.joinfields(lines, "") if self.linenum is not None: prefix = "%s:%s:" % (self.file, self.linenum) prefix_len = len(prefix) if str(exc_msg)[:prefix_len] != prefix: exc_message = "%s:%s: %s: %s" % (self.file, self.linenum, type.__name__, exc_msg) print exc_message if self.recipe.buildinfo: try: buildinfo = self.recipe.buildinfo buildinfo.error = exc_message buildinfo.file = self.file buildinfo.lastline = self.linenum buildinfo.stop() except: log.warning("could not write out to buildinfo") if cfg.debugRecipeExceptions and self.recipe.isatty(): debugger.post_mortem(tb, type, exc_msg) else: sys.exit(1)
def forkResponseFn(self, forkFunction, fn, *args, **kw): pid = forkFunction() if pid: if SSL and isinstance(self.request.request, SSLConnection): sslsocket = self.request.request socket = sslsocket.socket sslsocket.close = socket.close sslsocket.sslbio = None sslsocket.sockbio = None else: socket = self.request.request # Python 2.7 tries to shutdown() first which the parent must not do # after handing off socket.close() return try: try: rv = fn(*args, **kw) self.sendResponse(rv) os._exit(0) except: if self.debug: from conary.lib import debugger debugger.post_mortem() self.sendInternalError() finally: os._exit(1)
def buildAndExit(self): try: try: signal.signal(signal.SIGTERM, self._signalHandler) self.logFile.redirectOutput() # redirect all output to the log # file. # We do this to ensure that # output we don't control, # such as conary output, is # directed to a file. self.build() os._exit(0) except Exception, err: self.logger.error(traceback.format_exc()) self.job.exceptionOccurred(err, traceback.format_exc()) self.logFile.restoreOutput() try: self.worker.stopAllCommands() finally: if sys.stdin.isatty(): # this sets us back to be connected with the controlling # terminal (owned by our parent, the rmake server) from conary.lib import debugger debugger.post_mortem(sys.exc_info()[2]) os._exit(0) finally: os._exit(1)
def callFunction(self, fn, *args, **kw): try: if self.authMethod: self.authMethod(self, fn, *args, **kw) rv = fn(*args, **kw) if rv != None: rv = _freezeReturn(self.method, rv, self.methodVersion) else: rv = '' response = (True, rv) except Exception, err: if not isinstance(err, errors.RmakeError): self.logger.exception("Exception in API call:") response = (False, _freezeException(err)) if self.debug: from conary.lib import debugger debugger.post_mortem(sys.exc_info()[2])
def callFunction(self, fn, *args, **kw): try: if self.authMethod: self.authMethod(self, fn, *args, **kw) rv = fn(*args, **kw) if isinstance(rv, rpclib.ResponseModifier): return rv if rv != None: rv = _freezeReturn(self.method, rv, self.methodVersion) else: rv = '' response = (True, rv) except Exception, err: response = (False, _freezeException(err)) if self.debug: from conary.lib import debugger debugger.post_mortem(sys.exc_info()[2])
def buildAndExit(self): try: try: signal.signal(signal.SIGTERM, self._signalHandler) self.build() os._exit(0) except Exception, err: self.logger.error(traceback.format_exc()) self.job.exceptionOccurred(err, traceback.format_exc()) try: self.worker.stopAllCommands() finally: if sys.stdin.isatty(): # this sets us back to be connected with the controlling # terminal (owned by our parent, the rmake server) from conary.lib import debugger debugger.post_mortem(sys.exc_info()[2]) os._exit(0) finally: os._exit(1)
def _remove(path): if os.path.lexists(path): if os.path.islink(path): os.remove(path) elif os.path.isdir(path): shutil.rmtree(path) else: os.remove(path) def _link(source, target): _remove(target) os.symlink(source, target) def loadModules(moduleList, topDir='..', shouldClone=False, searchPath=None): m = ModuleLoader(moduleList, topDir, shouldClone=shouldClone, repositoryLocation='http://scc.eng.rpath.com//hg/', searchPath=searchPath) try: m.loadModules() m.testModules() except KeyboardInterrupt, e: raise except Exception, e: from conary.lib import debugger import traceback traceback.print_exc() debugger.post_mortem(sys.exc_info()[2]) sys.exit(1) os.environ['PYTHONPATH'] = ':'.join(sys.path)
def post_mortem(self, err): from conary.lib import debugger debugger.post_mortem(err[2], err[1], err[0])