def run ( self ): print "Welcome to the thread!" #print self.cmd #print self.pContent p = Popen(cmd, stdout=PIPE, stderr=STDOUT, shell=True) stdoutdata, stderrdata = p.communicate() # display errors and warnings from last generated log file, # followed by the full output of the texify command # (if we only use the texify output, we get multiple errors/warnings, and also # warnings about e.g. references that are corrected in subsequent runs) texifyLog = stdoutdata.decode(getOEMCP()).splitlines() try: # Read it in as binary, as there may be NULLs # No need to close as we do not create a file object log = open(texFile + ".log", 'rb').read().decode(getOEMCP()).splitlines() except IOError: # if we cannot read the log file for any reason, # just use the texify output log = texifyLog pContent = self.pContent + ["",] + parseTeXlog(log) + \ ["","********************", "", "Full texify output follows", \ "Remember: texify may run latex & friends many times; missing refs. etc. may get automatically fixed in later runs",\ "", "********************", "", ""] + texifyLog sublime.setTimeout(functools.partial(self.qp,"texify","gotoTeXError", pContent), 0) print "returned from qp in thread"
def lintFile(self, view, openFull): basePath = sublime.packagesPath()+"\\Seld\\" startupinfo = STARTUPINFO() startupinfo.dwFlags |= STARTF_USESHOWWINDOW content = view.substr(Region(0, view.size())) process = Popen('cscript "'+basePath+'jslint.js"', stdin=PIPE, stdout=PIPE, stderr=PIPE, startupinfo=startupinfo) (stdout, stderr) = process.communicate(content) output = b'' for line in stderr.splitlines(): print line if line[0:7] == 'Lint at': if output.strip(): output += b"\n" try: output += line.decode('utf-8').strip() + " >>" except UnicodeDecodeError: print "File encoding error detected" elif output.strip() and line.strip(): output += " "+line.decode('utf-8').strip() if not output.strip(): if openFull: view.eraseRegions('jsLint') self.updateStatus('No syntax error detected') return if openFull: lines = output.splitlines() jsLint.highlightTexts(self, view, lines) view.window().showQuickPanel("", "jsLintGoto", lines, sublime.QUICK_PANEL_MONOSPACE_FONT) else: sublime.setTimeout(functools.partial(self.updateStatus, '<!> '+output.splitlines()[0]), 100)
def wrapped(*args, **kwargs): def idle(): func.pending -= 1 if func.pending is 0: func(*args, **kwargs) func.pending +=1 sublime.setTimeout(idle, ms)
def revert(self, view): sublime.setTimeout(partial(view.runCommand, 'revert'), 50) self.justReverted = True
def next(): try: routine.next() except StopIteration: return sublime.setTimeout(next, every)
def getPackages(self): packageList = packagedownloader.listPackages() # Interrupt main thread to notify sublime.setTimeout(partial(self.notify, packageList), 1)