Verify command-line arguments and run commands
171079
def run():
    """"""
    args = parse_args()
    logging.basicConfig(level=logging.WARN)

    # to prevent flooding for sensu-check.
    logging.getLogger('kafka').setLevel(logging.CRITICAL)

    if args.controller_only and args.first_broker_only:
        terminate(
            status_code.WARNING,
            prepare_terminate_message(
                "Only one of controller_only and first_broker_only should be used",
            ),
            args.json,
        )

    if args.controller_only or args.first_broker_only:
        if args.broker_id is None:
            terminate(
                status_code.WARNING,
                prepare_terminate_message("broker_id is not specified"),
                args.json,
            )
        elif args.broker_id == -1:
            try:
                args.broker_id = get_broker_id(args.data_path)
            except Exception as e:
                terminate(
                    status_code.WARNING,
                    prepare_terminate_message("{}".format(e)),
                    args.json,
                )

    try:
        cluster_config = config.get_cluster_config(
            args.cluster_type,
            args.cluster_name,
            args.discovery_base_path,
        )
        code, msg = args.command(cluster_config, args)
    except ConfigurationError as e:
        terminate(
            status_code.CRITICAL,
            prepare_terminate_message("ConfigurationError {0}".format(e)),
            args.json,
        )

    terminate(code, msg, args.json)
1303219
def _run_command(cmd, options=(), env=None):
    '''
    
    '''
    params = [cmd]
    params.extend(options)
    return __salt__['cmd.run_all'](params, env=env, python_shell=False)
938804
def check_call(args, stdin=None, env=None):
    """"""
    log.debug('run: %s%s', args, ' {}'.format(env) if env else '')
    subprocess.check_call(args=args, stdin=stdin, env=env)
1089515
def run_command(args):
    """"""
    library_rc = 'pylintrc'
    test_rc = 'pylintrc.test'

    if os.path.exists(library_rc):
        os.remove(library_rc)

    if os.path.exists(test_rc):
        os.remove(test_rc)

    default_config = read_config(get_default_config())
    user_config = load_local_config(args.config)
    configuration = determine_final_config(user_config)

    make_rc(default_config, library_rc,
            additions=configuration.library_additions,
            replacements=configuration.library_replacements)
    make_rc(default_config, test_rc,
            additions=configuration.test_additions,
            replacements=configuration.test_replacements)

    lint_fileset(*args.library_filesets, rc_filename=library_rc,
                 description='Library')
    lint_fileset(*args.test_filesets, rc_filename=test_rc,
                 description='Test')
845585
def check_args(parser, args):
    """"""
    # Make sure only one action has been specified
    if len([a for a in [args.create, args.extract, args.verify, args.list,
                        args.list_detailed, args.hash, args.add_signature] if a
            is not None]) != 1:
        parser.error("Must specify something to do (one of -c, -x, -t, -T, -v, --hash, --add-signature)")

    if args.create and not args.files:
        parser.error("Must specify at least one file to add to marfile")

    if args.extract and args.compression not in (None, 'bz2', 'xz', 'auto'):  # pragma: nocover
        parser.error('Unsupported compression type')

    if args.create and args.compression not in (None, 'bz2', 'xz'):  # pragma: nocover
        parser.error('Unsupported compression type')

    if args.hash and len(args.files) != 1:
        parser.error("Must specify a file to output the hash for")
975124
def argument_run(self, sp_r):
		
		arg_run = []

		for line in sp_r:
			logging.debug("argument run: handling: " + str(line))
			if(line[1] == "data"):
				arg_run.append( (line[0], line[1], line[2], line[2].get_words(line[3])))
				continue
			if(line[1] == "command"):
				self.checkargs(line[0], line[2], line[3])
				arg_run.append( (line[0], line[1], line[2], [a for a in self.convert_args(line[2], line[3])]))
		return arg_run
182319
def main(self, args):
        '''

        '''
        if args.action:
            self.runcmd(args.action, args.arguments)
        else:
            self.cmdloop()
614469
def run(self, params):
        

        self.params = list(reversed(params))

        if not self.params:
            self.help()
            return

        while self.params:
            p = self.params.pop()

            if p in self.command:
                # If we got a known command, execute it.
                self.command[p](self)

            elif os.path.exists(p):
                # If we were given the name of an existing file, read it.
                self.read_moc(p)

            else:
                # Otherwise raise an error.
                raise CommandError('file or command {0} not found'.format(p))
214681
def check_arguments(cls, conf):
        
        # Perform sanity checking on CIDR
        utils.ip_check(conf['fixed_cidr'], netmask_expected=True)

        # Perform sanity checking on host list
        for host in conf['fixed_hosts'].split(":"):
            utils.ip_check(host)
837990
def mod_run_check(cmd_kwargs, onlyif, unless, creates):
    '''
    
    '''
    # never use VT for onlyif/unless executions because this will lead
    # to quote problems
    cmd_kwargs = copy.deepcopy(cmd_kwargs)
    cmd_kwargs['use_vt'] = False
    cmd_kwargs['bg'] = False

    if onlyif is not None:
        if isinstance(onlyif, six.string_types):
            cmd = __salt__['cmd.retcode'](onlyif, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd != 0:
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(onlyif, list):
            for entry in onlyif:
                cmd = __salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs)
                log.debug('Last command \'%s\' return code: %s', entry, cmd)
                if cmd != 0:
                    return {'comment': 'onlyif condition is false: {0}'.format(entry),
                            'skip_watch': True,
                            'result': True}
        elif not isinstance(onlyif, six.string_types):
            if not onlyif:
                log.debug('Command not run: onlyif did not evaluate to string_type')
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}

    if unless is not None:
        if isinstance(unless, six.string_types):
            cmd = __salt__['cmd.retcode'](unless, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd == 0:
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(unless, list):
            cmd = []
            for entry in unless:
                cmd.append(__salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs))
                log.debug('Last command return code: %s', cmd)
            if all([c == 0 for c in cmd]):
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif not isinstance(unless, six.string_types):
            if unless:
                log.debug('Command not run: unless did not evaluate to string_type')
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}

    if isinstance(creates, six.string_types) and os.path.exists(creates):
        return {'comment': '{0} exists'.format(creates),
                'result': True}
    elif isinstance(creates, list) and all([
        os.path.exists(path) for path in creates
    ]):
        return {'comment': 'All files in creates exist',
                'result': True}

    # No reason to stop, return True
    return True
1331428
def run_command(self, cmd, history=True, new_prompt=True):
        """"""
        if not cmd:
            cmd = ''
        else:
            if history:
                self.add_to_history(cmd)
        if not self.multithreaded:
            if 'input' not in cmd:
                self.interpreter.stdin_write.write(
                                                to_binary_string(cmd + '\n'))
                self.interpreter.run_line()
                self.refresh.emit()
            else:
                self.write(_('In order to use commands like "raw_input" '
                             'or "input" run Spyder with the multithread '
                             'option (--multithread) from a system terminal'),
                           error=True)
        else:
            self.interpreter.stdin_write.write(to_binary_string(cmd + '\n'))
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)
491118
def check_args(args):
    """"""
    # Checking that only VCF can have a - (stdout) as output
    if args.output_format not in _streamable_format and args.output == "-":
        logger.error("{} format cannot be streamed to standard output"
                     "".format(args.output_format))
        sys.exit(1)

    # Checking the file extensions
    if args.output_format == "vcf" and args.output != "-":
        if not args.output.endswith(".vcf"):
            args.output += ".vcf"

    elif args.output_format == "plink":
        if args.output.endswith(".bed"):
            args.output = args.output[:-4]
1185815
def _validate_args(env, args):
    """"""

    if all([args['cpu'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-c | --cpu] not allowed with [-f | --flavor]')

    if all([args['memory'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-m | --memory] not allowed with [-f | --flavor]')

    if all([args['dedicated'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-d | --dedicated] not allowed with [-f | --flavor]')

    if all([args['host_id'], args['flavor']]):
        raise exceptions.ArgumentError(
            '[-h | --host-id] not allowed with [-f | --flavor]')

    if all([args['userdata'], args['userfile']]):
        raise exceptions.ArgumentError(
            '[-u | --userdata] not allowed with [-F | --userfile]')

    image_args = [args['os'], args['image']]
    if all(image_args):
        raise exceptions.ArgumentError(
            '[-o | --os] not allowed with [--image]')

    while not any([args['os'], args['image']]):
        args['os'] = env.input("Operating System Code", default="", show_default=False)
        if not args['os']:
            args['image'] = env.input("Image", default="", show_default=False)
791361
def check_output(args):
    """"""
    log.debug('run: %s', args)
    out = subprocess.check_output(args=args).decode('utf-8')
    log.debug('out: %r', out)
    return out
405299
def _run_cmd(cmd):
    '''
    
    '''
    ret = {}
    env_vars = {
        'KAPACITOR_URL': _get_url(),
        'KAPACITOR_UNSAFE_SSL': __salt__['config.option']('kapacitor.unsafe_ssl', 'false'),
    }
    result = __salt__['cmd.run_all'](cmd, env=env_vars)

    if result.get('stdout'):
        ret['stdout'] = result['stdout']
    if result.get('stderr'):
        ret['stderr'] = result['stderr']
    ret['success'] = result['retcode'] == 0

    return ret
291090
def main(argv=None):
    
    # Get command line arguments, validate them, and normalize them
    opts = cmdparse.parse_args(argv)
    assert validate_opts.validate(opts)
    opts = normalize_opts.normalize(opts)

    if opts.verbose:
        # Update client: print input and output directories
        messages.print_input_output(opts)

    file_paths = fileparse.get_file_list(opts)
    assert validate_files.validate(file_paths, opts)

    if opts.verbose and opts.is_dir:
        # Update client: print files that will be parsed
        messages.print_files(opts, file_paths)

    # For now, only using default GitHub Markdown for parsing
    # Collect tag/anchor combinations
    collector = make_github_markdown_collector(opts)
    anchors, duplicate_tags = collector.collect(file_paths)
    assert validate_anchors.validate(anchors, duplicate_tags, opts)

    # Write files using previously found AnchorHub tags and generated anchors
    writer = make_github_markdown_writer(opts)
    counter = writer.write(file_paths, anchors, opts)

    if opts.verbose:
        if opts.is_dir:
            # Update client: print files that had modifications
            messages.print_modified_files(opts, anchors)
        # Print summary statistics
        messages.print_summary_stats(counter)