Only reading/writing full sectors are allowed (because we need to set and
read the crc anyway).
Fixes#122
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Starting with -vv, we print out the ratbagd log messages to stdout/stderr,
-vvv switches ratbagd to raw mode. We start at level 2 so that we can have the
single -v reserved for ratbagctl itself.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Plan is to remove the key mapping altogether and make it transparent from the
Macro mappings (in libratbag/the drivers). Meanwhile, remove the DBus API so
nothing can actually start using it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If we leave ratbagctl.devel too soon, ratbagd gets killed before it even
receives the async call for commmit(), meaning everything we do on the
device is lost.
0.5 is empirical. It seems on my system 0.2 is enough (0.1 doesn't seem
to work). Hopefully this value is not device dependent.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
not sure why, but stat.S_IEXEC only sets exec permission for the user,
meaning that the installed file can't be run by anybody else than root.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
A quick and easy way to sync anything coming from dbus (like property updates)
without needing to be hooked into a glib mainloop directly.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Some devices can have a custom name, so let's export that capability.
In ratbagd, libratbag/ratbag_profile_set_name() returns an error, we
put it under silence, the client has to check for the capabilities
before asking ratbagd to change the profile name.
Fixes: #266
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
If we couldn't find the name on the bus or the ratbagd process already
terminated, return None and fail.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
I originally intended to have a dynamic use of argparse to generate
the commands, but it turned out to be a nightmare.
Just go down the tree of arguments and format the help properly.
Fixes#288
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We shouldn't try to access input_string[0] if len(input_string) is null.
Meaning a condition in the break in the while loop could be checked
earlier (or later).
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
ns is never reset, so once it has a subparser, it'll keep it, so the try
catch is just too much
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Calling "ratbagctl profile -t" resulted in an infinite loop because it
tried again and again to parse "-t" in the profile
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Too easy to trigger ("ratbagctl.devel profile" is just enough), so we
probably better have a proper usage call here.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
.parse did not consumed the input_string, it only appends the given
parsing to the parent. Rename the function and kill the debug output
in nested calls as this was misleading while re-reading the code.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
The help option (or verbose FWIW) were not global which makes some random
behavior when using -h at different places for the input string.
Retrieve those options once and remove them from the list of things to
process.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
"sudo ./build/ratbagctl.devel profile 2 4" returns an exception with cmd
being unknown.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Keeps the ratbagd daemon running until a signal is received. This is helpful
for using an external client (like piper) to run against the ratbagd.devel
instance. And to make that even easier, print the RATBAGCTL_DEVEL environment
variable for use with ratbagd.py. In the future, this should probably be a
more generic name.
The integration is a bit odd because we need to add --keepalive to the actual
parser, but we recreate that on every parse() call. So we set a flag on the
parent object and check for that during parser creation.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Don't automatically handle the help output - call print_help() on the parser
manually.
It's unclear why this doesn't just get called correctly, but at least this
fixes the immediate issue. The subcommand help is still pretty terrible
though.
https://github.com/libratbag/libratbag/issues/288
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We do not really care using the actual ratbagctl command, we just want
to run it. So we can simply call out the python functions directly
and live happily ever after.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
We want to share as much as possible between ratbagctl.devel and
ratbagctl.test, so better have a separate file that knows how to
properly spawn the dbus daemon and terminate it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
On CircleCI, the builds fail one over four times because we are launching
the testsuite while ratbagd.devel is still not ready.
Do a basic polling after we launch the daemon so that we are aware when
the ratbagd daemon is ready.
A proper solution would be to use "new" for querying the proxy, not
"new_sync". However, this would require us to have a GTK mainloop
running, so it's a PITA.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>