From 856d5e87818459ea3568aa638dceef757b6be704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Luttringer?= Date: Mon, 25 Jun 2012 13:18:12 +0200 Subject: [PATCH] Use ISError in place of IOError in PipeFile --- installsystems/repository.py | 6 +++--- installsystems/tools.py | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/installsystems/repository.py b/installsystems/repository.py index 9e76028..6703490 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -606,7 +606,7 @@ class RepositoryManager(object): try: original_dbpath = config.dbpath if temp and nosync: - raise IOError("sync is disabled") + raise ISError("sync is disabled") elif temp: # this is a temporary cached repository tempfd, config.dbpath = tempfile.mkstemp() @@ -623,7 +623,7 @@ class RepositoryManager(object): try: rlast = int(PipeFile(config.lastpath, mode='r', timeout=self.timeout).read().strip()) - except IOError: + except ISError: rlast = -1 else: rlast = rdb.mtime @@ -650,7 +650,7 @@ class RepositoryManager(object): if os.path.exists(config.dbpath): os.unlink(config.dbpath) raise - except IOError as e: + except ISError as e : # if something append bad during caching, we mark repo as offline debug(u"Unable to cache repository %s: %s" % (config.name, e)) config.offline = True diff --git a/installsystems/tools.py b/installsystems/tools.py index da4f50a..452c4d8 100644 --- a/installsystems/tools.py +++ b/installsystems/tools.py @@ -141,8 +141,7 @@ class PipeFile(object): try: self.fo = urllib2.urlopen(path, timeout=self.timeout) except Exception as e: - # FIXME: unable to open file - raise IOError(e) + raise ISError("Unable to open %s" % path, e) # get file size if "Content-Length" in self.fo.headers: self.size = int(self.fo.headers["Content-Length"]) @@ -162,8 +161,7 @@ class PipeFile(object): try: self.fo = urllib2.urlopen(path, timeout=self.timeout) except Exception as e: - # FIXME: unable to open file - raise IOError(e) + raise ISError("Unable to open %s" % path, e) # get file size try: self.size = int(self.fo.headers["content-length"]) @@ -178,7 +176,7 @@ class PipeFile(object): try: import paramiko except ImportError: - raise IOError("URL type not supported") + raise ISError("URL type not supported. Paramiko is missing") # parse url (login, passwd, host, port, path) = re.match( "ssh://(([^:]+)(:([^@]+))?@)?([^/:]+)(:(\d+))?(/.*)?", path).group(2, 4, 5, 7, 8) @@ -216,7 +214,7 @@ class PipeFile(object): def read(self, size=None): if self.mode == "w": - raise IOError("Unable to read in w mode") + raise ISError("Unable to read in w mode") buf = self.fo.read(size) length = len(buf) self._md5.update(buf) @@ -231,7 +229,7 @@ class PipeFile(object): def write(self, buf): if self.mode == "r": - raise IOError("Unable to write in r mode") + raise ISError("Unable to write in r mode") self.fo.write(buf) length = len(buf) self._md5.update(buf) -- GitLab