Skip to content

Commit

Permalink
Merge pull request #4741 from pymedusa/feature/flake8-quotes
Browse files Browse the repository at this point in the history
Add quotes checker (Python)
  • Loading branch information
medariox authored Jul 28, 2018
2 parents 4019121 + cc13cea commit dfe63ec
Show file tree
Hide file tree
Showing 98 changed files with 603 additions and 591 deletions.
6 changes: 3 additions & 3 deletions medusa/clients/torrent/deluge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,9 @@ def _set_torrent_ratio(self, result):

elif ratio and float(ratio) == -1:
# Disable stop at ratio to seed forever
post_data = json.dumps({"method": "core.set_torrent_stop_at_ratio",
"params": [result.hash, False],
"id": 5})
post_data = json.dumps({'method': 'core.set_torrent_stop_at_ratio',
'params': [result.hash, False],
'id': 5})

self._request(method='post', data=post_data)

Expand Down
2 changes: 1 addition & 1 deletion medusa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def change_GIT_PATH():
"""
app.version_check_scheduler = None
app.version_check_scheduler = scheduler.Scheduler(
CheckVersion(), cycleTime=datetime.timedelta(hours=app.UPDATE_FREQUENCY), threadName="CHECKVERSION", silent=False)
CheckVersion(), cycleTime=datetime.timedelta(hours=app.UPDATE_FREQUENCY), threadName='CHECKVERSION', silent=False)
app.version_check_scheduler.enable = True
app.version_check_scheduler.start()
app.version_check_scheduler.forceRun()
Expand Down
2 changes: 1 addition & 1 deletion medusa/databases/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# coding=utf-8

from __future__ import unicode_literals
__all__ = ["main_db", "cache_db", "failed_db"]
__all__ = ['main_db', 'cache_db', 'failed_db']
98 changes: 49 additions & 49 deletions medusa/databases/cache_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
# and subclass the previous migration.
class InitialSchema(db.SchemaUpgrade):
def test(self):
return self.hasTable("db_version")
return self.hasTable('db_version')

def execute(self):
queries = [
("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);",),
("CREATE TABLE lastSearch (provider TEXT, time NUMERIC);",),
("CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,"
" show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);",),
("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);",),
("CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);",),
("CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);",),
("CREATE TABLE db_version (db_version INTEGER);",),
("INSERT INTO db_version(db_version) VALUES (1);",),
('CREATE TABLE lastUpdate (provider TEXT, time NUMERIC);',),
('CREATE TABLE lastSearch (provider TEXT, time NUMERIC);',),
('CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,'
' show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);',),
('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);',),
('CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);',),
('CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);',),
('CREATE TABLE db_version (db_version INTEGER);',),
('INSERT INTO db_version(db_version) VALUES (1);',),
]
for query in queries:
if len(query) == 1:
Expand All @@ -40,110 +40,110 @@ def execute(self):

class AddSceneExceptions(InitialSchema):
def test(self):
return self.hasTable("scene_exceptions")
return self.hasTable('scene_exceptions')

def execute(self):
self.connection.action(
"CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER, show_name TEXT);")
'CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER, show_name TEXT);')


class AddSceneNameCache(AddSceneExceptions):
def test(self):
return self.hasTable("scene_names")
return self.hasTable('scene_names')

def execute(self):
self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);")
self.connection.action('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);')


class AddNetworkTimezones(AddSceneNameCache):
def test(self):
return self.hasTable("network_timezones")
return self.hasTable('network_timezones')

def execute(self):
self.connection.action("CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);")
self.connection.action('CREATE TABLE network_timezones (network_name TEXT PRIMARY KEY, timezone TEXT);')


class AddLastSearch(AddNetworkTimezones):
def test(self):
return self.hasTable("lastSearch")
return self.hasTable('lastSearch')

def execute(self):
self.connection.action("CREATE TABLE lastSearch (provider TEXT, time NUMERIC);")
self.connection.action('CREATE TABLE lastSearch (provider TEXT, time NUMERIC);')


class AddSceneExceptionsSeasons(AddLastSearch):
def test(self):
return self.hasColumn("scene_exceptions", "season")
return self.hasColumn('scene_exceptions', 'season')

def execute(self):
self.addColumn("scene_exceptions", "season", "NUMERIC", -1)
self.addColumn('scene_exceptions', 'season', 'NUMERIC', -1)


class AddSceneExceptionsCustom(AddSceneExceptionsSeasons): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "custom")
return self.hasColumn('scene_exceptions', 'custom')

def execute(self):
self.addColumn("scene_exceptions", "custom", "NUMERIC", 0)
self.addColumn('scene_exceptions', 'custom', 'NUMERIC', 0)


class AddSceneExceptionsRefresh(AddSceneExceptionsCustom): # pylint:disable=too-many-ancestors
def test(self):
return self.hasTable("scene_exceptions_refresh")
return self.hasTable('scene_exceptions_refresh')

def execute(self):
self.connection.action(
"CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);")
'CREATE TABLE scene_exceptions_refresh (list TEXT PRIMARY KEY, last_refreshed INTEGER);')


class ConvertSceneExeptionsToIndexerScheme(AddSceneExceptionsRefresh): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "indexer_id")
return self.hasColumn('scene_exceptions', 'indexer_id')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_exceptions;")
self.connection.action("ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;")
self.connection.action("CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,"
" show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);")
self.connection.action("INSERT INTO scene_exceptions SELECT exception_id, tvdb_id as indexer_id, show_name,"
" season, custom FROM tmp_scene_exceptions;")
self.connection.action("DROP TABLE tmp_scene_exceptions;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_exceptions;')
self.connection.action('ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;')
self.connection.action('CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer_id INTEGER,'
' show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);')
self.connection.action('INSERT INTO scene_exceptions SELECT exception_id, tvdb_id as indexer_id, show_name,'
' season, custom FROM tmp_scene_exceptions;')
self.connection.action('DROP TABLE tmp_scene_exceptions;')


class ConvertSceneNamesToIndexerScheme(AddSceneExceptionsRefresh): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_names", "indexer_id")
return self.hasColumn('scene_names', 'indexer_id')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_names;")
self.connection.action("ALTER TABLE scene_names RENAME TO tmp_scene_names;")
self.connection.action("CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);")
self.connection.action("INSERT INTO scene_names SELECT * FROM tmp_scene_names;")
self.connection.action("DROP TABLE tmp_scene_names;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_names;')
self.connection.action('ALTER TABLE scene_names RENAME TO tmp_scene_names;')
self.connection.action('CREATE TABLE scene_names (indexer_id INTEGER, name TEXT);')
self.connection.action('INSERT INTO scene_names SELECT * FROM tmp_scene_names;')
self.connection.action('DROP TABLE tmp_scene_names;')


class RemoveIndexerUpdateSchema(ConvertSceneNamesToIndexerScheme): # pylint:disable=too-many-ancestors
def test(self):
return not self.hasTable("indexer_update")
return not self.hasTable('indexer_update')

def execute(self):
self.connection.action("DROP TABLE indexer_update;")
self.connection.action('DROP TABLE indexer_update;')


class AddIndexerSceneExceptions(RemoveIndexerUpdateSchema): # pylint:disable=too-many-ancestors
def test(self):
return self.hasColumn("scene_exceptions", "indexer")
return self.hasColumn('scene_exceptions', 'indexer')

def execute(self):
self.connection.action("DROP TABLE IF EXISTS tmp_scene_exceptions;")
self.connection.action("ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;")
self.connection.action('DROP TABLE IF EXISTS tmp_scene_exceptions;')
self.connection.action('ALTER TABLE scene_exceptions RENAME TO tmp_scene_exceptions;')
self.connection.action(
"CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer INTEGER, indexer_id INTEGER, "
"show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);")
'CREATE TABLE scene_exceptions (exception_id INTEGER PRIMARY KEY, indexer INTEGER, indexer_id INTEGER, '
'show_name TEXT, season NUMERIC DEFAULT -1, custom NUMERIC DEFAULT 0);')
self.connection.action(
"INSERT INTO scene_exceptions SELECT exception_id, 1, indexer_id, show_name, season,"
"custom FROM tmp_scene_exceptions;")
self.connection.action("DROP TABLE tmp_scene_exceptions;")
'INSERT INTO scene_exceptions SELECT exception_id, 1, indexer_id, show_name, season,'
'custom FROM tmp_scene_exceptions;')
self.connection.action('DROP TABLE tmp_scene_exceptions;')


class AddIndexerIds(AddIndexerSceneExceptions):
Expand Down Expand Up @@ -196,5 +196,5 @@ def clear_provider_tables(self):
def inc_major_version(self):
major_version, minor_version = self.connection.version
major_version += 1
self.connection.action("UPDATE db_version SET db_version = ?;", [major_version])
self.connection.action('UPDATE db_version SET db_version = ?;', [major_version])
return self.connection.version
8 changes: 4 additions & 4 deletions medusa/databases/failed_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def translate_status(self):
def inc_major_version(self):
major_version, minor_version = self.connection.version
major_version += 1
self.connection.action("UPDATE db_version SET db_version = ?;", [major_version])
self.connection.action('UPDATE db_version SET db_version = ?;', [major_version])
return self.connection.version


Expand All @@ -185,16 +185,16 @@ def shift_history_qualities(self):
This makes it possible to set UNKNOWN as 1, making it the lowest quality.
"""
log.info('Shift qualities in history one place to the left.')
sql_results = self.connection.select("SELECT quality FROM history GROUP BY quality ORDER BY quality DESC;")
sql_results = self.connection.select('SELECT quality FROM history GROUP BY quality ORDER BY quality DESC;')
for result in sql_results:
quality = result[b'quality']
new_quality = quality << 1
self.connection.action(
"UPDATE history SET quality = ? WHERE quality = ?;",
'UPDATE history SET quality = ? WHERE quality = ?;',
[new_quality, quality]
)

def update_status_unknown(self):
"""Change any `UNKNOWN` quality to 1."""
log.info(u'Update status UNKONWN from tv_episodes')
self.connection.action("UPDATE history SET quality = 1 WHERE quality = 65536;")
self.connection.action('UPDATE history SET quality = 1 WHERE quality = 65536;')
Loading

0 comments on commit dfe63ec

Please sign in to comment.