diff options
author | Jonathan Cave <jonathan.cave@canonical.com> | 2018-12-20 14:37:37 +0000 |
---|---|---|
committer | Jonathan Cave <jonathan.cave@canonical.com> | 2018-12-21 17:21:48 +0000 |
commit | 34163f4435a46984f6193c676928fe842f139362 (patch) | |
tree | cad37ffd3cad5aefca8e4b3ad2a40f1e4b3f8a51 /bin | |
parent | f60cac039edfb1337857878a96b5f9dd4450bc94 (diff) |
bluetooth: create bluetooth detect job
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bt_list_adapters.py | 46 |
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 00000000..e7914428 --- /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() |