Ejemplo n.º 1
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except (IOError, OSError) as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        elif _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 2
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except (IOError, OSError) as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        elif _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 3
0
 def unlock(self):
     """Release this lock.
     This deletes the directory with the given name.
     @raise: Any exception os.readlink() may raise, or
     ValueError if the lock is not owned by this process.
     """
     pid = readlink(self.name)
     if int(pid) != os.getpid():
         raise ValueError("Lock %r not owned by this process" % (self.name,))
     rmlink(self.name)
     self.locked = False
Ejemplo n.º 4
0
    def unlock(self):
        """Release this lock.

        This deletes the directory with the given name.

        @raise: Any exception os.readlink() may raise, or
        ValueError if the lock is not owned by this process.
        """
        pid = readlink(self.name)
        if int(pid) != os.getpid():
            raise ValueError("Lock %r not owned by this process" % (self.name,))
        rmlink(self.name)
        self.locked = False
Ejemplo n.º 5
0
    def unlock(self):
        """
        Release this lock.

        This deletes the directory with the given name.

        @raise OSError: Any exception L{os.readlink()} may raise.
        @raise ValueError: If the lock is not owned by this process.
        """
        pid = readlink(self.name)
        if int(pid) != os.getpid():
            raise ValueError(f"Lock {self.name!r} not owned by this process")
        rmlink(self.name)
        self.locked = False
Ejemplo n.º 6
0
                """
                try:
                    pid = readlink(self.name)
                except (OSError, IOError), e:
                    if e.errno != errno.ENOENT:
                        raise
                    self.clean = True
                else:
                    if not hasattr(os, "kill"):
                        return False
                    try:
                        os.kill(int(pid), 0)
                    except (OSError, IOError), e:
                        if e.errno != errno.ESRCH:
                            raise
                        rmlink(self.name)
                        self.clean = False
                    else:
                        return False

                symlink(str(os.getpid()), self.name)
                self.locked = True
                return True

            def unlock(self):
                """Release this lock.

                This deletes the directory with the given name.

                @raise: Any exception os.readlink() may raise, or
                ValueError if the lock is not owned by this process.
Ejemplo n.º 7
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except OSError as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        raise
                    except IOError as e:
                        if _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                        # Verify that the running process corresponds to
                        # a Spyder one
                        p = psutil.Process(int(pid))

                        # Valid names for main script
                        names = set(['spyder', 'spyder3', 'bootstrap.py'])
                        if PYTEST:
                            names.add('runtests.py')

                        # Check the first three command line arguments
                        arguments = set(
                            os.path.basename(arg) for arg in p.cmdline()[:3])
                        conditions = [names & arguments]
                        if not any(conditions):
                            raise (OSError(errno.ESRCH, 'No such process'))
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 8
0
    if (os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/client")):
        if (os.path.islink(
                "../forge/mcp/src/minecraft/net/medsouz/miney/client")):
            os.unlink("../forge/mcp/src/minecraft/net/medsouz/miney/client")
        else:
            os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/client")
    if (os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/common")):
        if (os.path.islink(
                "../forge/mcp/src/minecraft/net/medsouz/miney/common")):
            os.unlink("../forge/mcp/src/minecraft/net/medsouz/miney/common")
        else:
            os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/common")
    if (os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/common")):
        if (os.path.islink(
                "../forge/mcp/src/minecraft/net/medsouz/miney/updater")):
            os.rmlink("../forge/mcp/src/minecraft/net/medsouz/miney/updater")
        else:
            os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/updater")
    shutil.rmtree("../forge/")
else:

    print "Forge not found"
if (os.path.exists("../Miney-Updater-master/")):
    print "Removing Miney-Updater"
    shutil.rmtree("../Miney-Updater-master/")
else:
    print "Miney-Updater not found"
print "==================================="
print "Downloading recommended Forge build..."
urllib.urlretrieve(
    "http://files.minecraftforge.net/minecraftforge/minecraftforge-src-recommended.zip",
Ejemplo n.º 9
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except OSError as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        raise
                    except IOError as e:
                        if _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                        # Verify that the running process corresponds to
                        # a Spyder one
                        p = psutil.Process(int(pid))

                        # Valid names for main script
                        names = set(['spyder', 'spyder3', 'spyder.exe',
                                     'spyder3.exe', 'bootstrap.py',
                                     'spyder-script.py'])
                        if running_under_pytest():
                            names.add('runtests.py')

                        # Check the first three command line arguments
                        arguments = set(os.path.basename(arg)
                                        for arg in p.cmdline()[:3])
                        conditions = [names & arguments]
                        if not any(conditions):
                            raise(OSError(errno.ESRCH, 'No such process'))
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 10
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except OSError as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        raise
                    except IOError as e:
                        if _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                        # Verify that the running process corresponds to
                        # a TRex one
                        p = psutil.Process(int(pid))
                        if os.name == 'nt':
                            conditions = [
                                'trex' in c.lower() for c in p.cmdline()
                            ]
                        else:
                            conditions = [
                                p.name() == 'trex',
                                p.name() == 'trex3'
                            ]
                        # For DEV
                        conditions += ['bootstrap.py' in p.cmdline()]
                        if not any(conditions):
                            raise (OSError(errno.ESRCH, 'No such process'))
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 11
0
print "Cleaning the repository..."
if(os.path.exists("../forge/")):
        print "Removing Forge"
        if(os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/client")):
                if(os.path.islink("../forge/mcp/src/minecraft/net/medsouz/miney/client")):
                        os.unlink("../forge/mcp/src/minecraft/net/medsouz/miney/client")
                else:
                        os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/client")
        if(os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/common")):
                if(os.path.islink("../forge/mcp/src/minecraft/net/medsouz/miney/common")):
                        os.unlink("../forge/mcp/src/minecraft/net/medsouz/miney/common")
                else:
                        os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/common")
        if(os.path.exists("../forge/mcp/src/minecraft/net/medsouz/miney/common")):
                if(os.path.islink("../forge/mcp/src/minecraft/net/medsouz/miney/updater")):
                        os.rmlink("../forge/mcp/src/minecraft/net/medsouz/miney/updater")
                else:
                        os.rmdir("../forge/mcp/src/minecraft/net/medsouz/miney/updater")
        shutil.rmtree("../forge/")
else:

	print "Forge not found"
if(os.path.exists("../Miney-Updater-master/")):
	print "Removing Miney-Updater"
	shutil.rmtree("../Miney-Updater-master/")
else:
	print "Miney-Updater not found"
print"==================================="
print "Downloading recommended Forge build..."
urllib.urlretrieve ("http://files.minecraftforge.net/minecraftforge/minecraftforge-src-recommended.zip", "forge.zip")
print "Forge downloaded! Extracting..."
Ejemplo n.º 12
0
    def lock(self):
        """
        Acquire this lock.

        @rtype: C{bool}
        @return: True if the lock is acquired, false otherwise.

        @raise: Any exception os.symlink() may raise, other than
        EEXIST.
        """
        clean = True
        while True:
            try:
                symlink(str(os.getpid()), self.name)
            except OSError as e:
                if _windows and e.errno in (errno.EACCES, errno.EIO):
                    # The lock is in the middle of being deleted because we're
                    # on Windows where lock removal isn't atomic.  Give up, we
                    # don't know how long this is going to take.
                    return False
                if e.errno == errno.EEXIST:
                    try:
                        pid = readlink(self.name)
                    except OSError as e:
                        if e.errno == errno.ENOENT:
                            # The lock has vanished, try to claim it in the
                            # next iteration through the loop.
                            continue
                        raise
                    except IOError as e:
                        if _windows and e.errno == errno.EACCES:
                            # The lock is in the middle of being
                            # deleted because we're on Windows where
                            # lock removal isn't atomic.  Give up, we
                            # don't know how long this is going to
                            # take.
                            return False
                        raise
                    try:
                        if kill is not None:
                            kill(int(pid), 0)
                        # Verify that the running process corresponds to
                        # a Spyder one
                        p = psutil.Process(int(pid))
                        if os.name == 'nt':
                            conditions = ['spyder' in c.lower()
                                          for c in p.cmdline()]
                        else:
                            conditions = [p.name() == 'spyder',
                                          p.name() == 'spyder3']
                        # For DEV
                        conditions += ['bootstrap.py' in p.cmdline()]
                        if not any(conditions):
                            raise(OSError(errno.ESRCH, 'No such process'))
                    except OSError as e:
                        if e.errno == errno.ESRCH:
                            # The owner has vanished, try to claim it in the
                            # next iteration through the loop.
                            try:
                                rmlink(self.name)
                            except OSError as e:
                                if e.errno == errno.ENOENT:
                                    # Another process cleaned up the lock.
                                    # Race them to acquire it in the next
                                    # iteration through the loop.
                                    continue
                                raise
                            clean = False
                            continue
                        raise
                    return False
                raise
            self.locked = True
            self.clean = clean
            return True
Ejemplo n.º 13
0
        """
        try:
            pid = readlink(self.name)
        except (OSError, IOError), e:
            if e.errno != errno.ENOENT:
                raise
            self.clean = True
        else:
            if not hasattr(os, 'kill'):
                return False
            try:
                os.kill(int(pid), 0)
            except (OSError, IOError), e:
                if e.errno != errno.ESRCH:
                    raise
                rmlink(self.name)
                self.clean = False
            else:
                return False

        symlink(str(os.getpid()), self.name)
        self.locked = True
        return True

    def unlock(self):
        """Release this lock.

        This deletes the directory with the given name.

        @raise: Any exception os.readlink() may raise, or
        ValueError if the lock is not owned by this process.