1
0
forked from drath/libratbag

Fix flake-8 complains

Piper already uses this, we might as well.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Benjamin Tissoires
2017-07-12 07:08:17 +02:00
parent 499ebc7d18
commit 89d071bb80
4 changed files with 27 additions and 16 deletions

3
.flake8 Normal file
View File

@@ -0,0 +1,3 @@
[flake8]
ignore = E402,E501
exclude = .git,__pycache__,build,data,piper/piper.py

View File

@@ -524,7 +524,7 @@ install_man('tools/ratbagctl.1')
config_ratbagctl_devel = configuration_data()
config_ratbagctl_devel.set('ratbagd_sha', ratbagd_sha)
config_ratbagctl_devel.set_quoted('MESON_BUILD_ROOT', meson.build_root())
config_ratbagctl_devel.set('MESON_BUILD_ROOT', meson.build_root())
configure_file(input : 'tools/ratbagctl.devel.in',
output : 'ratbagctl.devel',
configuration : config_ratbagctl_devel)

View File

@@ -29,12 +29,11 @@ import os
import shutil
import subprocess
import sys
import time
if not os.geteuid() == 0:
sys.exit('Script must be run as root')
SCRIPT_DIR = @MESON_BUILD_ROOT@
SCRIPT_DIR = '@MESON_BUILD_ROOT@'
# first copy the policy for the ratbagd daemon to be allowed to run
shutil.copy(os.path.join(SCRIPT_DIR, 'org.freedesktop.ratbag_devel1.conf'),

View File

@@ -594,21 +594,24 @@ class RatbagdLed(_RatbagdDBus):
"""
return self._dbus_call("SetBrightness", "u", brightness)
def list_devices(r, args):
for d in r.devices:
print("{:10s} {:32s}".format(d.id + ":", d.name))
def find_device(r, args):
dev = None
for d in r.devices:
if d.id == args.device:
dev = d
break;
break
if dev is None:
print("Unable to find device {}".format(args.device))
sys.exit(1)
return dev
def find_profile(r, args):
d = find_device(r, args)
try:
@@ -618,6 +621,7 @@ def find_profile(r, args):
sys.exit(1)
return p, d
def find_resolution(r, args):
p, d = find_profile(r, args)
try:
@@ -627,6 +631,7 @@ def find_resolution(r, args):
sys.exit(1)
return r, p, d
def find_button(r, args):
p, d = find_profile(r, args)
try:
@@ -636,18 +641,18 @@ def find_button(r, args):
sys.exit(1)
return b, p, d
def show_device(r, args):
d = find_device(r, args)
caps = { RatbagdDevice.CAP_SWITCHABLE_RESOLUTION : "switchable-resolution",
RatbagdDevice.CAP_SWITCHABLE_PROFILE : "switchable-profile",
RatbagdDevice.CAP_BUTTON_KEY : "button-keys",
RatbagdDevice.CAP_BUTTON_MACROS : "button-macros",
RatbagdDevice.CAP_DEFAULT_PROFILE : "default-profile",
RatbagdDevice.CAP_QUERY_CONFIGURATION : "query-configuration",
RatbagdDevice.CAP_DISABLE_PROFILE : "disable-profile",
RatbagdDevice.CAP_LED : "led" }
caps = {RatbagdDevice.CAP_SWITCHABLE_RESOLUTION: "switchable-resolution",
RatbagdDevice.CAP_SWITCHABLE_PROFILE: "switchable-profile",
RatbagdDevice.CAP_BUTTON_KEY: "button-keys",
RatbagdDevice.CAP_BUTTON_MACROS: "button-macros",
RatbagdDevice.CAP_DEFAULT_PROFILE: "default-profile",
RatbagdDevice.CAP_QUERY_CONFIGURATION: "query-configuration",
RatbagdDevice.CAP_DISABLE_PROFILE: "disable-profile",
RatbagdDevice.CAP_LED: "led"}
capabilities = [caps[c] for c in d.capabilities]
print("{} - {}".format(d.id, d.name))
@@ -661,6 +666,7 @@ def show_device(r, args):
break
print(" Active Profile: {}".format(active))
def show_profile(r, args):
p, d = find_profile(r, args)
@@ -677,6 +683,7 @@ def show_profile(r, args):
print(" Active Resolution: {}".format(active))
print(" Default Resolution: {}".format(default))
def show_resolution(r, args):
r, p, d = find_resolution(r, args)
@@ -690,12 +697,12 @@ def show_resolution(r, args):
else:
print(" Resolution: {}dpi".format(r.resolution[0]))
caps = { RatbagdResolution.CAP_INDIVIDUAL_REPORT_RATE : "individual-report-rate",
RatbagdResolution.CAP_SEPARATE_XY_RESOLUTION : "separate-xy-resolution" }
caps = {RatbagdResolution.CAP_INDIVIDUAL_REPORT_RATE: "individual-report-rate",
RatbagdResolution.CAP_SEPARATE_XY_RESOLUTION: "separate-xy-resolution"}
capabilities = [caps[c] for c in r.capabilities]
print(" Capabilities: {}".format(", ".join(capabilities)))
def show_button(r, args):
b, p, d = find_button(r, args)
@@ -714,6 +721,7 @@ def show_button(r, args):
elif b.action_type == "special":
print("Special Mapping: {}".format(b.special))
def make_parser():
parser = argparse.ArgumentParser(description="Inspect and modify configurable mice")
parser.add_argument("-V", "--version", action="version", version="@version@")
@@ -745,6 +753,7 @@ def make_parser():
return parser
def main(argv):
if not argv:
argv = ["list-devices"]