Executes the 'proposal vote' subcommand.  Given a key file, a proposal
    id and a vote value, it generates a batch of sawtooth_settings transactions
    in a BatchList instance.  The BatchList is file or submitted to a
    validator.
557904
def _do_config_proposal_vote(args):
    
    signer = _read_signer(args.key)
    rest_client = RestClient(args.url)

    proposals = _get_proposals(rest_client)

    proposal = None
    for candidate in proposals.candidates:
        if candidate.proposal_id == args.proposal_id:
            proposal = candidate
            break

    if proposal is None:
        raise CliException('No proposal exists with the given id')

    for vote_record in proposal.votes:
        if vote_record.public_key == signer.get_public_key().as_hex():
            raise CliException(
                'A vote has already been recorded with this signing key')

    txn = _create_vote_txn(
        signer,
        args.proposal_id,
        proposal.proposal.setting,
        args.vote_value)
    batch = _create_batch(signer, [txn])

    batch_list = BatchList(batches=[batch])

    rest_client.send_batches(batch_list)
1170606
public void runBatchFile(File batchFile) throws IOException {
		final BufferedReader reader = new BufferedReader(new FileReader(batchFile));
		try {
			doLines(0, new LineReader() {
				@Override
				public String getNextLine(String prompt) throws IOException {
					return reader.readLine();
				}
			}, true);
		} finally {
			reader.close();
		}
	}
423579
def _check_required_settings(batches):
    """"""
    required_settings = [
        'sawtooth.consensus.algorithm.name',
        'sawtooth.consensus.algorithm.version']

    for batch in batches:
        for txn in batch.transactions:
            txn_header = TransactionHeader()
            txn_header.ParseFromString(txn.header)
            if txn_header.family_name == 'sawtooth_settings':
                settings_payload = SettingsPayload()
                settings_payload.ParseFromString(txn.payload)
                if settings_payload.action == SettingsPayload.PROPOSE:
                    proposal = SettingProposal()
                    proposal.ParseFromString(settings_payload.data)
                    if proposal.setting in required_settings:
                        required_settings.remove(proposal.setting)

    if required_settings:
        raise CliException(
            'The following setting(s) are required at genesis, but were not '
            'included in the genesis batches: {}'.format(required_settings))
1058829
def execute(self):
        
        if not self.config.pr:
            raise NotPullRequestException

        logger.debug('Using the following configuration:')
        for name, value in self.config.as_dict().items():
            logger.debug('  - {}={}'.format(name, repr(value)))

        logger.info('Running Lintly against PR #{} for repo {}'.format(self.config.pr, self.project))

        parser = PARSERS.get(self.config.format)
        self._all_violations = parser.parse_violations(self.linter_output)
        logger.info('Lintly found violations in {} files'.format(len(self._all_violations)))

        diff = self.get_pr_diff()
        patch = self.get_pr_patch(diff)
        self._diff_violations = self.find_diff_violations(patch)
        logger.info('Lintly found diff violations in {} files'.format(len(self._diff_violations)))

        self.post_pr_comment(patch)
        self.post_commit_status()
268343
def submit(self, method, method_args=(), method_kwargs={}, done_callback=None, done_kwargs={}, loop=None):
        '''
        
        '''
        _future = self.pool.submit(method, *method_args, **method_kwargs)
        self.current_id += 1
        if done_callback:
            _future.add_done_callback(lambda _f:done_callback(_f,loop,**done_kwargs))#done kwargs, hardcoded kwargs
        self.request_pool[self.current_id] = _future
        return self.current_id, _future
958463
def run(cmd, *args, **kwargs):
    """"""
    log.info('> ' + list2cmdline(cmd))
    kwargs.setdefault('cwd', here)
    kwargs.setdefault('shell', sys.platform == 'win32')
    if not isinstance(cmd, list):
        cmd = cmd.split()
    return check_call(cmd, *args, **kwargs)
230804
def applyCommand(self):
        
        # generate the command information
        cursor      = self.textCursor()
        cursor.movePosition(cursor.EndOfLine)
        
        line        = projex.text.nativestring(cursor.block().text())
        at_end      = cursor.atEnd()
        modifiers   = QApplication.instance().keyboardModifiers()
        mod_mode    = at_end or modifiers == Qt.ShiftModifier
        
        # test the line for information
        if mod_mode and line.endswith(':'):
            cursor.movePosition(cursor.EndOfLine)
            
            line = re.sub('^>>> ', '', line)
            line = re.sub('^\.\.\. ', '', line)
            count = len(line) - len(line.lstrip()) + 4
            
            self.insertPlainText('\n... ' + count * ' ')
            return False
        
        elif mod_mode and line.startswith('...') and \
            (line.strip() != '...' or not at_end):
            cursor.movePosition(cursor.EndOfLine)
            line = re.sub('^\.\.\. ', '', line)
            count = len(line) - len(line.lstrip())
            self.insertPlainText('\n... ' + count * ' ')
            return False
        
        # if we're not at the end of the console, then add it to the end
        elif line.startswith('>>>') or line.startswith('...'):
            # move to the top of the command structure
            line = projex.text.nativestring(cursor.block().text())
            while line.startswith('...'):
                cursor.movePosition(cursor.PreviousBlock)
                line = projex.text.nativestring(cursor.block().text())
            
            # calculate the command
            cursor.movePosition(cursor.EndOfLine)
            line = projex.text.nativestring(cursor.block().text())
            ended = False
            lines = []
            
            while True:
                # add the new block
                lines.append(line)
                
                if cursor.atEnd():
                    ended = True
                    break
                
                # move to the next line
                cursor.movePosition(cursor.NextBlock)
                cursor.movePosition(cursor.EndOfLine)
                
                line = projex.text.nativestring(cursor.block().text())
                
                # check for a new command or the end of the command
                if not line.startswith('...'):
                    break
            
            command = '\n'.join(lines)
            
            # if we did not end up at the end of the command block, then
            # copy it for modification
            if not (ended and command):
                self.waitForInput()
                self.insertPlainText(command.replace('>>> ', ''))
                cursor.movePosition(cursor.End)
                return False
        
        else:
            self.waitForInput()
            return False
        
        self.executeCommand(command)
        return True
929251
def __File_Command_lineEdit_set_ui(self):
        

        # Adding settings key if it doesn't exists.
        self.__settings.get_key(self.__settings_section, "file_command").isNull() and \
        self.__settings.set_key(self.__settings_section, "file_command", self.__file_command)

        file_command = self.__settings.get_key(self.__settings_section, "file_command").toString()
        LOGGER.debug("> Setting '{0}' with value '{1}'.".format("File_Command_lineEdit",
                                                                file_command))
        self.__file_command = file_command
        self.File_Command_lineEdit.setText(file_command)
729298
public void batchCommitted()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(this, tc, "batchCommitted");
      
    if (batchSendList.size() != 0)
    {
      try
      {
        sendMsgs(batchSendList, false);
      }
      catch (SIResourceException e)
      {
        //FFDC
        FFDCFilter.processException(
          e,
          "com.ibm.ws.sib.processor.gd.SourceStream.batchCommitted",
          "1:2590:1.138",
          this);

        SibTr.exception(tc, e);
      }
    }
    
    // Empty list ready for use by next batch
    batchList.clear();
    batchSendList.clear();
    
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "batchCommitted");
  }
207721
def run(self):
        '''
        
        '''
        self._update_opts()
        cmd = self.opts['fun']

        veri = None
        ret = None
        try:
            if cmd in ('accept', 'reject', 'delete'):
                ret = self._run_cmd('name_match')
                if not isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                    return ret
                ret = self._filter_ret(cmd, ret)
                if not ret:
                    self._print_no_match(cmd, self.opts['match'])
                    return
                print('The following keys are going to be {0}ed:'.format(cmd.rstrip('e')))
                salt.output.display_output(ret, 'key', opts=self.opts)

                if not self.opts.get('yes', False):
                    try:
                        if cmd.startswith('delete'):
                            veri = input('Proceed? [N/y] ')
                            if not veri:
                                veri = 'n'
                        else:
                            veri = input('Proceed? [n/Y] ')
                            if not veri:
                                veri = 'y'
                    except KeyboardInterrupt:
                        raise SystemExit("\nExiting on CTRL-c")
                # accept/reject/delete the same keys we're printed to the user
                self.opts['match_dict'] = ret
                self.opts.pop('match', None)
                list_ret = ret

            if veri is None or veri.lower().startswith('y'):
                ret = self._run_cmd(cmd)
                if cmd in ('accept', 'reject', 'delete'):
                    if cmd == 'delete':
                        ret = list_ret
                    for minions in ret.values():
                        for minion in minions:
                            print('Key for minion {0} {1}ed.'.format(minion,
                                                                     cmd.rstrip('e')))
                elif isinstance(ret, dict):
                    salt.output.display_output(ret, 'key', opts=self.opts)
                else:
                    salt.output.display_output({'return': ret}, 'key', opts=self.opts)
        except salt.exceptions.SaltException as exc:
            ret = '{0}'.format(exc)
            if not self.opts.get('quiet', False):
                salt.output.display_output(ret, 'nested', self.opts)
        return ret
600258
def action_add(self):
        

        # prepare values for new shortcut
        path = self.args['--workdir'] or os.getcwd()
        name = self.args['<name>']
        cmd = self.args['<command>']

        overwrite = self.args['--force']

        # check for conflicts in DB
        if not overwrite and self.shortcut_exists(name):
            print_err('The shortcut "%s" already exists.' % name)
            return

        # if cmd has arguments, extract the command only
        cmd_parts = [x.strip() for x in cmd.split(' ')]
        cmd_real = cmd_parts[0]
        cmd_tail = ' '.join(cmd_parts[1:])

        # if cmd_real starts with ./, remove that
        if cmd_real.startswith('./'):
            cmd_real = cmd_real[2:]

        # path to the file (if it's in the folder)
        localfile = os.path.abspath(os.path.join(path, cmd_real))

        # check if the file is present at the path given
        if os.path.isfile(localfile):

            # file extension
            ext = os.path.splitext(cmd_real)[1]

            # check for exacutable bit
            # jar is executable, but cannot be run directly
            if os.access(localfile, os.X_OK) and not ext == '.jar':
                # file is executable
                cmd = ''

                if not cmd_real.startswith('/'):
                    cmd = './'

                cmd = cmd + cmd_real + ' ' + cmd_tail

            else:
                # not executable
                # try to find interpreter for the file

                interpreter = {
                    '.py': 'python',
                    '.rb': 'ruby',
                    '.js': 'node',
                    '.pl': 'perl',
                    '.sh': 'sh',
                    '.php': 'php',
                    '.jar': 'java -jar',
                }.get(ext, None)

                # check if interpreter was found
                if interpreter is None:

                    msg = ('Could not make a shortcut to "%s":'
                           + '\n - not executable & unknown extension.') % localfile

                    print_err(msg)
                    return

                cmd = str(interpreter) + ' ' + \
                    str(cmd_real) + ' ' + str(cmd_tail)
        else:
            # use cmd, as given.
            pass

        if overwrite:
            self.db_exec('''
                    DELETE FROM shortcuts WHERE name=?
                    ''', (name,))
        # save to DB
        self.db_exec('''
            INSERT INTO shortcuts (name, path, command)
            VALUES (?, ?, ?)
            ''', (str(name), str(path), str(cmd)))

        # show OK message
        msg = ('Shortcut "%s" has been created.\n'
               + self.shortcut_str(path, cmd)) % name

        print_msg(msg)
571361
def run_command(command, args):
    
    for category, commands in iteritems(command_categories):
        for existing_command in commands:
            if existing_command.match(command):
                existing_command.run(args)
820639
def run
      command = ['flay', '--mass', @config['mass_threshold'].to_s, '--fuzzy', @config['fuzzy'].to_s]
      # Use a more liberal detection method
      command += ['--liberal'] if @config['liberal']
      messages = []
      # Run the command for each file
      applicable_files.each do |file|
        result = execute(command, args: [file])
        results = result.stdout.split("\n\n")
        results.shift
        unless results.empty?
          error_message = results.join("\n").gsub(/^\d+\)\s*/, '')
          message = Overcommit::Hook::Message.new(:error, nil, nil, error_message)
          messages << message
        end
      end
      messages
    end
365298
def execute(self):
        
        last_operation = len(self._operations) - 1
        for i, operation in enumerate(self._operations):
            command = self._cmd(operation)

            if command.execute() is False:
                return False
            else:
                action = command.execute_post_archive_actions
                self._post_archive_actions.append(action)

                if i == last_operation:
                    return True
364715
def call(cmd, input=None, assert_zero_exit_status=True, warn_on_non_zero_exist_status=False, **kwargs):
    
    if (not kwargs.get('shell')) and isinstance(cmd, basestring):
        raise ValueError('cmd should be list or tuple, not a string: %r' % cmd)
    result = SubprocessResult.call(cmd, input=input, **kwargs)
    if assert_zero_exit_status and result.ret != 0:
        raise SubprocessError(result)

    if warn_on_non_zero_exist_status and result.ret != 0:
        logger.warn('subprocess failed %r' % result)

    return result
1284770
public final void batchUpdateWidget(final Runnable action) {
        _batchUpdateCounter++;
        try {
            action.run();
        } catch (final RuntimeException e) {
            logger.error("Exception occurred in widget batch update, fireValueChanged() will not be invoked", e);
            throw e;
        } finally {
            _batchUpdateCounter--;
        }
        if (_batchUpdateCounter == 0) {
            onBatchFinished();
        }
    }
196237
def propose(self):
        
        # generate a list of all the untried candidate pipelines
        candidates = self._get_candidates()

        # get_candidates() returns None when every possibility has been tried
        if candidates is None:
            return None

        # predict() returns a predicted values for each candidate
        predictions = self.predict(candidates)

        # acquire() evaluates the list of predictions, selects one, and returns
        # its index.
        idx = self._acquire(predictions)
        return candidates[idx]