3
from flexget.manager import Session
4
from flexget.plugin import register_plugin
6
log = logging.getLogger('change')
7
found_deprecated = False
10
class ChangeWarn(object):
12
Gives warning if user has deprecated / changed configuration in the root level.
14
Will be replaced by root level validation in the future!
16
Contains ugly hacks, better to include all deprecation warnings here during 1.0 BETA phase
22
def old_database(self, feed, reason='', solution=''):
24
feed.manager.disable_feeds()
26
log.critical('You\'re running old database! Please see \'Upgrade Actions\' at flexget.com for necessary actions!')
29
log.critical('Reason : %s' % reason)
31
log.critical('Please run : %s' % solution)
33
def on_process_start(self, feed):
34
found_deprecated = False
35
config = feed.manager.config
37
if 'torrent_size' in feed.config:
38
log.critical('Plugin torrent_size is deprecated, use content_size instead')
39
found_deprecated = True
41
if 'nzb_size' in feed.config:
42
log.critical('Plugin nzb_size is deprecated, use content_size instead')
43
found_deprecated = True
45
# prevent useless keywords in root level
46
allow = ['feeds', 'presets', 'variables']
47
for key in config.iterkeys():
49
log.critical('Keyword \'%s\' is not allowed in the root level of configuration!' % key)
51
# priority (dict) was renamed to plugin_priority
52
if isinstance(feed.config.get('priority', None), dict):
53
log.critical('Plugin \'priority\' was renamed to \'plugin_priority\'')
56
from flexget.utils.sqlalchemy_utils import table_columns, table_exists
60
columns = table_columns('imdb_movies', session)
61
if not 'photo' in columns:
62
self.old_database(feed, 'photo missing from imdb_movies table')
63
if not 'updated' in columns:
64
self.old_database(feed, 'updated missing from imdb_movies table',
65
'sqlite3 %s "ALTER TABLE imdb_movies ADD updated DateTime;"' % feed.manager.db_filename)
66
if not 'mpaa_rating' in columns:
67
self.old_database(feed, 'mpaa_rating missing from imdb_movies table',
68
'sqlite3 %s "ALTER TABLE imdb_movies ADD mpaa_rating VARCHAR;"' % feed.manager.db_filename)
70
columns = table_columns('make_rss', session)
71
if not 'rsslink' in columns:
72
self.old_database(feed, 'rsslink missing from make_rss table')
74
columns = table_columns('imdb_queue', session)
75
if not 'title' in columns:
76
self.old_database(feed, 'title missing from imdb_queue table')
78
if table_exists('episode_qualities', session):
79
self.old_database(feed, 'old series format)')
81
columns = table_columns('thetvdb_favorites', session)
82
if not 'series_id' in columns:
83
self.old_database(feed, 'series_id missing from thetvdb_favorites table',
84
'sqlite3 %s "ALTER TABLE thetvdb_favorites ADD series_id VARCHAR;"' % feed.manager.db_filename)
87
feed.manager.disable_feeds()
92
register_plugin(ChangeWarn, 'change_warn', builtin=True)
94
# check that no old plugins are in pre-compiled form (pyc)
98
plugin_dir = os.path.normpath(sys.path[0] + '/../flexget/plugins/')
99
for name in os.listdir(plugin_dir):
100
require_clean = False
101
if 'resolver' in name:
104
if 'filter_torrent_size' in name:
107
if 'filter_nzb_size' in name:
110
if 'module_priority' in name:
113
if 'ignore_feed' in name:
116
if 'module_manual' in name:
119
if 'output_exec' in name:
122
if 'plugin_adv_exec' in name:
125
if 'output_transmissionrpc' in name:
129
log.critical('-' * 79)
130
log.critical('IMPORTANT: Please remove all pre-compiled .pyc and .pyo files from')
131
log.critical(' path: %s' % plugin_dir)
132
log.critical(' After this FlexGet should run again normally')
133
log.critical('-' * 79)
134
found_deprecated = True