Exemplo n.º 1
0
 def _unlock_func():
     SimpleFileLock.release_lock(magneto_lock, lock_map)
Exemplo n.º 2
0
 def _unlock_func():
     SimpleFileLock.release(magneto_lock, lock_map)
Exemplo n.º 3
0
if __name__ == "__main__":
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # acquire lock
    magneto_lock_dir = "/tmp"
    magneto_lock_file = ".magneto.lock"
    user_home = os.getenv("HOME")
    if user_home is not None:
        if os.path.isdir(user_home):
            magneto_lock_dir = user_home

    from entropy.locks import SimpleFileLock
    lock_map = {}
    magneto_lock = os.path.join(magneto_lock_dir, magneto_lock_file)
    acquired = SimpleFileLock.acquire_lock(magneto_lock, lock_map)
    def _unlock_func():
        SimpleFileLock.release_lock(magneto_lock, lock_map)

    try:
        if acquired:
            _startup(_unlock_func)
        else:
            sys.stderr.write(
                "Warning: another Magneto instance is already running.\n")
            raise SystemExit(1)
    finally:
        if acquired:
            _unlock_func()
Exemplo n.º 4
0
    raise SystemExit(0)

if __name__ == "__main__":
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    # acquire lock
    magneto_lock_dir = "/tmp"
    magneto_lock_file = ".magneto.lock"
    user_home = os.getenv("HOME")
    if user_home is not None:
        if os.path.isdir(user_home):
            magneto_lock_dir = user_home

    lock_map = {}
    magneto_lock = os.path.join(magneto_lock_dir, magneto_lock_file)
    acquired = SimpleFileLock.acquire(magneto_lock, lock_map)
    def _unlock_func():
        SimpleFileLock.release(magneto_lock, lock_map)

    try:
        if acquired:
            _startup(_unlock_func)
        else:
            sys.stderr.write(
                "Warning: another Magneto instance is already running.\n")
            raise SystemExit(1)
    finally:
        if acquired:
            _unlock_func()