def get_endpoint_name(self):
     name = None
     if self.has_option(
             ConfigFile.ENDPOINT_SECTION,
             ConfigFile.NAME_OPTION):
         name = self.get(
             ConfigFile.ENDPOINT_SECTION,
             ConfigFile.NAME_OPTION)
         if name == '':
             name = None
     if name is None:
         name = gcmu.public_name().split(".")[0]
     elif "#" in name:
         name = name[name.find("#")+1:]
     return name
Example #2
0
    def __init__(self, root="/", config_file=None):
        defaults = copy.deepcopy(os.environ)
        defaults["HOSTNAME"] = gcmu.public_name()
        if "SHORT_HOSTNAME" not in defaults:
            defaults["SHORT_HOSTNAME"] = defaults["HOSTNAME"].split(".")[0]
        if "USER" in defaults:
            del defaults["USER"]
        if "GLOBUSONLINE_USER" not in defaults:
            defaults["GLOBUSONLINE_USER"] = ""
        if "GLOBUSONLINE_PASSWORD" not in defaults:
            defaults["GLOBUSONLINE_PASSWORD"] = ""

        ConfigParser.ConfigParser.__init__(self, defaults)
        self.root = root
        if config_file is None:
            config_file = os.path.join("/", ConfigFile.DEFAULT_CONFIG_FILE)
        config_fp = open(config_file, "r")
        try:
            if self.readfp(config_fp) == []:
                raise ParsingError()
        finally:
            config_fp.close()