#pyagl ## Basic info Python library with bindings and tests for Automotive Grade Linux services Currently the library works only with images built with `aglsetup.sh agl-devel`, the non-agl-devel image does not expose websockets on TCP ports. The library implements CLI-callable main() methods and argparse with --help supplements in most modules. When installing the library into a new virtualenv, the modules should be executable with `python3 -m pyagl.services. --help` - which should return CLI usage of the invoked module First positional argument is IP Address of the target board ## Examples: ```shell script $ python3 -m pyagl.services.bluetooth_pbap --help usage: bluetooth_pbap.py [-h] [-l {CRITICAL,FATAL,ERROR,WARN,WARNING,INFO,DEBUG,NOTSET}] [--port PORT] [--listener] [--subscribe event] [--unsubscribe event] [--json JSON] [--verb VERB] [--api API] [--import_contacts] [--status] [--contacts] [--history HISTORY] ipaddr Utility to interact with agl-service-* via it's websocket positional arguments: ipaddr AGL host address optional arguments: -h, --help show this help message and exit -l {CRITICAL,FATAL,ERROR,WARN,WARNING,INFO,DEBUG,NOTSET}, --loglevel {CRITICAL,FATAL,ERROR,WARN,WARNING,INFO,DEBUG,NOTSET} Level of logging verbosity --port PORT AGL service websocket port --listener Register a listener for incoming events --subscribe event Subscribe to event type --unsubscribe event Unsubscribe from event type --import_contacts --status --contacts --history HISTORY Request call history - ICH/OCH/MCH/CCH ``` ```shell script $ python3 -m pyagl.services.bluetooth_pbap 192.168.234.251 --contacts Sent contacts request with messageid 896503218 [RESPONSE][Status: success][896503218][Info: contacts][Data: {'vcards': [{'fn': 'John Smith', 'telephone': [{'HOME': '+15557028324'}]}...]}, ``` Until the package is uploaded onto PyPI, either: * `git clone` the repository * `cd` into the cloned directory * `pip install .` or * `pip install` the generated zip from the repository(when public) --- ## Creating new modules Creating a new modules and tests can be done with a few steps: 1. clone the repository 2. cd \/pyagl 3. cookiecutter -f ../templates/ ## Running the tests The tests can be run either directly from the cloned repository or the default Python site-packages directory per system default or virtualenv: * for example on Debian systems the default site packages dir should be in /usr/local/lib/python3.8/dist-packages/pyagl/tests * otherwise for virtualenv - /lib/python3.8/site-packages/pyagl/tests pytest Running the tests rests on the assumptions that the following environment variables will be exported: All tests require AGL_TGT_IP and will look for AGL_TGT_PORT * AGL_TGT_IP - required - the containing the IP Address for the AGL instance * AGL_TGT_PORT - optional - if not exported, the library wil connect to the IP address via ssh to find out the service's listening TCP port * AGL_BTMAP_RECIPIENT - optional - When running Bluetooth MAP tests, this would be used as phone number to write text messages to * AGL_BTMAP_TEXT - optional - When running Bluetooth MAP tests, messages will be composed with this text * AGL_PBAP_PHONENUM - optional - When running Bluetooth PBAP tests, this phone number will be used to .search() * AGL_PBAP_VCF - optional - Bluetooh PBAP tests - query a contact entry out of the phonebook * AGL_BT_TEST_ADDR - optional - Bluetooth tests - pair/connect/disconnect with an actual Bluetooth device(phone)'s address it should have the DBus address style as "dev_00_01_02_03_04_05" instead regular colon-separated MAC address Should some of the optional variables be omitted, the fixtures and their dependent tests should fail gracefully with "XFAIL"(expected fail) or "SKIP" result. There are tests that are dependent on other tests, therefore if the dependent tests fail, the whole test chain will be skipped.