Пример #1
0
def session_save():
    """Send config-source command to qutebrowsers ipc server."""
    args = qutebrowser.get_argparser().parse_args()
    app.standarddir.init(args)
    socket = ipc._get_socketname(args.basedir)
    ipc.send_to_running_instance(
        socket, [":session-save get_urls"], args.target
    )
Пример #2
0
    def test_flatpak(self, monkeypatch, fake_runtime_dir, basedir, expected,
                     has_flatpak_id):
        if not has_flatpak_id:
            # Simulate an older Flatpak version
            monkeypatch.delenv('FLATPAK_ID', raising=False)

        socketname = ipc._get_socketname(basedir)
        expected_path = str(fake_runtime_dir / 'app' /
                            'org.qutebrowser.qutebrowser' / expected)
        assert socketname == expected_path
Пример #3
0
def test_long_username(fake_runtime_dir):
    """See https://github.com/The-Compiler/qutebrowser/issues/888."""
    name = ipc._get_socketname(basedir='/foo',
                               runtime_dir=fake_runtime_dir,
                               user='******')
    server = ipc.IPCServer(name)
    try:
        server.listen()
    finally:
        server.shutdown()
Пример #4
0
def test_long_username(monkeypatch):
    """See https://github.com/qutebrowser/qutebrowser/issues/888."""
    username = '******'
    basedir = '/this_is_a_long_basedir'
    monkeypatch.setattr('getpass.getuser', lambda: username)
    name = ipc._get_socketname(basedir=basedir)
    server = ipc.IPCServer(name)
    expected_md5 = md5('{}-{}'.format(username, basedir))
    assert expected_md5 in server._socketname
    try:
        server.listen()
    finally:
        server.shutdown()
Пример #5
0
def test_long_username(monkeypatch):
    """See https://github.com/qutebrowser/qutebrowser/issues/888."""
    username = '******'
    basedir = '/this_is_a_long_basedir'
    monkeypatch.setattr('getpass.getuser', lambda: username)
    name = ipc._get_socketname(basedir=basedir)
    server = ipc.IPCServer(name)
    expected_md5 = md5('{}-{}'.format(username, basedir))
    assert expected_md5 in server._socketname
    try:
        server.listen()
    finally:
        server.shutdown()
Пример #6
0
    def test_stale_legacy_server(self, caplog, qtbot, args, legacy_server,
                                 ipc_server, py_proc):
        legacy_name = ipc._get_socketname(args.basedir, legacy=True)
        logging.debug('== Setting up the legacy server ==')
        cmdline = py_proc("""
            import sys

            from PyQt5.QtCore import QCoreApplication
            from PyQt5.QtNetwork import QLocalServer

            app = QCoreApplication([])

            QLocalServer.removeServer(sys.argv[1])
            server = QLocalServer()

            ok = server.listen(sys.argv[1])
            assert ok

            print(server.fullServerName())
        """)

        name = subprocess.check_output(
            [cmdline[0]] + cmdline[1] + [legacy_name])
        name = name.decode('utf-8').rstrip('\n')

        # Closing the server should not remove the FIFO yet
        assert os.path.exists(name)

        ## Setting up the new server
        logging.debug('== Setting up new server ==')
        ret_server = ipc.send_or_listen(args)
        assert isinstance(ret_server, ipc.IPCServer)

        logging.debug('== Connecting ==')
        with qtbot.waitSignal(ret_server.got_args, raising=True):
            ret_client = ipc.send_or_listen(args)

        assert ret_client is None
Пример #7
0
    def test_stale_legacy_server(self, caplog, qtbot, args, legacy_server,
                                 ipc_server, py_proc):
        legacy_name = ipc._get_socketname(args.basedir, legacy=True)
        logging.debug('== Setting up the legacy server ==')
        cmdline = py_proc("""
            import sys

            from PyQt5.QtCore import QCoreApplication
            from PyQt5.QtNetwork import QLocalServer

            app = QCoreApplication([])

            QLocalServer.removeServer(sys.argv[1])
            server = QLocalServer()

            ok = server.listen(sys.argv[1])
            assert ok

            print(server.fullServerName())
        """)

        name = subprocess.check_output([cmdline[0]] + cmdline[1] +
                                       [legacy_name])
        name = name.decode('utf-8').rstrip('\n')

        # Closing the server should not remove the FIFO yet
        assert os.path.exists(name)

        ## Setting up the new server
        logging.debug('== Setting up new server ==')
        ret_server = ipc.send_or_listen(args)
        assert isinstance(ret_server, ipc.IPCServer)

        logging.debug('== Connecting ==')
        with qtbot.waitSignal(ret_server.got_args):
            ret_client = ipc.send_or_listen(args)

        assert ret_client is None
Пример #8
0
 def test_os_x(self, basedir, expected):
     socketname = ipc._get_socketname(basedir)
     parts = socketname.split(os.sep)
     assert parts[-2] == 'qute_test'
     assert parts[-1] == expected
Пример #9
0
 def test_windows(self, basedir, expected):
     socketname = ipc._get_socketname(basedir)
     assert socketname == expected
Пример #10
0
 def test_legacy(self, basedir, expected):
     socketname = ipc._get_socketname(basedir, legacy=True)
     assert socketname == expected
Пример #11
0
 def test_correct_socket_name(self, args):
     server = ipc.send_or_listen(args)
     expected_dir = ipc._get_socketname(args.basedir)
     assert '/' in expected_dir
     assert server._socketname == expected_dir
Пример #12
0
 def test_linux(self, basedir, fake_runtime_dir, expected):
     socketname = ipc._get_socketname(basedir)
     expected_path = str(fake_runtime_dir / 'qutebrowser' / expected)
     assert socketname == expected_path
Пример #13
0
def test_get_socketname(username, basedir, legacy, expected):
    socketname = ipc._get_socketname(basedir, '/runtimedir', legacy=legacy,
                                     user=username)
    assert socketname == expected
Пример #14
0
 def test_linux(self, basedir, fake_runtime_dir, expected):
     socketname = ipc._get_socketname(basedir)
     expected_path = str(fake_runtime_dir / 'qute_test' / expected)
     assert socketname == expected_path
Пример #15
0
 def legacy_server(self, args):
     legacy_name = ipc._get_socketname(args.basedir, legacy=True)
     legacy_server = ipc.IPCServer(legacy_name)
     legacy_server.listen()
     yield legacy_server
     legacy_server.shutdown()
Пример #16
0
 def test_legacy(self, basedir, expected):
     socketname = ipc._get_socketname(basedir, legacy=True)
     assert socketname == expected
Пример #17
0
def qute_reload():
    """Send config-source command to qutebrowsers ipc server."""
    args = qutebrowser.get_argparser().parse_args()
    app.standarddir.init(args)
    socket = ipc._get_socketname(args.basedir)
    ipc.send_to_running_instance(socket, [":config-source"], args.target)
Пример #18
0
 def legacy_server(self, args):
     legacy_name = ipc._get_socketname(args.basedir, legacy=True)
     legacy_server = ipc.IPCServer(legacy_name)
     legacy_server.listen()
     yield legacy_server
     legacy_server.shutdown()
Пример #19
0
 def test_windows(self, basedir, expected):
     socketname = ipc._get_socketname(basedir)
     assert socketname == expected
Пример #20
0
 def test_correct_socket_name(self, args):
     server = ipc.send_or_listen(args)
     expected_dir = ipc._get_socketname(args.basedir)
     assert '/' in expected_dir
     assert server._socketname == expected_dir
Пример #21
0
 def test_mac(self, basedir, expected):
     socketname = ipc._get_socketname(basedir)
     parts = socketname.split(os.sep)
     assert parts[-2] == 'qutebrowser'
     assert parts[-1] == expected