コード例 #1
0
def test_no_two_qtiles(qtile):
    try:
        xcore.XCore(qtile.display)
    except xcore.ExistingWMException:
        pass
    else:
        raise Exception("excpected an error on multiple qtiles connecting")
コード例 #2
0
def validate_config():
    output = [
        "The configuration file '",
        __file__,
        "' generated the following error:\n\n",
    ]

    try:
        # mandatory: we must reload the module (the config file was modified)
        importlib.reload(sys.modules[__name__])
        Config.from_file(xcore.XCore(), __file__)

    except ConfigError as error:
        output.append(str(error))

        # handle the case when a key is erroneous
        # more cases could be handled maybe
        if str(error).startswith("No such key"):
            output.append("\n\n")
            key = str(error).replace("No such key: ", "")
            try:
                similar_keys = find_similar_keys(key)
            except ImportError:
                output.append(
                    "Install 'regex' if you want to see valid similar keys")
            else:
                output.append(similar_keys)
        raise ConfigError("".join(output))

    except Exception as error:
        # here we handle SyntaxError and the likes
        # print("ERROR DE SINTAXIS")
        output.append("{}: {}".format(sys.exc_info()[0].__name__, str(error)))
        raise ConfigError("".join(output))
コード例 #3
0
 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())
コード例 #4
0
ファイル: test_config.py プロジェクト: yoryo33/qtile
def test_falls_back():
    xc = xcore.XCore()
    f = confreader.Config.from_file(
        xc, os.path.join(tests_dir, "configs", "basic.py"))

    # We just care that it has a default, we don't actually care what the
    # default is; don't assert anything at all about the default in case
    # someone changes it down the road.
    assert hasattr(f, "follow_mouse_focus")
コード例 #5
0
    def create_manager(self, config_class):
        """Create a Qtile manager instance in this thread

        This should only be used when it is known that the manager will throw
        an error and the returned manager should not be started, otherwise this
        will likely block the thread.
        """
        init_log(self.log_level, log_path=None, log_color=False)
        kore = xcore.XCore(display_name=self.display)
        config = config_class()
        for attr in dir(default_config):
            if not hasattr(config, attr):
                setattr(config, attr, getattr(default_config, attr))

        return SessionManager(kore, config, fname=self.sockfile)
コード例 #6
0
def test_validate():
    xc = xcore.XCore()
    f = confreader.Config(os.path.join(tests_dir, "configs", "basic.py"), xc)
    f.load()
    f.keys[0].key = "nonexistent"
    with pytest.raises(confreader.ConfigError):
        f.validate()

    f.keys[0].key = "x"
    f = confreader.Config(os.path.join(tests_dir, "configs", "basic.py"), xc)
    f.load()
    f.keys[0].modifiers = ["nonexistent"]
    with pytest.raises(confreader.ConfigError):
        f.validate()
    f.keys[0].modifiers = ["shift"]
コード例 #7
0
ファイル: test_config.py プロジェクト: yoryo33/qtile
def test_basic():
    xc = xcore.XCore()
    f = confreader.Config.from_file(
        xc, os.path.join(tests_dir, "configs", "basic.py"))
    assert f.keys
コード例 #8
0
ファイル: test_config.py プロジェクト: yoryo33/qtile
def test_syntaxerr():
    xc = xcore.XCore()
    with pytest.raises(confreader.ConfigError):
        confreader.Config.from_file(
            xc, os.path.join(tests_dir, "configs", "syntaxerr.py"))
コード例 #9
0
ファイル: qtile.py プロジェクト: wetw3rx/qtile
def make_qtile():
    from argparse import ArgumentParser
    parser = ArgumentParser(
        description='A full-featured, pure-Python tiling window manager.',
        prog='qtile',
    )
    parser.add_argument(
        '--version',
        action='version',
        version=VERSION,
    )
    parser.add_argument(
        "-c",
        "--config",
        action="store",
        default=path.expanduser(
            path.join(getenv('XDG_CONFIG_HOME', '~/.config'), 'qtile',
                      'config.py')),
        dest="configfile",
        help='Use the specified configuration file',
    )
    parser.add_argument("-s",
                        "--socket",
                        action="store",
                        default=None,
                        dest="socket",
                        help='Path of the Qtile IPC socket.')
    parser.add_argument("-n",
                        "--no-spawn",
                        action="store_true",
                        default=False,
                        dest="no_spawn",
                        help='Avoid spawning apps. (Used for restart)')
    parser.add_argument('-l',
                        '--log-level',
                        default='WARNING',
                        dest='log_level',
                        choices=('DEBUG', 'INFO', 'WARNING', 'ERROR',
                                 'CRITICAL'),
                        help='Set qtile log level')
    parser.add_argument(
        '--with-state',
        default=None,
        dest='state',
        help='Pickled QtileState object (typically used only internally)',
    )
    options = parser.parse_args()
    log_level = getattr(logging, options.log_level)
    init_log(log_level=log_level)
    kore = xcore.XCore()

    try:
        if not path.isfile(options.configfile):
            try:
                makedirs(path.dirname(options.configfile), exist_ok=True)
                from shutil import copyfile
                default_config_path = path.join(path.dirname(__file__), "..",
                                                "resources",
                                                "default_config.py")
                copyfile(default_config_path, options.configfile)
                logger.info('Copied default_config.py to %s',
                            options.configfile)
            except Exception as e:
                logger.exception(
                    'Failed to copy default_config.py to %s: (%s)',
                    options.configfile, e)

        config = confreader.Config.from_file(options.configfile, kore=kore)
    except Exception as e:
        logger.exception('Error while reading config file (%s)', e)
        config = confreader.Config()
        from libqtile.widget import TextBox
        widgets = config.screens[0].bottom.widgets
        widgets.insert(0, TextBox('Config Err!'))

    # XXX: the import is here because we need to call init_log
    # before start importing stuff
    from libqtile.core import session_manager
    return session_manager.SessionManager(
        kore,
        config,
        fname=options.socket,
        no_spawn=options.no_spawn,
        state=options.state,
    )
コード例 #10
0
ファイル: test_xcore.py プロジェクト: zero77/qtile
def test_keys(xephyr):
    xc = xcore.XCore()
    assert "a" in xc.get_keys()
    assert "shift" in xc.get_modifiers()
コード例 #11
0
def test_keys(qtile_nospawn):
    xc = xcore.XCore(qtile_nospawn.display)
    assert "a" in xc.get_keys()
    assert "shift" in xc.get_modifiers()