Exemplo n.º 1
0
    def start(self):
        self.initialize_logger(self.args.debug)
        try:
            os.makedirs(config_dir)
        except OSError:
            pass

        # Acquire a filesystem lock to prevent multiple instances from running
        lock = FilesystemLock(
            os.path.join(config_dir, "{}.lock".format(APP_NAME)))
        lock.acquire()

        logging.debug("Core starting with args: %s", self.args)
        logging.debug("Loaded config.txt settings: %s", settings)

        self.show_message()

        self.gui = Gui(self)
        self.gui.show_systray()

        reactor.callLater(0, self.start_gateways)
        reactor.run()
        for nodedir in get_nodedirs(config_dir):
            Tahoe(nodedir, executable=self.executable).kill()
        lock.release()
Exemplo n.º 2
0
def test_lock_release(tmpdir):
    lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    lock.acquire()
    lock.release()
    lock.acquire()
    lock.release()
Exemplo n.º 3
0
def test_lock_acquire_raise_filesystemlockerror_from_second_instance(tmpdir):
    lock_1 = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    lock_1.acquire()
    lock_2 = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    with pytest.raises(FilesystemLockError):
        lock_2.acquire()
Exemplo n.º 4
0
def test_lock_acquire_raise_filesystemlockerror_on_second_call(tmpdir):
    lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    lock.acquire()
    with pytest.raises(FilesystemLockError):
        lock.acquire()
Exemplo n.º 5
0
def test_lock_acquire_filepath_created(tmpdir):
    lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    lock.acquire()
    assert os.path.isfile(lock.filepath)
Exemplo n.º 6
0
def test_lock_acquire(tmpdir):
    lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock"))
    lock.acquire()
    assert lock.fd