1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Make Python2 happy

This commit is contained in:
spl0k 2019-04-13 16:02:32 +02:00
parent 5b0b5ff29b
commit c7f1499d46

View File

@ -38,20 +38,20 @@ class DaemonClient(object):
raise DaemonUnavailableError('No daemon address set') raise DaemonUnavailableError('No daemon address set')
try: try:
return Client(address = self.__address, authkey = self.__key) return Client(address = self.__address, authkey = self.__key)
except (FileNotFoundError, ConnectionRefusedError): except IOError:
raise DaemonUnavailableError("Couldn't connect to daemon at {}".format(self.__address)) raise DaemonUnavailableError("Couldn't connect to daemon at {}".format(self.__address))
def add_watched_folder(self, folder): def add_watched_folder(self, folder):
if not isinstance(folder, strtype): if not isinstance(folder, strtype):
raise TypeError('Expecting string, got ' + str(type(folder))) raise TypeError('Expecting string, got ' + str(type(folder)))
with self.__get_connection() as c: with self.__get_connection() as c:
c.send((WATCHER, W_ADD, folder)) c.send((WATCHER, W_ADD, (folder,)))
def remove_watched_folder(self, folder): def remove_watched_folder(self, folder):
if not isinstance(folder, strtype): if not isinstance(folder, strtype):
raise TypeError('Expecting string, got ' + str(type(folder))) raise TypeError('Expecting string, got ' + str(type(folder)))
with self.__get_connection() as c: with self.__get_connection() as c:
c.send((WATCHER, W_DEL, folder)) c.send((WATCHER, W_DEL, (folder,)))
class Daemon(object): class Daemon(object):
def __init__(self, address): def __init__(self, address):
@ -61,7 +61,7 @@ class Daemon(object):
def __handle_connection(self, connection): def __handle_connection(self, connection):
try: try:
module, cmd, *args = connection.recv() module, cmd, args = connection.recv()
if module == WATCHER: if module == WATCHER:
if cmd == W_ADD: if cmd == W_ADD:
self.__watcher.add_folder(*args) self.__watcher.add_folder(*args)