예제 #1
0
 def test_config_no_faked_header(self):
     tc_name = inspect.stack()[0][3]
     files = [[os.path.join(self.fixtures_dir, tc_name, 'test.ini'), False]]
     var = Config(files).get('general', 'apiurl')
     self.assertEqual(var, 'http://api.example.com')
     var = Config(files).get(var, 'email')
     self.assertEqual(var, '*****@*****.**')
예제 #2
0
 def test_config_files_ordering(self):
     tc_name = inspect.stack()[0][3]
     files = [
         [os.path.join(self.fixtures_dir, tc_name, 'a.cfg'), True],
         [os.path.join(self.fixtures_dir, tc_name, 'b.cfg'), True],
     ]
     var = Config(files).get(None, 'var')
     self.assertEqual(var, 'b')
예제 #3
0
    def get_changesauthor(self, args):
        changesauthor = None
        # return changesauthor if given as cli option
        if args.changesauthor:
            return args.changesauthor

        # find changesauthor in $HOME/.oscrc
        try:
            files = [[os.path.join(os.environ['HOME'], '.oscrc'), False]]
            cfg = Config(files)

            section = cfg.get('general', 'apiurl')
            if section:
                changesauthor = cfg.get(section, 'email')
        except KeyError:
            pass

        if not changesauthor:
            changesauthor = Cli.DEFAULT_AUTHOR

        logging.debug("AUTHOR: %s", changesauthor)

        return changesauthor
예제 #4
0
    def get_changesauthor(self, args):
        # return changesauthor if given as cli option
        if args.changesauthor:
            return args.changesauthor

        # find changesauthor in $HOME/.oscrc
        try:
            files = [[os.path.join(os.environ['HOME'], '.oscrc'), False]]
            cfg = Config(files)

            changesauthor = None
            section = cfg.get('general', 'apiurl')
            if section:
                changesauthor = cfg.get(section, 'email')
        except KeyError:
            pass

        if not changesauthor:
            changesauthor = Cli.DEFAULT_AUTHOR

        logging.debug("AUTHOR: %s", changesauthor)

        return changesauthor
예제 #5
0
    def test_config_debug_tar_scm(self):
        tc_name = inspect.stack()[0][3]

        try:
            tmp = os.environ['TAR_SCM_CLEAN_ENV']
        except KeyError:
            tmp = None

        os.environ['TAR_SCM_CLEAN_ENV'] = "1"

        files = [[os.path.join(self.fixtures_dir, tc_name, 'test.rc'), True]]
        var = Config(files).get(None, 'var')
        self.assertEqual(var, None)

        if tmp:
            os.environ['TAR_SCM_CLEAN_ENV'] = tmp
        else:
            os.environ['TAR_SCM_CLEAN_ENV'] = ''
            os.unsetenv('TAR_SCM_CLEAN_ENV')
예제 #6
0
    def _calc_repocachedir(self):
        # check for enabled caches in this order (first wins):
        #   1. local .cache
        #   2. environment
        #   3. user config
        #   4. system wide
        repocachedir = None
        cwd = os.getcwd()
        if os.path.isdir(os.path.join(cwd, '.cache')):
            repocachedir = os.path.join(cwd, '.cache')

        if repocachedir is None:
            repocachedir = os.getenv('CACHEDIRECTORY')

        if repocachedir is None:
            repocachedir = Config().get('tar_scm', 'CACHEDIRECTORY')

        if repocachedir:
            logging.debug("REPOCACHE: %s", repocachedir)
            self.repohash = self.get_repocache_hash(self.args.subdir)
            self.repocachedir = os.path.join(repocachedir, self.repohash)