-
Notifications
You must be signed in to change notification settings - Fork 473
/
change_warn.py
111 lines (79 loc) · 3.08 KB
/
change_warn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import sys
from loguru import logger
from flexget import plugin
from flexget.event import event
logger = logger.bind(name='change')
found_deprecated = False
class ChangeWarn:
"""
Gives warning if user has deprecated / changed configuration in the root level.
Will be replaced by root level validation in the future!
Contains ugly hacks, better to include all deprecation warnings here during 1.0 BETA phase
"""
def on_task_start(self, task, config):
global found_deprecated
if 'torrent_size' in task.config:
logger.critical('Plugin torrent_size is deprecated, use content_size instead')
found_deprecated = True
if 'nzb_size' in task.config:
logger.critical('Plugin nzb_size is deprecated, use content_size instead')
found_deprecated = True
if found_deprecated:
task.manager.shutdown(finish_queue=False)
task.abort('Deprecated config.')
@event('plugin.register')
def register_plugin():
plugin.register(ChangeWarn, 'change_warn', builtin=True, api_ver=2)
@event('manager.startup')
def startup_warnings(manager):
pass
# check that no old plugins are in pre-compiled form (pyc)
try:
import os.path
plugin_dirs = (
os.path.normpath(sys.path[0] + '/../flexget/plugins/'),
os.path.normpath(sys.path[0] + '/../flexget/plugins/input/'),
)
for plugin_dir in plugin_dirs:
for name in os.listdir(plugin_dir):
require_clean = False
if name.startswith('module'):
require_clean = True
if name == 'csv.pyc':
require_clean = True
if 'resolver' in name:
require_clean = True
if 'filter_torrent_size' in name:
require_clean = True
if 'filter_nzb_size' in name:
require_clean = True
if 'module_priority' in name:
require_clean = True
if 'ignore_feed' in name:
require_clean = True
if 'module_manual' in name:
require_clean = True
if 'output_exec' in name:
require_clean = True
if 'plugin_adv_exec' in name:
require_clean = True
if 'output_transmissionrpc' in name:
require_clean = True
if require_clean:
logger.critical('-' * 79)
logger.critical('IMPORTANT: Your installation has some files from older FlexGet!')
logger.critical('')
logger.critical(
' Please remove all pre-compiled .pyc and .pyo files from {}', plugin_dir
)
logger.critical(' Offending file: {}', name)
logger.critical('')
logger.critical(
' After getting rid of these FlexGet should run again normally'
)
logger.critical('')
logger.critical('-' * 79)
found_deprecated = True
break
except Exception:
pass