From 28506fc6bfaca3b0b6129e9486632846de1b369b Mon Sep 17 00:00:00 2001 From: Seblu Date: Wed, 1 Jun 2011 12:31:17 +0200 Subject: [PATCH] Add timeout paramter to isinstall --- bin/isinstall | 6 ++++-- installsystems/repository.py | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bin/isinstall b/bin/isinstall index 1abfb94..dde932b 100755 --- a/bin/isinstall +++ b/bin/isinstall @@ -37,7 +37,9 @@ p_main.add_argument('-q', "--quiet", action="store_false", dest="verbose", defau p_main.add_argument("-c", "--config", dest="config", type=str, default=None, help="config file path") p_main.add_argument("-v", "--image-version", dest="image_version", type=int, default=None, - help="specific image version") + help="image version") +p_main.add_argument("-t", "--timeout", dest="timeout", type=int, default=3, + help="download timeout") p_main.add_argument("image_name", type=str, help="image to install (path or name)") try: @@ -51,7 +53,7 @@ try: pkg = PackageImage(istools.abspath(args.image_name)) elif image_name_type == "name": # init repo cache object - repocache = RepositoryCache(config.cache, verbose=args.verbose) + repocache = RepositoryCache(config.cache, timeout=args.timeout, verbose=args.verbose) # register repositories repocache.register(config.repos) # update remote info diff --git a/installsystems/repository.py b/installsystems/repository.py index d03ed39..a1bcf61 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -176,8 +176,9 @@ class RepositoryConfig(object): class RepositoryCache(object): '''Local repository cache class''' - def __init__(self, cache_path, verbose=True): + def __init__(self, cache_path, timeout=3, verbose=True): self.verbose = verbose + self.timeout = timeout self.repos = {} self.path = os.path.abspath(cache_path) # ensure cache directories are avaiblable @@ -209,9 +210,9 @@ class RepositoryCache(object): # last local local_last = self.last(r) # copy last file - arrow("Copying %s repository last" % r, 2, self.verbose) + arrow("Checking %s repository last" % r, 2, self.verbose) istools.copy(self.repos[r]["orig"].last_path, - self.repos[r]["cache"].last_path,) + self.repos[r]["cache"].last_path, timeout=self.timeout) # last after update remote_last = self.last(r) debug("%s: last: local: %s, remote:%s" % (r, local_last, remote_last)) @@ -221,8 +222,7 @@ class RepositoryCache(object): if remote_last > local_last or not os.path.exists(local_db): # copy db file arrow("Copying %s repository db" % r, 2, self.verbose) - istools.copy(remote_db, local_db) - arrow("%s updated" % r, 2, self.verbose) + istools.copy(remote_db, local_db, timeout=self.timeout) def last(self, reponame): '''Return the last timestamp of a repo''' @@ -244,7 +244,7 @@ class RepositoryCache(object): # get remote image remotepath = os.path.join(self.repos[reponame]["orig"].config.image, filename) arrow("Copying from repository", 2, self.verbose) - istools.copy(remotepath, cachepath) + istools.copy(remotepath, cachepath, timeout=self.timeout) return cachepath def find_image(self, name, version): -- GitLab