Example #1
0
 def launch(self, options=None):
     """Launch the Qt app in the main thread and sync in another thread."""
     # TODO: use the start method as default once implemented
     from nxdrive.utils import PidLockFile
     lock = PidLockFile(self.controller.config_folder, "qt")
     if lock.lock() is not None:
         self.log.warning("Qt application already running: exiting")
         return
     from nxdrive.gui.application import Application
     app = Application(self.controller, options)
     exit_code = app.exec_()
     lock.unlock()
     self.log.debug("Qt application exited with code %r", exit_code)
Example #2
0
 def launch(self, options=None, console=False):
     """Launch the Qt app in the main thread and sync in another thread."""
     # TODO: use the start method as default once implemented
     from nxdrive.utils import PidLockFile
     lock = PidLockFile(self.manager.get_configuration_folder(), "qt")
     if lock.lock() is not None:
         self.log.warning("Qt application already running: exiting")
         return
     app = self._get_application(options, console=console)
     exit_code = app.exec_()
     lock.unlock()
     self.log.debug("Qt application exited with code %r", exit_code)
     return exit_code
Example #3
0
 def launch(self, options=None, console=False):
     """Launch the Qt app in the main thread and sync in another thread."""
     from nxdrive.utils import PidLockFile
     lock = PidLockFile(self.manager.get_configuration_folder(), "qt")
     if lock.lock() is not None:
         self.log.warning("Qt application already running: exiting")
         # Handle URL if needed
         self.manager.get_direct_edit().handle_url()
         return
     app = self._get_application(options, console=console)
     exit_code = app.exec_()
     lock.unlock()
     self.log.debug("Qt application exited with code %r", exit_code)
     return exit_code
Example #4
0
 def launch(self, options=None, console=False):
     """Launch the Qt app in the main thread and sync in another thread."""
     from nxdrive.utils import PidLockFile
     lock = PidLockFile(self.manager.nxdrive_home, 'qt')
     if lock.lock() is not None:
         self.log.warning('Qt application already running: exiting')
         # Handle URL if needed
         self.manager.direct_edit.handle_url()
         return
     app = self._get_application(console=console)
     exit_code = app.exec_()
     lock.unlock()
     self.log.debug('Qt application exited with code %r', exit_code)
     return exit_code
Example #5
0
 def launch(self, options=None, console=False):
     """Launch the Qt app in the main thread and sync in another thread."""
     from nxdrive.utils import PidLockFile
     lock = PidLockFile(self.manager.get_configuration_folder(), "qt")
     if lock.lock() is not None:
         self.log.warning("Qt application already running: exiting")
         # Handle URL if needed
         self.manager.get_drive_edit().handle_url()
         return
     app = self._get_application(options, console=console)
     exit_code = app.exec_()
     lock.unlock()
     self.log.debug("Qt application exited with code %r", exit_code)
     return exit_code
Example #6
0
def test_unlock(mocked_unlink, tmp):
    folder = tmp()
    folder.mkdir()
    lock_file = folder / "nxdrive_qt.pid"

    assert not lock_file.is_file()

    lock = PidLockFile(folder, "qt")

    # Not yet locked
    lock.unlock()

    # Now locked
    lock.lock()

    # Test another OSerror
    mocked_unlink.side_effect = PermissionError("Boom !")
    lock.unlock()
Example #7
0
def test_lock_file(tmp):
    folder = tmp()
    folder.mkdir()
    lock_file = folder / "nxdrive_qt.pid"

    assert not lock_file.is_file()

    lock = PidLockFile(folder, "qt")
    assert not lock.locked

    pid = lock.lock()
    assert pid is None
    assert lock.locked
    assert lock_file.is_file()

    lock.unlock()
    assert lock.locked
    assert not lock_file.is_file()