diff --git a/installsystems/repository.py b/installsystems/repository.py index 2763c44221047b5bd30d603c6ef94ee707738ef5..c570ea63cdf343e6ec989d3e685dbe10b0af85ff 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -104,7 +104,7 @@ class Repository(object): ''' try: last_path = os.path.join(config.path, config.lastname) - return int(istools.uopen(last_path, "r").read().rstrip()) + return int(open(last_path, "r").read().rstrip()) except Exception as e: raise Exception("Read last file failed: %s" % e) return 0 @@ -425,7 +425,8 @@ class RepositoryManager(object): open(filedest, "wb") # get remote last value try: - rlast = int(istools.uopen(config.lastpath).read().strip()) + rlast = int(istools.uopen(config.lastpath, + timeout=self.timeout).read().strip()) # get local last value llast = int(os.stat(filedest).st_mtime) # if repo is out of date, download it diff --git a/installsystems/tools.py b/installsystems/tools.py index 1630dabf95d06101f9860a1c83f3342087f53bf1..430b5906cc84aa4ad829aae229447f2000f47018 100644 --- a/installsystems/tools.py +++ b/installsystems/tools.py @@ -130,7 +130,7 @@ def abspath(path): else: return None -def uopen(path, mode="rb"): +def uopen(path, mode="rb", timeout=3): ''' Universal Open Create a file-like object to a file which can be remote @@ -139,7 +139,7 @@ def uopen(path, mode="rb"): if ftype == "file": return open(path, mode) elif ftype == "http" or ftype == "ftp": - return urllib2.urlopen(path) + return urllib2.urlopen(path, timeout=timeout) else: raise NotImplementedError