summaryrefslogtreecommitdiff
path: root/bin
diff options
authorPMR <pmr@pmr-lander>2019-01-08 17:26:51 +0000
committerPMR <pmr@pmr-lander>2019-01-08 17:26:51 +0000
commit75b1e3702bee6bcb3782d833f35edf1c6a899075 (patch)
tree35c06c3d295bbae9b8f64ae8a2ac9cb58fe01f0c /bin
parenta497f396944c52579db21f66075ac058f41386ff (diff)
parent34163f4435a46984f6193c676928fe842f139362 (diff)
Merge #361202 from ~jocave/plainbox-provider-checkbox:bluetooth-detect-job
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bt_list_adapters.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/bin/bt_list_adapters.py b/bin/bt_list_adapters.py
new file mode 100755
index 0000000..e791442
--- /dev/null
+++ b/bin/bt_list_adapters.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+#
+# This file is part of Checkbox.
+#
+# Copyright 2018 Canonical Ltd.
+#
+# Authors:
+# Jonathan Cave <jonathan.cave@canonical.com>
+#
+# Checkbox is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3,
+# as published by the Free Software Foundation.
+#
+# Checkbox is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
+
+import os
+
+
+def main():
+ rfkill = '/sys/class/rfkill'
+ found_adatper = False
+ for rfdev in os.listdir(rfkill):
+ typef = os.path.join(rfkill, rfdev, 'type')
+ type = ''
+ with open(typef, 'r') as f:
+ type = f.read().strip()
+ if type != 'bluetooth':
+ continue
+ found_adatper = True
+ namef = os.path.join(rfkill, rfdev, 'name')
+ name = ''
+ with open(namef, 'r') as f:
+ name = f.read().strip()
+ print(rfdev, name)
+ if found_adatper == False:
+ raise SystemExit('No bluetooth adatpers registered with rfkill')
+
+
+if __name__ == "__main__":
+ main()