# Path: sts/util/console.py
# class color(object):
#   GRAY, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, CRIMSON = map(lambda num : BEGIN + str(num) + "m", range(30, 39))
#   B_GRAY, B_RED, B_GREEN, B_YELLOW, B_BLUE, B_MAGENTA, B_CYAN, B_WHITE, B_CRIMSON =  map(lambda num: BEGIN + str(num) + "m", range(40, 49))
#   NORMAL = END


import subprocess
import threading
import os
import signal
import sys
import time
import traceback
from functools import partial
from sts.util.console import color

  if close_fds:
    for child in all_dead:
      for attr_name in "stdin", "stdout", "stderr":
        if hasattr(child, attr_name):
          try:
            attr = getattr(child, attr_name)
            if attr:
              attr.close()
          except IOError:
            msg("close() called on %s during concurrent operation\n" % attr_name)
          except:
            msg("Error closing child io.\n")
            tb = traceback.format_exc()
            msg(tb)

  if len(child_processes) == 0:
    msg(' OK\n')

printlock = threading.Lock()
def _prefix_thread(f, func):
  def run():
    while not f.closed:
      line = f.readline()
      if not line:
        break
      with printlock:
        print func(line)
    try:
      sys.stderr.write("Closing fd %d\n" % f)

# Path: sts/util/console.py
# class color(object):
#   GRAY, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE, CRIMSON = map(lambda num : BEGIN + str(num) + "m", range(30, 39))
#   B_GRAY, B_RED, B_GREEN, B_YELLOW, B_BLUE, B_MAGENTA, B_CYAN, B_WHITE, B_CRIMSON =  map(lambda num: BEGIN + str(num) + "m", range(40, 49))
#   NORMAL = END


# Path: sts/util/procutils.py
import subprocess
import threading
import os
import signal
import sys
import time
import traceback
from functools import partial
from sts.util.console import color


  if close_fds:
    for child in all_dead:
      for attr_name in "stdin", "stdout", "stderr":
        if hasattr(child, attr_name):
          try:
            attr = getattr(child, attr_name)
            if attr:
              attr.close()
          except IOError:
            msg("close() called on %s during concurrent operation\n" % attr_name)
          except:
            msg("Error closing child io.\n")
            tb = traceback.format_exc()
            msg(tb)

  if len(child_processes) == 0:
    msg(' OK\n')

printlock = threading.Lock()
def _prefix_thread(f, func):
  def run():
    while not f.closed:
      line = f.readline()
      if not line:
        break
      with printlock:
        print func(line)
    try:
      sys.stderr.write("Closing fd %d\n" % f)

      f.close() # idempotent, in case the f.closed broke out of the while loop