Commit 214dcdfe authored by Seblu's avatar Seblu
Browse files

fix config loading issue caused by argparse append

parent d5928968
Loading
Loading
Loading
Loading
+15 −10
Original line number Diff line number Diff line
@@ -23,13 +23,19 @@ def load_repositories(args):
    '''
    Load repository on arg line
    '''
    # load repo configs
    repos = []
    for r_config in args.repo_config:
        repos += RepoConfigFile(r_config).repos
    # load repo configs
    if args.repo_path is not None:
        # from command line
        repos = [ RepositoryConfig(None, path=args.repo_path) ]
    else:
        # from config
        repos += RepoConfigFile(args.repo_config).repos
        # filtering on repository name if present
        if args.repo_filter is not None:
            repos = filter(lambda x: x.name == args.repo_filter, repos)
    # print selected repositories
    debug("Loaded repositories: %s" % [ x.name for x in repos ])
    return repos

def c_init_image(args):
@@ -173,13 +179,12 @@ ex_group.add_argument('-q', "--quiet", action="store_true",
# common options
p_main.add_argument("-c", "--config", default="installsystems",
                    help="config file path")
p_main.add_argument("-R", "--repo-config", default="repository",
                    help="repository config file path")
p_main.add_argument("-f", "--repo-filter", default=None,
                    help="select repository by name in config files")
p_main.add_argument("-r", "--repo-path", action="append", default=[],
p_main.add_argument("-r", "--repo-path", default=None,
                    help="repository path")
p_main.add_argument("-R", "--repo-config", action="append",
                    default=["repository"],
                    help="repository config (can be specified more than one time)")
p_main.add_argument("-t", "--timeout", dest="timeout", type=int, default=None,
                    help="download timeout")
# create a subparsers for each command
+4 −4
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ class MainConfigFile(ConfigFile):
        if self.path is None:
            debug("No main config file to load")
            return
        debug("Loading config file: %s" % self.path)
        debug("Loading main config file: %s" % self.path)
        try:
            cp = RawConfigParser()
            cp.read(self.path)
@@ -72,7 +72,7 @@ class MainConfigFile(ConfigFile):
            if cp.has_section(self.prefix):
                self._config = dict(cp.items(self.prefix))
        except Exception as e:
            raise Exception("Unable load file %s: %s" % (self.path, e))
            raise Exception("Unable load main config file %s: %s" % (self.path, e))

    def merge(self, namespace):
        '''
@@ -141,7 +141,7 @@ class RepoConfigFile(ConfigFile):
        if self.path is None:
            return
        # loading config file if exists
        debug("Loading config file: %s" % self.path)
        debug("Loading repository config file: %s" % self.path)
        try:
            cp = RawConfigParser()
            cp.read(self.path)
@@ -153,7 +153,7 @@ class RepoConfigFile(ConfigFile):
                # get all options in repo
                self._repos.append(RepositoryConfig(rep, **dict(cp.items(rep))))
        except Exception as e:
            raise Exception("Unable load file %s: %s" % (self.path, e))
            raise Exception("Unable to load repository file %s: %s" % (self.path, e))

    @property
    def repos(self):
+0 −1
Original line number Diff line number Diff line
@@ -417,7 +417,6 @@ class RepositoryManager(object):
            if not os.path.exists(filedest):
                open(filedest, "wb")
        # get remote last value
        print config.lastpath
        rlast = int(istools.uopen(config.lastpath).read().strip())
        # get local last value
        llast = int(os.stat(filedest).st_mtime)