Example #1
0
def run_bg(cmd, **kargs):
  if options.verbose == 2:
    logging.debug("run: %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  proc = Popen(args=args, **kargs)
  proc.args = args
  _add_proc(proc)
  return proc
Example #2
0
def run_bg(cmd, **kargs):
  if options.verbose == 2:
    logging.debug("run: %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  proc = Popen(args=args, **kargs)
  proc.args = args
  _add_proc(proc)
  return proc
Example #3
0
def run_bg(cmd, **kargs):
    if options.verbose:
        print "run:", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
    if isinstance(cmd, str):
        args = shlex.split(cmd)
    else:
        args = cmd
    proc = Popen(args=args, **kargs)
    proc.args = args
    _add_proc(proc)
    return proc
Example #4
0
def execute(cmd, trap_output=False, verbose=False, **kargs):
  args = shlex.split(cmd)
  if trap_output:
    kargs['stdout'] = PIPE
    kargs['stderr'] = PIPE
  if verbose:
    print "Execute:", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems())
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode:
    raise Exception('FAIL: %s %s %s' % (args, stdout, stderr))
  return stdout, stderr
Example #5
0
def run_bg(cmd, **kargs):
  if options.verbose == 2:
    logging.debug("run: %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
  if 'extra_env' in kargs and kargs['extra_env']:
    kargs['env'] = os.environ.copy()
    kargs['env'].update(kargs['extra_env'])
    del(kargs['extra_env'])
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  proc = Popen(args=args, **kargs)
  proc.args = args
  _add_proc(proc)
  return proc
Example #6
0
def run_fail(cmd, **kargs):
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  kargs['stdout'] = PIPE
  kargs['stderr'] = PIPE
  if options.verbose == 2:
    logging.debug("run: (expect fail) %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode == 0:
    logging.info("stdout:\n%sstderr:\n%s", stdout, stderr)
    raise TestError('expected fail:', args, stdout, stderr)
  return stdout, stderr
Example #7
0
def run_fail(cmd, **kargs):
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  kargs['stdout'] = PIPE
  kargs['stderr'] = PIPE
  if options.verbose == 2:
    logging.debug("run: (expect fail) %s %s", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems()))
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode == 0:
    logging.info("stdout:\n%sstderr:\n%s", stdout, stderr)
    raise TestError('expected fail:', args, stdout, stderr)
  return stdout, stderr
Example #8
0
def run_fail(cmd, **kargs):
    if isinstance(cmd, str):
        args = shlex.split(cmd)
    else:
        args = cmd
    kargs["stdout"] = PIPE
    kargs["stderr"] = PIPE
    if options.verbose:
        print "run: (expect fail)", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
    proc = Popen(args, **kargs)
    proc.args = args
    stdout, stderr = proc.communicate()
    if proc.returncode == 0:
        debug("stdout:\n" + stdout + "stderr:\n" + stderr)
        raise TestError("expected fail:", args, stdout, stderr)
    return stdout, stderr
Example #9
0
def run_bg(cmd, **kargs):
    if options.verbose == 2:
        logging.debug("run: %s %s", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems()))
    if "extra_env" in kargs:
        kargs["env"] = os.environ.copy()
        if kargs["extra_env"]:
            kargs["env"].update(kargs["extra_env"])
        del (kargs["extra_env"])
    if isinstance(cmd, str):
        args = shlex.split(cmd)
    else:
        args = cmd
    proc = Popen(args=args, **kargs)
    proc.args = args
    _add_proc(proc)
    return proc
Example #10
0
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  if trap_output:
    kargs['stdout'] = PIPE
    kargs['stderr'] = PIPE
  logging.debug("run: %s %s", str(cmd), ', '.join('%s=%s' % x for x in kargs.iteritems()))
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode:
    if raise_on_error:
      raise TestError('cmd fail:', args, stdout, stderr)
    else:
      logging.debug('cmd fail: %s %s %s', str(args), stdout, stderr)
  return stdout, stderr
Example #11
0
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  if trap_output:
    kargs['stdout'] = PIPE
    kargs['stderr'] = PIPE
  logging.debug("run: %s %s", str(cmd), ', '.join('%s=%s' % x for x in kargs.iteritems()))
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode:
    if raise_on_error:
      raise TestError('cmd fail:', args, stdout, stderr)
    else:
      logging.debug('cmd fail: %s %s %s', str(args), stdout, stderr)
  return stdout, stderr
Example #12
0
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
    if isinstance(cmd, str):
        args = shlex.split(cmd)
    else:
        args = cmd
    if trap_output:
        kargs["stdout"] = PIPE
        kargs["stderr"] = PIPE
    logging.debug("run: %s %s", str(cmd), ", ".join("%s=%s" % x for x in kargs.iteritems()))
    proc = Popen(args, **kargs)
    proc.args = args
    stdout, stderr = proc.communicate()
    if proc.returncode:
        if raise_on_error:
            pause("cmd fail: %s, pausing..." % (args))
            raise TestError("cmd fail:", args, proc.returncode, stdout, stderr)
        else:
            logging.debug("cmd fail: %s %d %s %s", str(args), proc.returncode, stdout, stderr)
    return stdout, stderr
Example #13
0
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
  if isinstance(cmd, str):
    args = shlex.split(cmd)
  else:
    args = cmd
  if trap_output:
    kargs['stdout'] = PIPE
    kargs['stderr'] = PIPE
  if options.verbose:
    print "run:", cmd, ', '.join('%s=%s' % x for x in kargs.iteritems())
  proc = Popen(args, **kargs)
  proc.args = args
  stdout, stderr = proc.communicate()
  if proc.returncode:
    if raise_on_error:
      raise TestError('cmd fail:', args, stdout, stderr)
    else:
      if options.verbose:
        print 'cmd fail:', args, stdout, stderr
  return stdout, stderr
Example #14
0
def run(cmd, trap_output=False, raise_on_error=True, **kargs):
    if isinstance(cmd, str):
        args = shlex.split(cmd)
    else:
        args = cmd
    if trap_output:
        kargs["stdout"] = PIPE
        kargs["stderr"] = PIPE
    if options.verbose:
        print "run:", cmd, ", ".join("%s=%s" % x for x in kargs.iteritems())
    proc = Popen(args, **kargs)
    proc.args = args
    stdout, stderr = proc.communicate()
    if proc.returncode:
        if raise_on_error:
            raise TestError("cmd fail:", args, stdout, stderr)
        else:
            if options.verbose:
                print "cmd fail:", args, stdout, stderr
    return stdout, stderr
Example #15
0
def background(*args):
    """Run executable in the backround, return the popen"""
    p = Popen(cmdline(*args), stdout=PIPE, stderr=sys.stderr)
    p.args = args               # Save arguments for debugging output
    return p