Submit shell command to SGE queue via `qsub`
492271
def _build_qsub_command(cmd, job_name, outfile, errfile, pe, n_cpu):
    """"""
    qsub_template = """echo {cmd} | qsub -o ":{outfile}" -e ":{errfile}" -V -r y -pe {pe} {n_cpu} -N {job_name}"""
    return qsub_template.format(
        cmd=cmd, job_name=job_name, outfile=outfile, errfile=errfile,
        pe=pe, n_cpu=n_cpu)
586547
def submit(self, func, *args, **kwargs):
        
        self.op_sequence += 1
        self.sqs.send_message(
            QueueUrl=self.map_queue,
            MessageBody=utils.dumps({'args': args, 'kwargs': kwargs}),
            MessageAttributes={
                'sequence_id': {
                    'StringValue': str(self.op_sequence),
                    'DataType': 'Number'},
                'op': {
                    'StringValue': named(func),
                    'DataType': 'String',
                },
                'ser': {
                    'StringValue': 'json',
                    'DataType': 'String'}}
        )

        self.futures[self.op_sequence] = f = SQSFuture(
            self.op_sequence)
        return f
20413
def send_simple_command(self, cmd):
        """"""
        pkt = MqttPkt()
        
        pkt.command = cmd
        pkt.remaining_length = 0
        
        ret = pkt.alloc()
        if ret != NC.ERR_SUCCESS:
            return ret
        
        return self.packet_queue(pkt)
793978
def submit(cluster_config_file, docker, screen, tmux, stop, start,
           cluster_name, port_forward, script, script_args):
    
    assert not (screen and tmux), "Can specify only one of `screen` or `tmux`."

    if start:
        create_or_update_cluster(cluster_config_file, None, None, False, False,
                                 True, cluster_name)

    target = os.path.join("~", os.path.basename(script))
    rsync(cluster_config_file, script, target, cluster_name, down=False)

    cmd = " ".join(["python", target] + list(script_args))
    exec_cluster(cluster_config_file, cmd, docker, screen, tmux, stop, False,
                 cluster_name, port_forward)
265790
def run_command(self, command, message):
        
        proc = subprocess.Popen([
            'echo \'%s\' | %s' % (fedmsg.encoding.dumps(message), command)
        ], shell=True, executable='/bin/bash')
        return proc.wait()
634417
def run(configobj=None):
    
    acssum(configobj['input'],
           configobj['output'],
           exec_path=configobj['exec_path'],
           time_stamps=configobj['time_stamps'],
           verbose=configobj['verbose'],
           quiet=configobj['quiet']
           )
376300
def send_command(self, command):
        """"""
        if self._pipe_commands:
            self._pipe_commands.send(command)
        else:
            if self.shutdown:
                # Stop delivering messages in shutdown.
                self.log.info(
                    "During shutdown no command queue pipe found for command\n%s",
                    str(command),
                )
            else:
                self.log.error(
                    "No command queue pipe found for command\n%s", str(command)
                )
625918
def submit(script, workspace, **params):
    """"""
    from klab import cluster, process

    # Make sure the rosetta symlink has been created.

    if not os.path.exists(workspace.rosetta_dir):
        raise pipeline.RosettaNotFound(workspace)

    # Parse some job parameters for the keyword arguments.

    params = dict((k, v) for k, v in params.items() if v is not None)
    test_run = params.get('test_run', False)
    nstruct = params.get('nstruct')
    max_runtime = params.get('max_runtime', '6:00:00')
    max_memory = params.get('max_memory', '1G')

    if test_run:
        nstruct = 1

    if nstruct is None:
        raise TypeError("submit() requires the keyword argument 'nstruct' for production runs.")

    # Use Jinja to render the XML script that will be passed to rosetta.

    finalize_protocol(workspace, params)

    # Submit the job and put it immediately into the hold state.

    qsub_command = 'qsub', '-h', '-cwd',
    qsub_command += '-o', workspace.log_dir,
    qsub_command += '-j', 'y',
    qsub_command += '-t', '1-{0}'.format(nstruct),
    qsub_command += '-l', 'h_rt={0}'.format(max_runtime),
    qsub_command += '-l', 'mem_free={0}'.format(max_memory),
    qsub_command += pipeline.big_job_path(script),
    qsub_command += workspace.focus_dir,

    status = process.check_output(qsub_command)
    status_pattern = re.compile(r'Your job-array (\d+).[0-9:-]+ \(".*"\) has been submitted')
    status_match = status_pattern.match(status)

    if not status_match:
        print status
        sys.exit()

    # Figure out the job id, then make a params file specifically for it.

    job_id = status_match.group(1)

    with open(workspace.job_info_path(job_id), 'w') as file:
        json.dump(params, file)

    # Release the hold on the job.

    qrls_command = 'qrls', job_id
    process.check_output(qrls_command)
    print status,
453996
def submit_commands(self, devices, execution):
        
        fs = []
        for device in devices:
            if device[key_id_] != self.device_id:
                logging.warning('Ignoring command for unknown device: %s'
                                % device[key_id_])
                continue
            if not execution:
                logging.warning('Ignoring noop execution')
                continue
            for command in execution:
                f = self.executor.submit(
                    self.dispatch_command, **command
                )
                fs.append(f)
        return fs
147298
def submit_string(string, **kwargs)
      Tempfile.open('qsub.') do |f|
        f.write string.to_s
        f.close
        submit_script(f.path, **kwargs)
      end
    end
829990
def make_submit_job(shell, output, job_type):
    
    run_cmd = [shell, output]
    submit_command = Command(alias=PIPELINE_ALIAS, cmds=run_cmd)
    submit_job = get_job(submit_command, job_type)
    submit_job.make()
    return submit_job
461340
def trigger(queue, user=None, group=None, mode=None, trigger=_c.FSQ_TRIGGER):
    ''''''
    # default our owners and mode
    user, group, mode = _dflts(user, group, mode)
    trigger_path = fsq_path.trigger(queue, trigger=trigger)
    created = False
    try:
        # mkfifo is incapable of taking unicode, coerce back to str
        try:
            os.mkfifo(trigger_path.encode(_c.FSQ_CHARSET), mode)
            created = True
        except (OSError, IOError, ), e:
            # if failure not due to existence, rm and bail
            if e.errno != errno.EEXIST:
                raise e

        # don't open and fchown here, as opening WRONLY without an open
        # reading fd will hang, opening RDONLY will zombie if we don't
        # flush, and intercepts triggers meant to go elsewheres
        os.chmod(trigger_path, mode)
        if user is not None or group is not None:
            os.chown(trigger_path, *uid_gid(user, group, path=trigger_path))
    except (OSError, IOError, ), e:
        # only rm if we created and failed, otherwise leave it and fail
        if created:
            _cleanup(trigger_path, e)
        _raise(trigger_path, e)
491020
def exec_command(self, cmd, tmp_path, sudo_user, sudoable=False, executable='/bin/sh'):
        '''  '''

        bufsize = 4096
        try:
            chan = self.ssh.get_transport().open_session()
        except Exception, e:
            msg = "Failed to open session"
            if len(str(e)) > 0:
                msg += ": %s" % str(e)
            raise errors.AnsibleConnectionFailed(msg)
        chan.get_pty()

        if not self.runner.sudo or not sudoable:
            if executable:
                quoted_command = executable + ' -c ' + pipes.quote(cmd)
            else:
                quoted_command = cmd
            vvv("EXEC %s" % quoted_command, host=self.host)
            chan.exec_command(quoted_command)
        else:
            shcmd, prompt = utils.make_sudo_cmd(sudo_user, executable, cmd)
            vvv("EXEC %s" % shcmd, host=self.host)
            sudo_output = ''
            try:
                chan.exec_command(shcmd)
                if self.runner.sudo_pass:
                    while not sudo_output.endswith(prompt):
                        chunk = chan.recv(bufsize)
                        if not chunk:
                            if 'unknown user' in sudo_output:
                                raise errors.AnsibleError(
                                    'user %s does not exist' % sudo_user)
                            else:
                                raise errors.AnsibleError('ssh connection ' +
                                    'closed waiting for password prompt')
                        sudo_output += chunk
                    chan.sendall(self.runner.sudo_pass + '\n')
            except socket.timeout:
                raise errors.AnsibleError('ssh timed out waiting for sudo.\n' + sudo_output)

        stdout = ''.join(chan.makefile('rb', bufsize))
        stderr = ''.join(chan.makefile_stderr('rb', bufsize))
        return (chan.recv_exit_status(), '', stdout, stderr)
435463
def pbs_submit(script, queue, headers, resources, envvars)
        attribs = []
        headers.each do |name, value|
          attribs << { name: name, value: value }
        end
        resources.each do |rsc, value|
          attribs << { name: :Resource_List, resource: rsc, value: value }
        end
        unless envvars.empty?
          attribs << {
            name: :Variable_List,
            value: envvars.map {|k,v| "#{k}=#{v}"}.join(",")
          }
        end

        connect do |cid|
          attropl = Torque::Attropl.from_list attribs
          Torque.pbs_submit cid, attropl, script, queue, nil
        end
      end
15701
def start(queue, profile=None, tag='salt/engine/sqs', owner_acct_id=None):
    '''
    
    '''
    if __opts__.get('__role') == 'master':
        fire_master = salt.utils.event.get_master_event(
            __opts__,
            __opts__['sock_dir'],
            listen=False).fire_event
    else:
        fire_master = __salt__['event.send']

    message_format = __opts__.get('sqs.message_format', None)

    sqs = _get_sqs_conn(profile)
    q = None
    while True:
        if not q:
            q = sqs.get_queue(queue, owner_acct_id=owner_acct_id)
            q.set_message_class(boto.sqs.message.RawMessage)

        _process_queue(q, queue, fire_master, tag=tag, owner_acct_id=owner_acct_id, message_format=message_format)
1103249
def call(self, args, devnull=False):
        
        if self.debug:
            click.echo(subprocess.list2cmdline(args))
            click.confirm('Continue?', default=True, abort=True)
        try:
            kwargs = {}
            if devnull:
                # Pipe to /dev/null (or equivalent).
                kwargs['stderr'] = subprocess.STDOUT
                kwargs['stdout'] = self.FNULL
            ret_code = subprocess.call(args, **kwargs)
        except subprocess.CalledProcessError:
            return False
        return ret_code
858000
function runNpmTask(taskName, directory) {

    console.log(`running ${taskName} in ${directory}`);

    var opts = {
        cwd: directory,
        env: process.env,
        stdio: 'inherit',
        shell: true
    };

    args = taskName.split(' ');

    var proc = cp.spawnSync('npm', args, opts);

    if (proc.error) {
        process.stderr.write(proc.error.toString());
    }

    return proc.status;
}