[Tutor] To check for empty string after a portion of the string in python 3.6
srinivasan
srinivasan.rns at gmail.com
Mon Dec 3 16:16:30 EST 2018
Dear Python Experts,
Could you please help me, as am still learning python syntax, how can
I add conditional check for empty string after running "hcitool scan"
(ie., when there is no Bluetooth devices discovered) ie., after the
word "Scanning..." , when there are no Bluetooth discover-able
devices and then return False in the below python code snippet?
Command:
~$ sudo hcitool scan
Scanning ... -------------------------->
When there are no BT devices
~$ sudo hcitool scan
Scanning ...
64:A2:F9:06:63:79 OnePlus 6 ---------------------------> When there
are BT devices
~$
Python code snippet:
def bluetooth_scan(self):
"""
Start bluetooth scanning process.
:return: Return device info by mac address and name.
"""
cmd = "sudo hciconfig hci0 up"
self._helper.execute_cmd_return_code(cmd)
cmd = "sudo hcitool scan"
res = self._helper.execute_cmd_output_string(cmd)
return res
Many Thanks in advance,
More information about the Tutor
mailing list