Exemple #1
0
    def start(self, config_class):
        rpipe, wpipe = multiprocessing.Pipe()

        def run_qtile():
            llvl = logging.DEBUG if pytest.config.getoption(
                "--debuglog") else logging.INFO
            kore = xcore.XCore()
            try:
                init_log(llvl, log_path=None, log_color=False)
                q = QtileManager(kore, config_class(), self.display,
                                 self.sockfile)
                q.loop()
            except Exception:
                wpipe.send(traceback.format_exc())

        self.proc = multiprocessing.Process(target=run_qtile)
        self.proc.start()

        # First, wait for socket to appear
        if can_connect_qtile(self.sockfile):
            ipc_client = ipc.Client(self.sockfile)
            ipc_command = command_interface.IPCCommandInterface(ipc_client)
            self.c = command_client.InteractiveCommandClient(ipc_command)
            return
        if rpipe.poll(sleep_time):
            error = rpipe.recv()
            raise AssertionError("Error launching Qtile, traceback:\n%s" %
                                 error)
        raise AssertionError("Error launching Qtile")
Exemple #2
0
    def start(self, config_class):
        rpipe, wpipe = multiprocessing.Pipe()

        def run_qtile():
            try:
                kore = xcore.XCore(display_name=self.display)
                init_log(self.log_level, log_path=None, log_color=False)
                q = SessionManager(kore, config_class(), fname=self.sockfile)
                q.loop()
            except Exception:
                wpipe.send(traceback.format_exc())

        self.proc = multiprocessing.Process(target=run_qtile)
        self.proc.start()

        # First, wait for socket to appear
        if can_connect_qtile(self.sockfile, ok=lambda: not rpipe.poll()):
            ipc_client = ipc.Client(self.sockfile)
            ipc_command = command_interface.IPCCommandInterface(ipc_client)
            self.c = command_client.InteractiveCommandClient(ipc_command)
            return
        if rpipe.poll(sleep_time):
            error = rpipe.recv()
            raise AssertionError("Error launching Qtile, traceback:\n%s" %
                                 error)
        raise AssertionError("Error launching Qtile")
Exemple #3
0
def top(opts):
    if not ENABLED:
        raise Exception('Could not import tracemalloc')
    lines = opts.lines
    seconds = opts.seconds
    force_start = opts.force_start
    if opts.socket is None:
        socket = ipc.find_sockfile()
    else:
        socket = opts.socket
    client = ipc.Client(socket)
    client = command_interface.IPCCommandInterface(client)
    client = command_client.InteractiveCommandClient(client)

    try:
        if not opts.raw:
            curses.wrapper(get_stats,
                           client,
                           limit=lines,
                           seconds=seconds,
                           force_start=force_start)
        else:
            raw_stats(client, limit=lines, force_start=force_start)
    except TraceNotStarted:
        print("tracemalloc not started on qtile, start by setting "
              "PYTHONTRACEMALLOC=1 before starting qtile")
        print("or force start tracemalloc now, but you'll lose early traces")
        exit(1)
    except TraceCantStart:
        print("Can't start tracemalloc on qtile, check the logs")
    except KeyboardInterrupt:
        exit(-1)
Exemple #4
0
def can_connect_qtile(socket_path):
    ipc_client = ipc.Client(socket_path)
    ipc_command = command_interface.IPCCommandInterface(ipc_client)
    client = command_client.InteractiveCommandClient(ipc_command)
    val = client.status()
    if val == 'OK':
        return True
    return False
Exemple #5
0
def can_connect_qtile(socket_path, *, ok=None):
    if ok is not None and not ok():
        raise AssertionError()

    ipc_client = ipc.Client(socket_path)
    ipc_command = command_interface.IPCCommandInterface(ipc_client)
    client = command_client.InteractiveCommandClient(ipc_command)
    val = client.status()
    if val == 'OK':
        return True
    return False
Exemple #6
0
def qshell(args) -> None:
    if args.socket is None:
        socket = ipc.find_sockfile()
    else:
        socket = args.socket
    client = ipc.Client(socket, is_json=args.is_json)
    cmd_object = command_interface.IPCCommandInterface(client)
    qsh = sh.QSh(cmd_object)
    if args.command is not None:
        qsh.process_line(args.command)
    else:
        qsh.loop()
Exemple #7
0
def main() -> None:
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--version',
        action='version',
        version='%(prog)s 0.3',
    )
    parser.add_argument(
        "-s", "--socket",
        action="store", type=str,
        default=None,
        help='Use specified socket to connect to qtile.'
    )
    parser.add_argument(
        "-r", "--run",
        action="store", type=str,
        default=None,
        dest="pyfile",
        help='The full path to python file with the \"main\" function to call.'
    )
    parser.add_argument(
        "-c", "--command",
        action="store", type=str,
        default=None,
        help='Run the specified qshell command and exit.'
    )
    parser.add_argument(
        "-j", "--json",
        action="store_true",
        default=False,
        dest="is_json",
        help='Use json in order to communicate with qtile server.'
    )

    args = parser.parse_args()

    if args.socket is None:
        socket = ipc.find_sockfile()
    else:
        socket = args.socket
    client = ipc.Client(socket, is_json=args.is_json)
    cmd_object = command_interface.IPCCommandInterface(client)
    qsh = sh.QSh(cmd_object)
    if args.pyfile is None:
        if args.command is not None:
            qsh.process_line(args.command)
        else:
            qsh.loop()
    else:
        print(qsh.process_line("run_external({})".format(args.pyfile)))
Exemple #8
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     socket_path = ipc.find_sockfile()
     ipc_client = ipc.Client(socket_path)
     cmd_object = command_interface.IPCCommandInterface(ipc_client)
     self.qsh = sh.QSh(cmd_object)