def _run_command(cmd,sched=None):
    """
    Run the command, either locally or via a scheduler

    Arguments:
      cmd (Command): command to run
      sched (SimpleScheduler): optional, a scheduler
        to use to run the command
    """
    print("Running %s" % cmd)
    if sched is None:
        retcode,output = cmd.subprocess_check_output()
    else:
        job = sched.submit(cmd)
        job.wait()
        retcode = job.exit_code
    return retcode