From d26576122eb23409a5a9796f2ba562b820d86a48 Mon Sep 17 00:00:00 2001 From: echel0n Date: Wed, 17 Dec 2014 02:23:48 -0800 Subject: [PATCH] Small SQL syntax fix --- sickbeard/tvcache.py | 10 ++++++---- tests/encoding_tests.py | 12 ------------ 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index b6fcd41a..e2ba8918 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -36,6 +36,7 @@ from sickbeard import clients from name_parser.parser import NameParser, InvalidNameException, InvalidShowException from sickbeard import encodingKludge as ek + class CacheDBConnection(db.DBConnection): def __init__(self, providerName): db.DBConnection.__init__(self, "cache.db") @@ -47,7 +48,7 @@ class CacheDBConnection(db.DBConnection): "CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT, release_group TEXT)") else: sqlResults = self.select( - "SELECT url, COUNT(url) as count FROM [" + providerName + "] GROUP BY url HAVING count > 1") + "SELECT url, COUNT(url) AS count FROM [" + providerName + "] GROUP BY url HAVING count > 1") for cur_dupe in sqlResults: self.action("DELETE FROM [" + providerName + "] WHERE url = ?", [cur_dupe["url"]]) @@ -75,6 +76,7 @@ class CacheDBConnection(db.DBConnection): if str(e) != "table lastUpdate already exists": raise + class TVCache(): def __init__(self, provider): @@ -233,7 +235,7 @@ class TVCache(): if not parse_result: # create showObj from indexer_id if available - showObj=None + showObj = None if indexer_id: showObj = helpers.findCertainShow(sickbeard.showList, indexer_id) @@ -305,8 +307,8 @@ class TVCache(): else: for epObj in episode: cl.append([ - "SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? " - "AND quality IN (" + ",".join([str(x) for x in epObj.wantedQuality]) + ")", + "SELECT * FROM [" + self.providerID + "] WHERE indexerid = ? AND season = ? AND episodes LIKE ? AND quality IN (" + ",".join( + [str(x) for x in epObj.wantedQuality]) + ")", [epObj.show.indexerid, epObj.season, "%|" + str(epObj.episode) + "|%"]]) sqlResults = myDB.mass_action(cl, fetchall=True) diff --git a/tests/encoding_tests.py b/tests/encoding_tests.py index 0f58bda3..40089b27 100644 --- a/tests/encoding_tests.py +++ b/tests/encoding_tests.py @@ -28,20 +28,8 @@ class EncodingTests(unittest.TestCase): if not sickbeard.SYS_ENCODING or sickbeard.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'): sickbeard.SYS_ENCODING = 'UTF-8' - if not hasattr(sys, "setdefaultencoding"): - reload(sys) - - try: - # pylint: disable=E1101 - # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError - sys.setdefaultencoding(sickbeard.SYS_ENCODING) - except: - sys.exit("Sorry, you MUST add the SickRage folder to the PYTHONPATH environment variable\n" + - "or find another way to force Python to use " + sickbeard.SYS_ENCODING + " for string encoding.") - for s in strings: try: - show_name = s.decode(sickbeard.SYS_ENCODING, 'xmlcharrefreplace') show_dir = ek.ek(os.path.join, rootDir, sanitizeFileName(s)) self.assertTrue(isinstance(show_dir, unicode)) except Exception, e: