%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pyc

�
���^c@@s
dZddlmZmZmZddlmZddlZ	ddl
mZeZ
yddlZeZ
Wnek
r}nXidd6ZdZd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS(u�
Support for Bluetooth (using BlueZ in Linux).

The following packages are required packages for this module:

    bluez >= 5.7
    bluez-libs >= 5.7
    bluez-utils >= 5.7
    pybluez >= 0.18
i(tabsolute_importtprint_functiontunicode_literals(tshlex_quoteN(tCommandExecutionErroruaddressuaddress_u	bluetoothcC@str
tStdfS(u8
    Only load the module if bluetooth is installed
    uIThe bluetooth execution module cannot be loaded: bluetooth not installed.(tHAS_PYBLUEZt__virtualname__tFalse(((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pyt__virtual__'scC@sad}td|�j�}|d}d}y
tj}Wntk
rN}nXi|d6|d6S(u�
    Return Bluez version from bluetoothd -v

    CLI Example:

    .. code-block:: bash

        salt '*' bluetoothd.version
    ubluetoothctl -vucmd.runiu <= 0.18 (Unknown, but installed)uBluezuPyBluez(t__salt__t
splitlinest	bluetootht__version__t	Exception(tcmdtoutt
bluez_versiontpybluez_versiontexc((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytversion0s


cC@s�i}d}td|�j�}d}x�|D]�}|jd�r�|jd�}|d}i|d6dj|�d	6||<nd
|kr�|j�}|d||d<nd
|kr�d||d<nd|kr/d||d<q/q/W|S(u�
    Get the many addresses of the Bluetooth adapter

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.address
    u	hciconfigucmd.runuuhciu:iudeviceu/sys/class/bluetooth/{0}upathu
BD AddressiuaddressuDOWNuoffupoweru
UP RUNNINGuon(R	R
t
startswithtsplittformat(tretRRtdevtlinetcomps((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytaddress_Es&


cC@s�|t�krtd��n|dks6|tkrEd}d}nd}d}dj||�}td|�j�t�}||d|kr�tStS(	u�
    Power a bluetooth device on or off

    CLI Examples:

    .. code-block:: bash

        salt '*' bluetooth.power hci0 on
        salt '*' bluetooth.power hci0 off
    u%Invalid dev passed to bluetooth.poweruonuupudownuoffuhciconfig {0} {1}ucmd.runupower(RRtTrueRR	R
R(RtmodetstateRtinfo((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytpoweres		cC@st|t�krtd��ndj|�}td|�j�dj|�}td|�}d|krptStS(u�
    Enable this bluetooth device to be discoverable.

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.discoverable hci0
    u,Invalid dev passed to bluetooth.discoverableuhciconfig {0} iscanucmd.runu
hciconfig {0}uUP RUNNING ISCAN(RRRR	R
RR(RRR((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytdiscoverable�s
cC@st|t�krtd��ndj|�}td|�j�dj|�}td|�}d|krptStS(u�
    Turn off scanning modes on this device.

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.noscan hci0
    u&Invalid dev passed to bluetooth.noscanuhciconfig {0} noscanucmd.runu
hciconfig {0}uSCAN(RRRR	R
RR(RRR((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytnoscan�s
cC@sIg}tjdt�}x*|D]"}|ji|d|d6�qW|S(u}
    Scan for bluetooth devices in the area

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.scan
    tlookup_namesii(Rtdiscover_devicesRtappend(Rtdevicestdevice((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytscan�s


 cC@sNtjjjj|�s'td��ndj|�}td|�j�dS(u�
    Block a specific bluetooth device by BD Address

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.block DE:AD:BE:EF:CA:FE
    u,Invalid BD address passed to bluetooth.blockuhciconfig {0} blockucmd.runN(	tsalttutilstvalidatetnettmacRRR	R
(tbdaddrR((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytblock�s

cC@sNtjjjj|�s'td��ndj|�}td|�j�dS(u�
    Unblock a specific bluetooth device by BD Address

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.unblock DE:AD:BE:EF:CA:FE
    u.Invalid BD address passed to bluetooth.unblockuhciconfig {0} unblockucmd.runN(	R)R*R+R,R-RRR	R
(R.R((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytunblock�s

cC@s�tjjjj|�s'td��nyt|�Wntk
rTtd��nXt�}dj	t
|d�t
|�t
|��}td|dt�j
�}|S(u�
    Pair the bluetooth adapter with a device

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.pair DE:AD:BE:EF:CA:FE 1234

    Where DE:AD:BE:EF:CA:FE is the address of the device to pair with, and 1234
    is the passphrase.

    TODO: This function is currently broken, as the bluez-simple-agent program
    no longer ships with BlueZ >= 5.0. It needs to be refactored.
    u+Invalid BD address passed to bluetooth.pairu2bluetooth.pair requires a numerical key to be usedu%echo {0} | bluez-simple-agent {1} {2}udeviceucmd.runtpython_shell(R)R*R+R,R-RtintR
RRt
_cmd_quoteR	RR
(taddresstkeytaddyRR((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytpair�s

	%cC@sPtjjjj|�s'td��ndj|�}td|�j�}|S(ul
    Unpair the bluetooth adapter from a device

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.unpair DE:AD:BE:EF:CA:FE

    Where DE:AD:BE:EF:CA:FE is the address of the device to unpair.

    TODO: This function is currently broken, as the bluez-simple-agent program
    no longer ships with BlueZ >= 5.0. It needs to be refactored.
    u-Invalid BD address passed to bluetooth.unpairubluez-test-device remove {0}ucmd.run(	R)R*R+R,R-RRR	R
(R4RR((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytunpair
scC@stdd�}|S(ut
    Start the bluetooth service.

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.start
    u
service.startu	bluetooth(R	(R((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytstart#s
cC@stdd�}|S(ur
    Stop the bluetooth service.

    CLI Example:

    .. code-block:: bash

        salt '*' bluetooth.stop
    uservice.stopu	bluetooth(R	(R((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pytstop1s
( t__doc__t
__future__RRRtsalt.ext.six.movesRR3tsalt.utils.validate.netR)tsalt.exceptionsRRRRRtImportErrort__func_alias__RRRRR R!R"R(R/R0R7R8R9R:(((s@/usr/lib/python2.7/site-packages/salt/modules/bluez_bluetooth.pyt<module>s4


				 							$		

Zerion Mini Shell 1.0