How to use the termcolor.red function in termcolor

To help you get started, we’ve selected a few termcolor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PenguPilot / PenguPilot / svctrl / processes.py View on Github external
def start(name, path, args):
   if args:
      path += ' ' + args
   if validate(name):
      print green('note:') + ' %s is already running' % name
   else:
      print 'starting', blue(name), '...',
      ps = subprocess.Popen(path.split(' '), shell = False, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
      ps.stdout.close()
      ps.stderr.close()
      ps.wait()
      if ps.returncode != 0:
         print red('[ERROR: service quit with code ' + str(ps.returncode) + ']')
      else:
         for _ in range(30):
            time.sleep(0.1)
            try:
               pid = validate(name)
               if pid:
                   break
            except:
               pass
         if not pid:
            raise Exception('process terminated')
         print green('[OK]')
github PenguPilot / PenguPilot / svctrl / svctrl.py View on Github external
if len(names) > 1:
               print 'dependency resolution order:', names
            for name in names:
               start(name, config[name][0], args[2])
         else:
            running = running_processes()
            names = []
            for service in restart_order(name):
               if service in running:
                  names.append(service)
            rev_names = copy.deepcopy(names)
            rev_names.reverse()
            for name in rev_names:
               stop(name)
      except KeyError, e:
         print red('ERROR:'), 'service %s is unknown' % args[1]
      except Exception, e:
         print red('ERROR:'), 'service %s failed to start/stop: %s' % (args[1], str(e))

   elif args[0] == 'restart':
      name = args[1]
      try:
         data = config[name]
      except KeyError, e:
         print red('ERROR:'), 'service %s is unknown' % args[1]
         sys.exit(1)
      names = []
      running = running_processes()
      if name not in running:
         print red('ERROR:'), 'service %s is not running' % args[1]
         sys.exit(1)
      for service in restart_order(name):
github PenguPilot / PenguPilot / svctrl / svctrl.py View on Github external
for service in restart_order(name):
         if service in running:
            names.append(service)
      rev_names = copy.deepcopy(names)
      rev_names.reverse()
      if len(rev_names) > 1:
         print 'stop resolution order:', rev_names
      for name in rev_names:
         stop(name)
      if len(names) > 1:
         print 'start resolution order:', names
      for name in names:
         start(name, config[name][0], args[2])

except KeyboardInterrupt:
   print red('NOTE:'), 'operation canceled by user'
github PenguPilot / PenguPilot / svctrl / svctrl.py View on Github external
args = parse_args()
   config = read_config()
   if args == 'show':
      # show list and status of services
      max_name_len = 0
      for name in config:
         name_len = len(name)
         if name_len > max_name_len:
            max_name_len = name_len
      for name, (path, _) in config.items():
         skip = ' ' * (max_name_len - len(name))
         pid = validate(name)
         if pid:
            ex_str = green('running [%d]' % pid)
         else:
            ex_str = red('not running')
         try:
            if len(config[name][1]) > 0:
               ex_str += '\t(deps: ' + ', '.join(config[name][1]) + ')'
         except:
            pass
         print '%s:%s %s' % (blue(name), skip, ex_str)

   elif args[0] in ['start', 'stop']:
      try:
         name = args[1]
         data = config[name]
         if args[0] == 'start':
            names = start_order(name)
            if len(names) > 1:
               print 'dependency resolution order:', names
            for name in names:
github PenguPilot / PenguPilot / svctrl / processes.py View on Github external
def stop(name):
   print 'stopping', blue(name), '...',
   pid = validate(name)
   if pid:
      kill(pid)
      while validate(name):
         time.sleep(0.1)
      print green('[OK]')
   else:
      print red('[ERROR: no such process]')