Permalink
Browse files

support for stderr lol :)

  • Loading branch information...
maltize committed Sep 6, 2011
1 parent 33fccbb commit ba3ad8d3fb2b3d71f417cb28a0d17abd9f488d59
Showing with 17 additions and 4 deletions.
  1. +17 −4 run_ruby_test.py
View
@@ -11,11 +11,14 @@ class AsyncProcess(object):
def __init__(self, cmd, listener):
self.cmd = cmd
self.listener = listener
- thread.start_new_thread(self.read_stdout, ())
+ print "DEBUG_EXEC: " + self.cmd
+ self.proc = subprocess.Popen([self.cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if self.proc.stdout:
+ thread.start_new_thread(self.read_stdout, ())
+ if self.proc.stderr:
+ thread.start_new_thread(self.read_stderr, ())
def read_stdout(self):
- print "DEBUG_EXEC: " + self.cmd
- self.proc = subprocess.Popen([self.cmd], shell=True, stdout=subprocess.PIPE)
while True:
data = os.read(self.proc.stdout.fileno(), 2**15)
if data != "":
@@ -25,6 +28,16 @@ def read_stdout(self):
self.listener.is_running = False
break
+ def read_stderr(self):
+ while True:
+ data = os.read(self.proc.stderr.fileno(), 2**15)
+ if data != "":
+ sublime.set_timeout(functools.partial(self.listener.append_data, self.proc, data), 0)
+ else:
+ self.proc.stderr.close()
+ self.listener.is_running = False
+ break
+
class StatusProcess(object):
def __init__(self, msg, listener):
self.msg = msg
@@ -145,4 +158,4 @@ def run(self):
StatusProcess("Checking syntax of : " + file_name, self)
else:
- sublime.error_message("only .rb or .erb file")
+ sublime.error_message("only .rb or .erb file")

0 comments on commit ba3ad8d

Please sign in to comment.