X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=musicpd.py;h=13a20a5802dd7b3a8a8fe36463300d74aa8f4622;hp=d96e76a54387fcfb7d6ac8db9be83540252edf83;hb=207435c9a3fd6c2b9ac2c04b30ab68a698d34b74;hpb=40455e48fef4d5ac8bf2c19f745d7495180e7205 diff --git a/musicpd.py b/musicpd.py index d96e76a..13a20a5 100644 --- a/musicpd.py +++ b/musicpd.py @@ -1,21 +1,11 @@ -# python-musicpd: Python MPD client library -# Copyright (C) 2012-2021 kaliko -# Copyright (C) 2019 Naglis Jonaitis -# Copyright (C) 2019 Bart Van Loon -# Copyright (C) 2008-2010 J. Alexander Treuman -# -# python-musicpd is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# python-musicpd is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with python-musicpd. If not, see . +# SPDX-FileCopyrightText: 2012-2022 kaliko +# SPDX-FileCopyrightText: 2021 Wonko der Verständige +# SPDX-FileCopyrightText: 2019 Naglis Jonaitis +# SPDX-FileCopyrightText: 2019 Bart Van Loon +# SPDX-FileCopyrightText: 2008-2010 J. Alexander Treuman +# SPDX-License-Identifier: GPL-3.0-or-later +"""python-musicpd: Python Music Player Daemon client library""" + import socket import os @@ -26,7 +16,7 @@ HELLO_PREFIX = "OK MPD " ERROR_PREFIX = "ACK " SUCCESS = "OK" NEXT = "list_OK" -VERSION = '0.8.0b0' +VERSION = '0.9.0b0' #: Seconds before a connection attempt times out #: (overriden by MPD_TIMEOUT env. var.) CONNECTION_TIMEOUT = 30 @@ -726,6 +716,13 @@ class MPDClient: self._sock.close() self._reset() + def __enter__(self): + self.connect() + return self + + def __exit__(self, exception_type, exception_value, exception_traceback): + self.disconnect() + def fileno(self): """Return the socket’s file descriptor (a small integer). This is useful with :py:obj:`select.select`.