⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setup.py

📁 HADOOP 0.18.0安装源代码头文件
💻 PY
📖 第 1 页 / 共 3 页
字号:
            pass          elif nArgs == 0:            print "Usage: ",hodhelp.help()            sys.exit(0)          else:            # subcommand is given            cmdstr = self.args[0] # the subcommand itself            cmdlist = hodhelp.ops            if cmdstr not in cmdlist:              print "Usage: ", hodhelp.help()              sys.exit(2)            numNodes = None            clusterDir = None            # Check which subcommand. cmdstr  = subcommand itself now.            if cmdstr == "allocate":              clusterDir = getattr(self.__parsedOptions, 'hod.clusterdir')              numNodes = getattr(self.__parsedOptions, 'hod.nodecount')               if not clusterDir or not numNodes:                print hodhelp.usage(cmdstr)                sys.exit(3)              cmdstr = cmdstr + ' ' + clusterDir + ' ' + numNodes              setattr(self.__parsedOptions,'hod.operation', cmdstr)             elif cmdstr == "deallocate" or cmdstr == "info":              clusterDir = getattr(self.__parsedOptions, 'hod.clusterdir')              if not clusterDir:                print hodhelp.usage(cmdstr)                sys.exit(3)               cmdstr = cmdstr + ' ' + clusterDir              setattr(self.__parsedOptions,'hod.operation', cmdstr)            elif cmdstr == "list":              setattr(self.__parsedOptions,'hod.operation', cmdstr)              pass             elif cmdstr == "script":              clusterDir = getattr(self.__parsedOptions, 'hod.clusterdir')              numNodes = getattr(self.__parsedOptions, 'hod.nodecount')              originalDir = getattr(self.__parsedOptions, 'hod.original-dir')              if originalDir and clusterDir:                self.remove_exit_code_file(originalDir, clusterDir)              if not _script or not clusterDir or not numNodes:                print hodhelp.usage(cmdstr)                sys.exit(3)              pass            elif cmdstr == "help":              if nArgs == 1:                self.print_help()                sys.exit(0)              elif nArgs != 2:                self.print_help()                sys.exit(3)              elif self.args[1] == 'options':                self.print_options()                sys.exit(0)              cmdstr = cmdstr + ' ' + self.args[1]              setattr(self.__parsedOptions,'hod.operation', cmdstr)        # end of processing for arguments on the client side        if self.__withConfig:            self.config = self.__parsedOptions.config            if not self.config:                self.error("configuration file must be specified")            if not os.path.isabs(self.config):                # A relative path. Append the original directory which would be the                # current directory at the time of launch                try:                      origDir = getattr(self.__parsedOptions, 'hod.original-dir')                    if origDir is not None:                        self.config = os.path.join(origDir, self.config)                        self.__parsedOptions.config = self.config                except AttributeError, e:                    self.error("hod.original-dir is not defined.\                                   Cannot get current directory")            if not os.path.exists(self.config):                if self.__defaultLoc and not re.search("/", self.config):                    self.__parsedOptions.config = os.path.join(                        self.__defaultLoc, self.config)        self.__build_dict()       def norm_cluster_dir(self, orig_dir, directory):        directory = os.path.expanduser(directory)        if not os.path.isabs(directory):            directory = os.path.join(orig_dir, directory)        directory = os.path.abspath(directory)        return directory    def remove_exit_code_file(self, orig_dir, dir):        try:            dir = self.norm_cluster_dir(orig_dir, dir)            if os.path.exists(dir):                exit_code_file = os.path.join(dir, "script.exitcode")                if os.path.exists(exit_code_file):                    os.remove(exit_code_file)        except:            print >>sys.stderr, "Could not remove the script.exitcode file."        def __init_display_options(self):        self.__orig_option_list = self.option_list[:]        optionListTitleMap = {}        for option in self.option_list:            optionListTitleMap[option._long_opts[0]] = option              self.__orig_grps = self.option_groups[:]        for group in self.option_groups:            self.__orig_grp_lists[group.title] = group.option_list[:]                                            groupTitleMap = {}        optionTitleMap = {}        for group in self.option_groups:            groupTitleMap[group.title] = group            optionTitleMap[group.title] = {}            for option in group.option_list:                (sectionName, optionName) = \                    self.__split_compound(option._long_opts[0])                optionTitleMap[group.title][optionName] = option                  for section in self._mySections:            for option in self._configDef[section]:                if self._configDef[section][option]['help']:                    if groupTitleMap.has_key(section):                        if not self.__display_grp_lists.has_key(section):                            self.__display_grp_lists[section] = []                        self.__display_grp_lists[section].append(                            optionTitleMap[section][option])                                        try:                            self.__display_option_list.append(                            optionListTitleMap["--" + self.__splice_compound(                            section, option)])                    except KeyError:                        pass        try:            self.__display_option_list.append(optionListTitleMap['--config'])        except KeyError:            pass                  self.__display_option_list.append(optionListTitleMap['--help'])        self.__display_option_list.append(optionListTitleMap['--verbose-help'])        self.__display_option_list.append(optionListTitleMap['--version'])                            self.__display_grps = self.option_groups[:]                     for section in self._mySections:            if self.__display_grp_lists.has_key(section):                self.__orig_grp_lists[section] = \                    groupTitleMap[section].option_list            else:                try:                    self.__display_grps.remove(groupTitleMap[section])                except KeyError:                    pass                    def __gen_alpha(self):        assignedOptions = []        for section in self._configDef:            for option in self._configDef[section]:                if self._configDef[section][option]['short']:                    assignedOptions.append(                        self._configDef[section][option]['short'])                for symbol in self.__alphaString:            if not symbol in assignedOptions:                self.__alpha.append(symbol)    def __splice_compound(self, section, option):        return "%s.%s" % (section, option)            def __split_compound(self, compound):            return compound.split('.')            def __build_short_map(self):        """ build a short_map of parametername : short_option. This is done        only for those parameters that don't have short options already        defined in configDef.        If possible, the first letter in the option that is not already        used/reserved as a short option is allotted. Otherwise the first        letter in __alpha that isn't still used is allotted.        e.g. { 'hodring.java-home': 'T', 'resource_manager.batch-home': 'B' }        """        optionsKey = {}        for compound in self.__optionList:            (section, option) = self.__split_compound(compound)            if not optionsKey.has_key(section):                optionsKey[section] = []            optionsKey[section].append(option)                for section in self._configDef.sections():            options = optionsKey[section]            options.sort()            for option in options:                if not self._configDef[section][option]['short']:                    compound = self.__splice_compound(section, option)                    shortOptions = self.__shortMap.values()                    for i in range(0, len(option)):                        letter = option[i]                        letter = letter.lower()                        if letter in self.__alpha:                            if not letter in shortOptions and \                                not letter in self.__reserved:                                self.__shortMap[compound] = letter                                break                    if not self.__shortMap.has_key(compound):                        for i in range(0, len(self.__alpha)):                            letter = self.__alpha[i]                            if not letter in shortOptions and \                                not letter in self.__reserved:                                self.__shortMap[compound] = letter    def __add_option(self, config, compoundOpt, section, option, group=None):        addMethod = self.add_option        if group: addMethod=group.add_option                self.__compoundOpts.append(compoundOpt)                if compoundOpt == 'gridservice-mapred.final-server-params' or \           compoundOpt == 'gridservice-hdfs.final-server-params' or \           compoundOpt == 'gridservice-mapred.server-params' or \           compoundOpt == 'gridservice-hdfs.server-params' or \           compoundOpt == 'hod.client-params':          _action = 'append'        elif config[section][option]['type'] == 'bool':          _action = 'store_true'        else:          _action = 'store'        if self.__shortMap.has_key(compoundOpt):          addMethod("-" + self.__shortMap[compoundOpt],                          "--" + compoundOpt, dest=compoundOpt,                           action= _action,                           metavar=config[section][option]['type'],                          default=config[section][option]['default'],                          help=config[section][option]['desc'])        else:          if config[section][option]['short']:            addMethod("-" + config[section][option]['short'],                               "--" + compoundOpt, dest=compoundOpt,                               action= _action,                              metavar=config[section][option]['type'],                              default=config[section][option]['default'],                              help=config[section][option]['desc'])             else:            addMethod('', "--" + compoundOpt, dest=compoundOpt,                               action= _action,                               metavar=config[section][option]['type'],                              default=config[section][option]['default'],                              help=config[section][option]['desc'])                                  def __add_options(self):        if self.__withConfig:            self.add_option("-c", "--config", dest='config',                 action='store', default=self.__defaultConfig,                 metavar='config_file',                help="Full path to configuration file.")        self.add_option("", "--verbose-help",             action='help', default=None,             metavar='flag',            help="Display verbose help information.")                self.add_option("-v", "--version",             action='version', default=None,             metavar='flag',            help="Display version information.")                self.version = self.__version          if len(self._mySections) > 1:            for section in self._mySections:                group = OptionGroup(self, section)                for option in self._configDef[section]:                    compoundOpt = self.__splice_compound(section, option)                    self.__add_option(self._configDef, compoundOpt, section,                                       option, group)                self.add_option_group(group)        else:            for section in self._mySections:                for option in self._configDef[section]:                    compoundOpt = self.__splice_compound(section, option)                    self.__add_option(self._configDef, compoundOpt, section,                                       option)                        def __build_dict(self):        if self.__withConfig:            self._dict['config'] = str(getattr(self.__parsedOptions, 'config'))        for compoundOption in dir(self.__parsedOptions):            if compoundOption in self.__compoundOpts:                (section, option) = self.__split_compound(compoundOption)                if not self._dict.has_key(section):                    self._dict[section] = {}                                if getattr(self.__parsedOptions, compoundOption):                    _attr = getattr(self.__parsedOptions, compoundOption)                    # when we have multi-valued parameters passed separately                    # from command line, python optparser pushes them into a                    # list. So converting all such lists to strings                    if type(_attr) == type([]):                      import string                      _attr = string.join(_attr,',')                    self._dict[section][option] = _attr                            for section in self._configDef:            for option in self._configDef[section]:                 if self._configDef[section][option]['type'] == 'bool':                    compoundOption = self.__splice_compound(section, option)                    if not self._dict.has_key(section):                        self._dict[section] = {}                                        if option not in self._dict[section]:                        self._dict[section][option] = False     def __set_display_groups(self):        if not '--verbose-help' in sys.argv:            self.option_groups = self.__display_grps            self.option_list = self.__display_option_list            for group in self.option_groups:                group.option_list = self.__display_grp_lists[group.title]     def __unset_display_groups(self):        if not '--verbose-help' in sys.argv:            self.option_groups = self.__orig_grps            self.option_list = self.__orig_option_list            for group in self.option_groups:                group.option_list = self.__orig_grp_lists[group.title]           def print_help(self, file=None):        self.__set_display_groups()        OptionParser.print_help(self, file)        self.__unset_display_groups()    def print_options(self):        _usage = self.usage        self.set_usage('')        self.print_help()        self.set_usage(_usage)                            def verify(self):        return baseConfig.verify(self)    def replace_escape_seqs(self):      replace_escapes(self)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -