mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 19:52:16 +00:00
Fixed DeprecationWarnings
This commit is contained in:
parent
420003dfc1
commit
fd67eb9cd4
@ -196,7 +196,7 @@ def lyrics():
|
|||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
# Lyrics file couldn't be decoded. Rather than displaying an error, try with the potential next files or
|
# Lyrics file couldn't be decoded. Rather than displaying an error, try with the potential next files or
|
||||||
# return no lyrics. Log it anyway.
|
# return no lyrics. Log it anyway.
|
||||||
app.logger.warn('Unsupported encoding for lyrics file ' + lyrics_path)
|
app.logger.warning('Unsupported encoding for lyrics file ' + lyrics_path)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return request.formatter(dict(lyrics = dict(
|
return request.formatter(dict(lyrics = dict(
|
||||||
@ -217,7 +217,7 @@ def lyrics():
|
|||||||
_value_ = root.find('cl:Lyric', namespaces = ns).text
|
_value_ = root.find('cl:Lyric', namespaces = ns).text
|
||||||
)))
|
)))
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
app.logger.warn('Error while requesting the ChartLyrics API: ' + str(e))
|
app.logger.warning('Error while requesting the ChartLyrics API: ' + str(e))
|
||||||
|
|
||||||
return request.formatter(dict(lyrics = dict()))
|
return request.formatter(dict(lyrics = dict()))
|
||||||
|
|
||||||
|
@ -92,14 +92,14 @@ class LastFm:
|
|||||||
else:
|
else:
|
||||||
r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs)
|
r = requests.get('http://ws.audioscrobbler.com/2.0/', params = kwargs)
|
||||||
except requests.exceptions.RequestException as e:
|
except requests.exceptions.RequestException as e:
|
||||||
self.__logger.warn('Error while connecting to LastFM: ' + str(e))
|
self.__logger.warning('Error while connecting to LastFM: ' + str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
json = r.json()
|
json = r.json()
|
||||||
if 'error' in json:
|
if 'error' in json:
|
||||||
if json['error'] in (9, '9'):
|
if json['error'] in (9, '9'):
|
||||||
self.__user.lastfm_status = False
|
self.__user.lastfm_status = False
|
||||||
self.__logger.warn('LastFM error %i: %s' % (json['error'], json['message']))
|
self.__logger.warning('LastFM error %i: %s' % (json['error'], json['message']))
|
||||||
|
|
||||||
return json
|
return json
|
||||||
|
|
||||||
|
@ -24,6 +24,11 @@ class DbTestCase(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
db.init_database('sqlite:', True)
|
db.init_database('sqlite:', True)
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.assertRegex
|
||||||
|
except AttributeError:
|
||||||
|
self.assertRegex = self.assertRegexpMatches
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.release_database()
|
db.release_database()
|
||||||
|
|
||||||
@ -118,7 +123,7 @@ class DbTestCase(unittest.TestCase):
|
|||||||
self.assertTrue(root['isDir'])
|
self.assertTrue(root['isDir'])
|
||||||
self.assertEqual(root['title'], 'Root folder')
|
self.assertEqual(root['title'], 'Root folder')
|
||||||
self.assertEqual(root['album'], 'Root folder')
|
self.assertEqual(root['album'], 'Root folder')
|
||||||
self.assertRegexpMatches(root['created'], date_regex)
|
self.assertRegex(root['created'], date_regex)
|
||||||
|
|
||||||
child = child_folder.as_subsonic_child(user)
|
child = child_folder.as_subsonic_child(user)
|
||||||
self.assertIn('parent', child)
|
self.assertIn('parent', child)
|
||||||
@ -153,7 +158,7 @@ class DbTestCase(unittest.TestCase):
|
|||||||
self.assertIn('starred', root)
|
self.assertIn('starred', root)
|
||||||
self.assertIn('userRating', root)
|
self.assertIn('userRating', root)
|
||||||
self.assertIn('averageRating', root)
|
self.assertIn('averageRating', root)
|
||||||
self.assertRegexpMatches(root['starred'], date_regex)
|
self.assertRegex(root['starred'], date_regex)
|
||||||
self.assertEqual(root['userRating'], 2)
|
self.assertEqual(root['userRating'], 2)
|
||||||
self.assertEqual(root['averageRating'], 3.5)
|
self.assertEqual(root['averageRating'], 3.5)
|
||||||
|
|
||||||
@ -176,7 +181,7 @@ class DbTestCase(unittest.TestCase):
|
|||||||
self.assertIn('starred', artist_dict)
|
self.assertIn('starred', artist_dict)
|
||||||
self.assertEqual(artist_dict['name'], 'Test Artist')
|
self.assertEqual(artist_dict['name'], 'Test Artist')
|
||||||
self.assertEqual(artist_dict['albumCount'], 0)
|
self.assertEqual(artist_dict['albumCount'], 0)
|
||||||
self.assertRegexpMatches(artist_dict['starred'], date_regex)
|
self.assertRegex(artist_dict['starred'], date_regex)
|
||||||
|
|
||||||
db.Album(name = 'Test Artist', artist = artist) # self-titled
|
db.Album(name = 'Test Artist', artist = artist) # self-titled
|
||||||
db.Album(name = 'The Album After The First One', artist = artist)
|
db.Album(name = 'The Album After The First One', artist = artist)
|
||||||
@ -215,8 +220,8 @@ class DbTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(album_dict['artistId'], str(artist.id))
|
self.assertEqual(album_dict['artistId'], str(artist.id))
|
||||||
self.assertEqual(album_dict['songCount'], 2)
|
self.assertEqual(album_dict['songCount'], 2)
|
||||||
self.assertEqual(album_dict['duration'], 8)
|
self.assertEqual(album_dict['duration'], 8)
|
||||||
self.assertRegexpMatches(album_dict['created'], date_regex)
|
self.assertRegex(album_dict['created'], date_regex)
|
||||||
self.assertRegexpMatches(album_dict['starred'], date_regex)
|
self.assertRegex(album_dict['starred'], date_regex)
|
||||||
|
|
||||||
@db_session
|
@db_session
|
||||||
def test_track(self):
|
def test_track(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user