Exemple #1
0
def _connect(self, port):
    result = _connect_to(self, port)

    if result == 0:  # everything went fine
        return
    if result == errno.EEXIST:  # silently pass if already connected
        return

    raise OSError(result)
Exemple #2
0
def get_ip(domain):
    if domain.count("/"):
        domain = domain.split("/")[0]
    try:
        ip = socket.getaddrinfo(domain, None, socket.AF_INET6)[0][4][0]
    except:
        try:
            ip = socket.getaddrinfo("www." + domain, None,
                                    socket.AF_INET6)[0][4][0]
        except:
            raise OSError("No AAAA record for this domain")

    return ip
Exemple #3
0
    def do_rename_with_temp_exc(cls, func, f, g):
        """Rename f -> g, but using t as tempfile. If writing to g fails,
        will attempt to rollback f <- t."""
        t = f + '.tmp'
        while os.path.exists(t):
            t += 'z'

        # f -> t
        try:
            func(f, t)
        except OSError:
            raise OSError("Failed to create tempfile for rename: %s" % t)

        # t -> g
        try:
            func(t, g)
        except OSError:
            try:
                func(t, f)
            except OSError:
                raise OSError("Failed to rollback rename: %s <- %s" % (f, t))
            raise OSError("Failed rename %s -> %s" % (f, g))
Exemple #4
0
 def side_effect(*args, **kwargs):
     raise OSError(errno.EPERM, "access denied")
Exemple #5
0
 def side_effect(*args, **kwargs):
     raise OSError(errno.ESRCH, "process is dead already...")
Exemple #6
0
 def side_effect(x,y):
     raise OSError(errno.EPERM, "Access denied")