Commit 856d5e87 authored by Sébastien Luttringer's avatar Sébastien Luttringer
Browse files

Use ISError in place of IOError in PipeFile

parent 18a74955
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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
+5 −7
Original line number Diff line number Diff line
@@ -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)