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
Example #2
0
    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
Example #3
0
 def testMakeCommonAttrEqual(self):
     self.obj1, self.obj2 = utils.make_common_attr_equal(self.obj1, self.obj2)
     assert (self.obj1._d == '1'
             and self.obj2._d == '4'
             and self.obj1.a == 4
             and self.obj1.b == 5
             and self.obj1.c == 6
             and self.obj2.f == 'aaa')
Example #4
0
 def testMakeCommonAttrEqual(self):
     self.obj1, self.obj2 = utils.make_common_attr_equal(self.obj1, self.obj2)
     assert (self.obj1._d == '1'
             and self.obj2._d == '4'
             and self.obj1.a == 4
             and self.obj1.b == 5
             and self.obj1.c == 6
             and self.obj2.f == 'aaa')