def get_config(self): for f in self.cfgFileList: if os.access(f, os.F_OK): if not os.access(f, os.R_OK): print(("rhnpush does not have read permission on %s" % f)) sys.exit(1) config2 = rhnpush_config.rhnpushConfigParser(f) self.defaultconfig, config2 = utils.make_common_attr_equal( self.defaultconfig, config2) self._files_to_list() # Change the channel string into a list of strings. # pylint: disable=E1103 if not self.defaultconfig.channel: # if no channel then make it null array instead of # an empty string array from of size 1 [''] . self.defaultconfig.channel = [] else: self.defaultconfig.channel = [ x.strip() for x in self.defaultconfig.channel.split(',') ] # Get the command line arguments. These take precedence over the other settings argoptions, files = self.cmdconfig.parse_args() # Makes self.defaultconfig compatible with argoptions by changing all '0' value attributes to None. _zero_to_none(self.defaultconfig, self.store_true_list) # If verbose isn't set at the command-line, it automatically gets set to zero. If it's at zero, change it to # None so the settings in the config files take precedence. if argoptions.verbose == 0: argoptions.verbose = None # Orgid, count, cache_lifetime, and verbose all need to be integers, just like in argoptions. if self.defaultconfig.orgid: self.defaultconfig.orgid = int(self.defaultconfig.orgid) if self.defaultconfig.count: self.defaultconfig.count = int(self.defaultconfig.count) if self.defaultconfig.cache_lifetime: self.defaultconfig.cache_lifetime = int( self.defaultconfig.cache_lifetime) if self.defaultconfig.verbose: self.defaultconfig.verbose = int(self.defaultconfig.verbose) if self.defaultconfig.timeout: self.defaultconfig.timeout = int(self.defaultconfig.timeout) # Copy the settings in argoptions into self.defaultconfig. self.defaultconfig, argoptions = utils.make_common_attr_equal( self.defaultconfig, argoptions) # Make sure files is in the correct format. if self.defaultconfig.files != files: self.defaultconfig.files = files return self.defaultconfig
def get_config(self): for f in self.cfgFileList: if os.access(f, os.F_OK): if not os.access(f, os.R_OK): print(("rhnpush does not have read permission on %s" % f)) sys.exit(1) config2 = rhnpush_config.rhnpushConfigParser(f) self.defaultconfig, config2 = utils.make_common_attr_equal(self.defaultconfig, config2) self._files_to_list() # Change the channel string into a list of strings. # pylint: disable=E1103 if not self.defaultconfig.channel: # if no channel then make it null array instead of # an empty string array from of size 1 [''] . self.defaultconfig.channel = [] else: self.defaultconfig.channel = [x.strip() for x in self.defaultconfig.channel.split(',')] # Get the command line arguments. These take precedence over the other settings argoptions, files = self.cmdconfig.parse_args() # Makes self.defaultconfig compatible with argoptions by changing all '0' value attributes to None. _zero_to_none(self.defaultconfig, self.store_true_list) # If verbose isn't set at the command-line, it automatically gets set to zero. If it's at zero, change it to # None so the settings in the config files take precedence. if argoptions.verbose == 0: argoptions.verbose = None # Orgid, count, cache_lifetime, and verbose all need to be integers, just like in argoptions. if self.defaultconfig.orgid: self.defaultconfig.orgid = int(self.defaultconfig.orgid) if self.defaultconfig.count: self.defaultconfig.count = int(self.defaultconfig.count) if self.defaultconfig.cache_lifetime: self.defaultconfig.cache_lifetime = int(self.defaultconfig.cache_lifetime) if self.defaultconfig.verbose: self.defaultconfig.verbose = int(self.defaultconfig.verbose) if self.defaultconfig.timeout: self.defaultconfig.timeout = int(self.defaultconfig.timeout) # Copy the settings in argoptions into self.defaultconfig. self.defaultconfig, argoptions = utils.make_common_attr_equal(self.defaultconfig, argoptions) # Make sure files is in the correct format. if self.defaultconfig.files != files: self.defaultconfig.files = files return self.defaultconfig
def __init__(self, optionparser, store_true_list): sysdir = '/etc/sysconfig/rhn' homedir = utils.get_home_dir() default = 'rhnpushrc' regular = '.rhnpushrc' deffile = os.path.join(sysdir, default) regfile = os.path.join(homedir, regular) cwdfile = os.path.join(os.getcwd(), regular) self.cfgFileList = [deffile, regfile, cwdfile] self.defaultconfig = rhnpush_config.rhnpushConfigParser(ensure_consistency=True) # Get a reference to the object containing command-line options self.cmdconfig = optionparser self.store_true_list = store_true_list
def __init__(self, optionparser, store_true_list): sysdir = '/etc/sysconfig/rhn' homedir = utils.get_home_dir() default = 'rhnpushrc' regular = '.rhnpushrc' deffile = os.path.join(sysdir, default) regfile = os.path.join(homedir, regular) cwdfile = os.path.join(os.getcwd(), regular) self.cfgFileList = [deffile, regfile, cwdfile] self.defaultconfig = rhnpush_config.rhnpushConfigParser( ensure_consistency=True) # Get a reference to the object containing command-line options self.cmdconfig = optionparser self.store_true_list = store_true_list