]> kaliko git repositories - python-musicpd.git/blobdiff - doc/source/examples/connect_host.py
Add examples
[python-musicpd.git] / doc / source / examples / connect_host.py
diff --git a/doc/source/examples/connect_host.py b/doc/source/examples/connect_host.py
new file mode 100644 (file)
index 0000000..a7bdccc
--- /dev/null
@@ -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()