Loading bin/is +12 −6 Original line number Diff line number Diff line Loading @@ -303,8 +303,8 @@ def c_repo(parser, args): ''' repoman = load_repositories(args) for pattern in args.repository: repoman.show_repos(pattern, online=not args.offline, offline=not args.online, url=args.verbose, state=not args.no_state) repoman.show_repos(pattern, online=args.online, local=args.local, url=args.verbose, state=not args.no_state) def c_search(parser, args): ''' Loading Loading @@ -556,10 +556,16 @@ p_prepare_chroot.set_defaults(func=c_prepare_chroot) p_repo = subparsers.add_parser("repo", help=c_repo.__doc__.lower()) p_repo.add_argument("--force-offline", action="store_true", default=False, help="force repository to be offline") p_repo.add_argument("-o", "--online", action="store_true", default=False, help="list only online repository") p_repo.add_argument("-O", "--offline", action="store_true", default=False, help="list only offline repository") p_repo_mgroup = p_repo.add_mutually_exclusive_group() p_repo_mgroup.add_argument("-l", "--local", action="store_true", default=None, help="list local repository (filter)") p_repo_mgroup.add_argument("-r", "--remote", action="store_false", dest="local", help="list remote repository (filter)") p_repo_mgroup = p_repo.add_mutually_exclusive_group() p_repo_mgroup.add_argument("-o", "--online", action="store_true", default=None, help="list online repository (filter)") p_repo_mgroup.add_argument("-O", "--offline", action="store_false", dest="online", help="list offline repository (filter)") p_repo.add_argument("-S", "--no-state", action="store_true", default=False, help="doesn't display repository state (online/offline)") p_repo.add_argument("-v", "--verbose", action="store_true", default=False, Loading completion/bash/is +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ _is() { _filedir -d ;; repo) [[ "$cur" == -* ]] && _opt '-h --help -v --verbose -o --online -O --offline -S --no-state --force-offline' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -v --verbose -l --local -r --remote -o --online -O --offline -S --no-state --force-offline' && return 0 _repo ;; search) Loading installsystems/repository.py +25 −16 Original line number Diff line number Diff line Loading @@ -68,14 +68,16 @@ class Repository(object): def __init__(self, config): self.config = config self.version = 1 if not config.offline: self.local = istools.isfile(self.config.path) if not self.config.offline: try: self.db = Database(config.dbpath) except: self.config.offline = True if config.offline: if self.config.offline: debug("Repository %s is offline" % config.name) def __getattribute__(self, name): ''' Raise an error if repository is unavailable Loading @@ -83,8 +85,8 @@ class Repository(object): because repository is not initialized ''' config = object.__getattribute__(self, "config") # config and init are always accessible if name in ("init", "config"): # config, init, local are always accessible if name in ("init", "config", "local"): return object.__getattribute__(self, name) # if no db (not init or not accessible) raise error if config.offline: Loading @@ -97,7 +99,7 @@ class Repository(object): ''' config = self.config # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository creation must be local") # create base directories arrow("Creating base directories") Loading Loading @@ -128,7 +130,7 @@ class Repository(object): Update last file to current time ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository addition must be local") try: arrow("Updating last file") Loading @@ -155,7 +157,7 @@ class Repository(object): if delete is true, remove original files ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository addition must be local") # cannot add already existant image if self.has(image.name, image.version): Loading Loading @@ -232,7 +234,7 @@ class Repository(object): Check repository for unreferenced and missing files ''' # Check if the repo is local if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository must be local") local_files = set(os.listdir(self.config.path)) local_files.remove(self.config.dbname) Loading Loading @@ -262,7 +264,7 @@ class Repository(object): Clean the repository's content ''' # Check if the repo is local if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository must be local") allmd5 = set(self.getallmd5()) repofiles = set(os.listdir(self.config.path)) - set([self.config.dbname, self.config.lastname]) Loading Loading @@ -295,7 +297,7 @@ class Repository(object): Delete an image from repository ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository deletion must be local") # get md5 of files related to images (exception is raised if not exists md5s = self.getmd5(name, version) Loading Loading @@ -621,18 +623,25 @@ class RepositoryManager(object): return repo.get(name, version), repo raise Exception("Unable to find image %s v%s" % (name, version)) def show_repos(self, pattern, online=True, offline=True, url=False, state=True): def show_repos(self, pattern, local=None, online=None, url=False, state=True): ''' Show repository inside manager online: list online repository offline: list offline repository verbose: display path if :param online: is true, list only online repositories if :param online: is false, list only offline repostiories if :param online: is None, list both online and offline repostiories. if :param local: is true, list only local repositories if :param local: is false, list only remote repostiories if :param local: is None, list both local and remote repostiories. ''' for reponame in fnmatch.filter(self.names, pattern): repo = self[reponame] if repo.config.offline and not offline: if repo.config.offline and online is True: continue if not repo.config.offline and online is False: continue if repo.local and local is False: continue if not repo.config.offline and not online: if not repo.local and local is True: continue s = "#light##blue#%s#reset#"% repo.config.name if url: Loading Loading
bin/is +12 −6 Original line number Diff line number Diff line Loading @@ -303,8 +303,8 @@ def c_repo(parser, args): ''' repoman = load_repositories(args) for pattern in args.repository: repoman.show_repos(pattern, online=not args.offline, offline=not args.online, url=args.verbose, state=not args.no_state) repoman.show_repos(pattern, online=args.online, local=args.local, url=args.verbose, state=not args.no_state) def c_search(parser, args): ''' Loading Loading @@ -556,10 +556,16 @@ p_prepare_chroot.set_defaults(func=c_prepare_chroot) p_repo = subparsers.add_parser("repo", help=c_repo.__doc__.lower()) p_repo.add_argument("--force-offline", action="store_true", default=False, help="force repository to be offline") p_repo.add_argument("-o", "--online", action="store_true", default=False, help="list only online repository") p_repo.add_argument("-O", "--offline", action="store_true", default=False, help="list only offline repository") p_repo_mgroup = p_repo.add_mutually_exclusive_group() p_repo_mgroup.add_argument("-l", "--local", action="store_true", default=None, help="list local repository (filter)") p_repo_mgroup.add_argument("-r", "--remote", action="store_false", dest="local", help="list remote repository (filter)") p_repo_mgroup = p_repo.add_mutually_exclusive_group() p_repo_mgroup.add_argument("-o", "--online", action="store_true", default=None, help="list online repository (filter)") p_repo_mgroup.add_argument("-O", "--offline", action="store_false", dest="online", help="list offline repository (filter)") p_repo.add_argument("-S", "--no-state", action="store_true", default=False, help="doesn't display repository state (online/offline)") p_repo.add_argument("-v", "--verbose", action="store_true", default=False, Loading
completion/bash/is +1 −1 Original line number Diff line number Diff line Loading @@ -139,7 +139,7 @@ _is() { _filedir -d ;; repo) [[ "$cur" == -* ]] && _opt '-h --help -v --verbose -o --online -O --offline -S --no-state --force-offline' && return 0 [[ "$cur" == -* ]] && _opt '-h --help -v --verbose -l --local -r --remote -o --online -O --offline -S --no-state --force-offline' && return 0 _repo ;; search) Loading
installsystems/repository.py +25 −16 Original line number Diff line number Diff line Loading @@ -68,14 +68,16 @@ class Repository(object): def __init__(self, config): self.config = config self.version = 1 if not config.offline: self.local = istools.isfile(self.config.path) if not self.config.offline: try: self.db = Database(config.dbpath) except: self.config.offline = True if config.offline: if self.config.offline: debug("Repository %s is offline" % config.name) def __getattribute__(self, name): ''' Raise an error if repository is unavailable Loading @@ -83,8 +85,8 @@ class Repository(object): because repository is not initialized ''' config = object.__getattribute__(self, "config") # config and init are always accessible if name in ("init", "config"): # config, init, local are always accessible if name in ("init", "config", "local"): return object.__getattribute__(self, name) # if no db (not init or not accessible) raise error if config.offline: Loading @@ -97,7 +99,7 @@ class Repository(object): ''' config = self.config # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository creation must be local") # create base directories arrow("Creating base directories") Loading Loading @@ -128,7 +130,7 @@ class Repository(object): Update last file to current time ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository addition must be local") try: arrow("Updating last file") Loading @@ -155,7 +157,7 @@ class Repository(object): if delete is true, remove original files ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository addition must be local") # cannot add already existant image if self.has(image.name, image.version): Loading Loading @@ -232,7 +234,7 @@ class Repository(object): Check repository for unreferenced and missing files ''' # Check if the repo is local if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository must be local") local_files = set(os.listdir(self.config.path)) local_files.remove(self.config.dbname) Loading Loading @@ -262,7 +264,7 @@ class Repository(object): Clean the repository's content ''' # Check if the repo is local if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository must be local") allmd5 = set(self.getallmd5()) repofiles = set(os.listdir(self.config.path)) - set([self.config.dbname, self.config.lastname]) Loading Loading @@ -295,7 +297,7 @@ class Repository(object): Delete an image from repository ''' # check local repository if not istools.isfile(self.config.path): if not self.local: raise Exception("Repository deletion must be local") # get md5 of files related to images (exception is raised if not exists md5s = self.getmd5(name, version) Loading Loading @@ -621,18 +623,25 @@ class RepositoryManager(object): return repo.get(name, version), repo raise Exception("Unable to find image %s v%s" % (name, version)) def show_repos(self, pattern, online=True, offline=True, url=False, state=True): def show_repos(self, pattern, local=None, online=None, url=False, state=True): ''' Show repository inside manager online: list online repository offline: list offline repository verbose: display path if :param online: is true, list only online repositories if :param online: is false, list only offline repostiories if :param online: is None, list both online and offline repostiories. if :param local: is true, list only local repositories if :param local: is false, list only remote repostiories if :param local: is None, list both local and remote repostiories. ''' for reponame in fnmatch.filter(self.names, pattern): repo = self[reponame] if repo.config.offline and not offline: if repo.config.offline and online is True: continue if not repo.config.offline and online is False: continue if repo.local and local is False: continue if not repo.config.offline and not online: if not repo.local and local is True: continue s = "#light##blue#%s#reset#"% repo.config.name if url: Loading