Parse the <master> argument.

        @param master_arg: the <master> argument to parse

        @return: tuple of master's host and port
        @raise UsageError: on errors parsing the argument
168426
def validateMasterArgument(self, master_arg):
        
        if master_arg[:5] == "http:":
            raise usage.UsageError("<master> is not a URL - do not use URL")

        if ":" not in master_arg:
            master = master_arg
            port = 9989
        else:
            master, port = master_arg.split(":")

        if not master:
            raise usage.UsageError("invalid <master> argument '{}'".format(
                                   master_arg))
        try:
            port = int(port)
        except ValueError:
            raise usage.UsageError("invalid master port '{}', "
                                   "needs to be a number".format(port))

        return master, port
939972
public alluxio.grpc.NetAddress getMasterAddress() {
    return masterAddress_ == null ? alluxio.grpc.NetAddress.getDefaultInstance() : masterAddress_;
  }
501541
def _collect_masters_map(self, response):
        '''
        
        '''
        while True:
            try:
                data, addr = self._socket.recvfrom(0x400)
                if data:
                    if addr not in response:
                        response[addr] = []
                    response[addr].append(data)
                else:
                    break
            except Exception as err:
                if not response:
                    self.log.error('Discovery master collection failure: %s', err)
                break
814903
def master_key_required(func):
    ''''''
    def ret(obj, *args, **kw):
        conn = ACCESS_KEYS
        if not (conn and conn.get('master_key')):
            message = '%s requires the master key' % func.__name__
            raise core.ParseError(message)
        func(obj, *args, **kw)
    return ret
872478
def _parse_execution_args(execution_args):
        
        if not isinstance(execution_args, (list, tuple)):
            raise ValueError("Parameter 'execution_args' should be a list")

        return [EOWorkflow.parse_input_args(input_args) for input_args in execution_args]
386849
def main():
    
    parser = argparse.ArgumentParser(description=main.__doc__, add_help=True)
    parser.add_argument('-M', '--master_key', dest='master_key', help='Path  to the master key ' +
                        'used for the encryption.  Data is transferred without encryption if this' +
                        'is not provided.', type=str, required=False, default=None)
    parser.add_argument('-B', '--bucket', dest='bucket', help='S3 bucket.', type=str, required=True)
    parser.add_argument('-R', '--remote_dir', dest='remote_dir', help='Pseudo directory within ' +
                        'the bucket to store the file(s).  NOTE: Folder structure below ' +
                        'REMOTE_DIR will be retained.', type=str, required=False, default='')
    parser.add_argument('data', help='File(s) or folder(s) to transfer to S3.', type=str, nargs='+')
    params = parser.parse_args()
    # Input handling
    if params.master_key and not os.path.exists(params.master_key):
        raise InputParameterError('The master key was not found at ' +
                                  params.master_key)
    #  If the user doesn't have ~/.boto , it doesn't even make sense to go ahead
    if not os.path.exists(os.path.expanduser('~/.boto')):
        raise RuntimeError('~/.boto not found')
    # Ensure that the remote directory doesn't start with a /
    if params.remote_dir.startswith('/'):
        raise InputParameterError('The remote dir cannot start with a \'/\'')

    # Process each of the input arguments.
    for datum in params.data:
        datum = os.path.abspath(datum)
        if not os.path.exists(datum):
            print('ERROR: %s could not be found.' % datum, file=sys.stderr)
            continue
        write_to_s3(datum, params.master_key, params.bucket, params.remote_dir)
    return None
551356
def parse_args():
    
    parser = ArgumentParser(description="PyTorch distributed training launch "
                                        "helper utilty that will spawn up "
                                        "multiple distributed processes")

    # Optional arguments for the launch helper
    parser.add_argument("--nnodes", type=int, default=1,
                        help="The number of nodes to use for distributed "
                             "training")
    parser.add_argument("--node_rank", type=int, default=0,
                        help="The rank of the node for multi-node distributed "
                             "training")
    parser.add_argument("--nproc_per_node", type=int, default=1,
                        help="The number of processes to launch on each node, "
                             "for GPU training, this is recommended to be set "
                             "to the number of GPUs in your system so that "
                             "each process can be bound to a single GPU.")
    parser.add_argument("--master_addr", default="127.0.0.1", type=str,
                        help="Master node (rank 0)'s address, should be either "
                             "the IP address or the hostname of node 0, for "
                             "single node multi-proc training, the "
                             "--master_addr can simply be 127.0.0.1")
    parser.add_argument("--master_port", default=29500, type=int,
                        help="Master node (rank 0)'s free port that needs to "
                             "be used for communciation during distributed "
                             "training")
    parser.add_argument('--no_hyperthreads', action='store_true',
                        help='Flag to disable binding to hyperthreads')
    parser.add_argument('--no_membind', action='store_true',
                        help='Flag to disable memory binding')

    # non-optional arguments for binding
    parser.add_argument("--nsockets_per_node", type=int, required=True,
                        help="Number of CPU sockets on a node")
    parser.add_argument("--ncores_per_socket", type=int, required=True,
                        help="Number of CPU cores per socket")

    # positional
    parser.add_argument("training_script", type=str,
                        help="The full path to the single GPU training "
                             "program/script to be launched in parallel, "
                             "followed by all the arguments for the "
                             "training script")

    # rest from the training program
    parser.add_argument('training_script_args', nargs=REMAINDER)
    return parser.parse_args()
282759
private void printMetaMasterInfo() throws IOException {
    mIndentationLevel++;
    Set<MasterInfoField> masterInfoFilter = new HashSet<>(Arrays
        .asList(MasterInfoField.LEADER_MASTER_ADDRESS, MasterInfoField.WEB_PORT,
            MasterInfoField.RPC_PORT, MasterInfoField.START_TIME_MS,
            MasterInfoField.UP_TIME_MS, MasterInfoField.VERSION,
            MasterInfoField.SAFE_MODE, MasterInfoField.ZOOKEEPER_ADDRESSES));
    MasterInfo masterInfo = mMetaMasterClient.getMasterInfo(masterInfoFilter);

    print("Master Address: " + masterInfo.getLeaderMasterAddress());
    print("Web Port: " + masterInfo.getWebPort());
    print("Rpc Port: " + masterInfo.getRpcPort());
    print("Started: " + CommonUtils.convertMsToDate(masterInfo.getStartTimeMs(),
        mDateFormatPattern));
    print("Uptime: " + CommonUtils.convertMsToClockTime(masterInfo.getUpTimeMs()));
    print("Version: " + masterInfo.getVersion());
    print("Safe Mode: " + masterInfo.getSafeMode());

    List<String> zookeeperAddresses = masterInfo.getZookeeperAddressesList();
    if (zookeeperAddresses == null || zookeeperAddresses.isEmpty()) {
      print("Zookeeper Enabled: false");
    } else {
      print("Zookeeper Enabled: true");
      print("Zookeeper Addresses: ");
      mIndentationLevel++;
      for (String zkAddress : zookeeperAddresses) {
        print(zkAddress);
      }
      mIndentationLevel--;
    }
  }
908522
def parse_args():
    
    parser = argparse.ArgumentParser(description="Converts, and downloads a vm by name from vCenter to OVF in specified"
                                                 " directory, then uploads the image as an AMI. AMI will be uploaded "
                                                 "using specified AWS profile, to specified regions. ")
    parser.add_argument('-i', '--vcenter_host', type=str, required=True, help='Hostname or Ip of vCenter API of VM')
    parser.add_argument('-u', '--vcenter_user', type=str, required=True, help='Username for vCenter authentication')
    parser.add_argument('-p', '--vcenter_pass', type=str, required=True, help='Password for authentication to vCenter API')
    parser.add_argument('-n', '--vm_name', type=str, required=True, help='Name of the VM in vCenter')
    parser.add_argument('-d', '--directory', type=str, default=tempfile.mkdtemp(),
                        help='Directory to save the vmdk temp file (defaults to temp location')
    parser.add_argument('-w', '--vcenter_port', type=str, default='443',
                        help='Port to use for communication to vcenter api. Default is 443')
    args = parser.parse_args()
    validate_args(args)
    return args
1099305
def parse(self, arguments=None):
        
        arguments = self.arguments or arguments
        # FIXME: prep/normalize arguments in __init__
        # Split arguments if given as string and run the parser
        if isinstance(arguments, basestring):
            arguments = utils.split(arguments)

        # run the wrapped argparser command to gather user set arg values
        # FROM: https://docs.python.org/3/library/argparse.html
        # Sometimes a script may only parse a few of the command-line
        # arguments, passing the remaining arguments on to another script or
        # program.  In these cases, the parse_known_args() method can be
        # useful. It works much like parse_args() except that it does not
        # produce an error when extra arguments are present. Instead, it
        # returns a two item tuple containing the populated namespace and
        # the list of remaining argument strings.
        opts, _arguments = self.parser.parse_known_args(arguments)

        if not opts.config_file:
            opts.config_file = os.path.expanduser(DEFAULT_IDID_CONFIG)
        opts.config = Configuration().from_file(opts.config_file)
        # alias shortcut
        self.config = opts.config

        # if we're passing arguments in as a string we might get \n's or null
        # strings '' that we want to be sure to ignore
        _arguments = filter(
            lambda x: x if x else None, [_.strip() for _ in _arguments if _])

        # Now let the subclass parse the remaining special opts that
        # weren't consumed by default argparser
        opts = self._parse(opts, _arguments)

        return opts
830637
def parse_args(args):
    
    parser = argparse.ArgumentParser(
        description='Starts the REST API application and connects to a '
        'specified validator.')

    parser.add_argument('-B', '--bind',
                        help='identify host and port for API to run on \
                        default: http://localhost:8008)',
                        action='append')
    parser.add_argument('-C', '--connect',
                        help='specify URL to connect to a running validator')
    parser.add_argument('-t', '--timeout',
                        help='set time (in seconds) to wait for validator \
                        response')
    parser.add_argument('--client-max-size',
                        type=int,
                        help='the max size (in bytes) of a request body')
    parser.add_argument('-v', '--verbose',
                        action='count',
                        default=0,
                        help='enable more verbose output to stderr')
    parser.add_argument('--opentsdb-url',
                        help='specify host and port for Open TSDB database \
                        used for metrics')
    parser.add_argument('--opentsdb-db',
                        help='specify name of database for storing metrics')

    try:
        version = pkg_resources.get_distribution(DISTRIBUTION_NAME).version
    except pkg_resources.DistributionNotFound:
        version = 'UNKNOWN'

    parser.add_argument(
        '-V', '--version',
        action='version',
        version=(DISTRIBUTION_NAME + ' (Hyperledger Sawtooth) version {}')
        .format(version),
        help='display version information')

    return parser.parse_args(args)
785712
def use_master_key(flag=True):
    
    global USE_MASTER_KEY
    if not flag:
        USE_MASTER_KEY = False
        return
    if not MASTER_KEY:
        raise RuntimeError('LeanCloud SDK master key not specified')
    USE_MASTER_KEY = True
835014
def master_call(self, **kwargs):
        '''
        
        '''
        load = kwargs
        load['cmd'] = self.client
        channel = salt.transport.client.ReqChannel.factory(self.opts,
                                                           crypt='clear',
                                                           usage='master_call')
        try:
            ret = channel.send(load)
        finally:
            channel.close()
        if isinstance(ret, collections.Mapping):
            if 'error' in ret:
                salt.utils.error.raise_error(**ret['error'])
        return ret
775371
def parse_args(self, argv=None):
        
        arg_input = shlex.split(argv) if argv is not None else None
        self.get_or_create_session()
        return self.argparser.parse_args(arg_input)
684273
def argparser():
    
    parser = argparse.ArgumentParser(description=__description__)
    sparser = parser.add_subparsers()
    add_cookbook_mgmt_options(sparser)
    add_role_options(sparser)
    add_github_hook_options(sparser)
    add_jenkins_job_options(sparser)
    return parser
1247631
def _add_parser_arguments_git(self, subparsers):
        
        subparsers.add_parser(
            "git-clone",
            help="Clone all defined data repositories if they dont exist.")

        subparsers.add_parser(
            "git-push",
            help="Add all files to data repositories, commit, and push.")

        subparsers.add_parser(
            "git-pull",
            help="'Pull' all data repositories.")

        subparsers.add_parser(
            "git-reset-local",
            help="Hard reset all data repositories using local 'HEAD'.")

        subparsers.add_parser(
            "git-reset-origin",
            help="Hard reset all data repositories using 'origin/master'.")

        subparsers.add_parser(
            "git-status",
            help="Get the 'git status' of all data repositories.")

        return
536407
function connect (master) {
    if (_socket && _socket._master.name === master.name) {
      debug(`already connected to master ${master.name}`)
      return
    }
    if (_connectingMaster && _connectingMaster.name === master.name) {
      debug(`already connecting to master ${master.name}`)
      return
    }

    _connectingMaster = master
    let newSocket = _getSocket(master)

    let _messagesToResend = []
    let _onMessagePublished = (...args) => {
      if (_socket) _messagesToResend.push(args)
    }
    _publishStream.on('message', _onMessagePublished)

    debug(`connecting to ${master.name} at ${master.endpoint}`)

    let connectionStart = Date.now()
    const onSocketConnected = timingoutCallback((err) => {
      _publishStream.removeListener('message', _onMessagePublished)
      newSocket.unmonitor()

      if (
        err ||
        !_connectingMaster ||
        _connectingMaster.name === !master.name
      ) {
        newSocket.close()
        if (err) {
          debug(`failed to connect to ${master.name} at ${master.endpoint}`)
          disconnect()
        }
        return
      }

      _connectingMaster = null
      let previousSocket = _socket

      debug(`${previousSocket ? 'switched' : 'connected'} to ${master.name} at ${master.endpoint} in ${Date.now() - connectionStart} ms`)

      _socket = newSocket

      let totalMessagesToResend = _messagesToResend.length
      if (totalMessagesToResend) {
        debug(`resending ${totalMessagesToResend} messages published while transitioning`)
        _messagesToResend.forEach(message => _socket.send(message))
      }

      if (previousSocket) {
        previousSocket.close()
        debug(`closed previous connection to ${previousSocket._master.name} at ${previousSocket._master.endpoint}`)
      } else {
        connection.emit('connect')
      }
    }, 500)

    newSocket.once('connect', () => onSocketConnected())
    return connection
  }