def parse(self): error = None lines = self.lines[:] while lines: line = lines.pop() if line.startswith(' Module '): modPath, lineNo, funcName = line[9:].split(', ') lineNo = int(lineNo[5:]) modPath = modPath.strip() if modPath == 'Script (Python)': path = lines.pop() lines.pop() if path.startswith(' - <PythonScript at '): path = path[22:].strip()[:-1] debugUrl = self.baseUrl + path + '/Script (Python)' self.stack.append( ErrorStack.StackEntry(debugUrl, lineNo + 1, funcName)) elif modPath.startswith('Python expression'): continue else: modPath = self.libPath + '/' + modPath.replace('.', '/') + '.py' self.stack.append( ErrorStack.StackEntry(modPath, lineNo, funcName)) elif line.startswith(' - <PythonScript at '): path = line[22:].strip()[:-1] debugUrl = self.baseUrl + path + '/Script (Python)' self.stack.append( ErrorStack.StackEntry(debugUrl, 0, os.path.basename(path))) elif line.startswith(' - <ZopePageTemplate at '): path = line[26:].strip()[:-1] debugUrl = self.baseUrl + path + '/Page Template' self.stack.append( ErrorStack.StackEntry(debugUrl, 0, os.path.basename(path))) elif line.startswith(' - URL: '): path = line[10:].strip() lineNo, colNo = lines.pop().split(', ') lineNo = int(lineNo.split()[-1]) debugUrl = self.baseUrl + path + '/Page Template' self.stack.append( ErrorStack.StackEntry(debugUrl, lineNo, os.path.basename(path))) elif line and line[0] != ' ': errType, errValue = line.split(': ', 1) lines.reverse() errValue = (errValue + ' '.join(lines)).strip() if errValue and errValue[0] == '<': errValue = Utils.html2txt(errValue).replace('\n', ' ') error = [errType, errValue] break assert error self.error = error for entry in self.stack: entry.error = error
def compile(self): import ModRunner oldErr = sys.stderr sys.stderr = ErrorStack.RecFile() try: cmr = ModRunner.CompileModuleRunner(self.editor.erroutFrm) cmr.run(self.filename, self.data + '\n\n', self.modified) serr = ErrorStack.errorList(sys.stderr) cmr.checkError(serr, 'Compiled') finally: sys.stderr = oldErr return len(serr)
def runLint(self): filename = self.assertLocalFile() from ExternalLib import pylint import StringIO pylint.pylint(StringIO.StringIO(self.data), filename) if pylint.warnings: return ErrorStack.buildLintWarningList(pylint.warnings[:])
def parse(self): for ref in self.lines: self.error = [ '%s%% confidence for: %s:%s' % (ref.confidence, ref.filename, ref.lineno) ] self.stack.append( ErrorStack.StackEntry( ref.filename, ref.lineno, linecache.getline(ref.filename, ref.lineno), self.error))
def crashLog(self): err = ErrorStack.crashError(os.path.splitext(self.assertLocalFile())[0]+'.trace') if err: frm = self.editor.erroutFrm if frm: frm.updateCtrls(err) frm.display(err) return frm else: wx.LogError(_('Trace file not found. Run with command line param -T')) return None
def finFunc(): errors = StringIO(''.join(err)).readlines() output = StringIO(''.join(out)).readlines() serr = ErrorStack.buildErrorList(errors) if serr or output: self.checkError(serr, _('Ran'), output, errRaw=errors) if execFinish: execFinish(self)
def run(self, cmd, Parser=ErrorStack.StdErrErrorParser, caption=_('Execute module'), root='Error', autoClose=False): import ProcessProgressDlg dlg = ProcessProgressDlg.ProcessProgressDlg(None, cmd, caption, autoClose=autoClose) try: dlg.ShowModal() serr = ErrorStack.buildErrorList(dlg.errors, Parser) return self.checkError(serr, _('Ran'), dlg.output, root, dlg.errors) finally: dlg.Destroy()
def compile(self): import ModRunner oldErr = sys.stderr sys.stderr = ErrorStack.RecFile() try: cmr = ModRunner.CompileModuleRunner(self.editor.erroutFrm) cmr.run(self.filename, self.data+'\n\n', self.modified) serr = ErrorStack.errorList(sys.stderr) cmr.checkError(serr, 'Compiled') finally: sys.stderr = oldErr return len(serr)
def run(self, cmd, inpLines=[], execStart=None): inpLines.reverse() inp, outp, errp = os.popen3(cmd) pid = 0 # XXX only available on unix :( if execStart: wx.CallAfter(execStart, pid) out = [] while 1: if inpLines: inp.write(inpLines.pop()) l = outp.readline() if not l: break out.append(l) errLines = errp.readlines() serr = ErrorStack.buildErrorList(errLines) self.pid = pid if serr or out: return self.checkError(serr, _('Ran'), out, errRaw=errLines) else: return None