X-Git-Url: https://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=doc%2Fsource%2Fexamples%2Fconnect_host.py;fp=doc%2Fsource%2Fexamples%2Fconnect_host.py;h=a7bdccc2c36aeac5a660717d9d47a8bdae9f87a6;hp=0000000000000000000000000000000000000000;hb=c7b2fbbb9689a180f220322b21e2b0bef798eb68;hpb=43a63d085fab34f337ceec232e29e5760f4fcc25 diff --git a/doc/source/examples/connect_host.py b/doc/source/examples/connect_host.py new file mode 100644 index 0000000..a7bdccc --- /dev/null +++ b/doc/source/examples/connect_host.py @@ -0,0 +1,17 @@ +import sys +import logging + +import musicpd + +# Set logging to debug level +logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s') + +client = musicpd.MPDClient() +try: + client.connect(host='example.lan') + client.password('secret') + client.status() +except musicpd.MPDError as err: + print(f'An error occured: {err}') +finally: + client.disconnect()