flexget.plugins.generic.welcome
Covered: 15 lines
Missed: 20 lines
Skipped 12 lines
Percent: 42 %
 1
import os
 3
__author__ = 'paranoidi'
 5
import sys
 6
from flexget.utils.simple_persistence import SimplePersistence
 7
from flexget.plugin import register_plugin
 8
import logging
10
log = logging.getLogger('welcome')
13
class WelcomePlugin(object):
15
    def __init__(self, ):
16
        self.executed = False
17
        self.persistence = SimplePersistence(plugin='welcome')
19
    def on_process_start(self, feed, entries):
20
        if self.executed or not feed.manager.options.quiet:
21
            return
22
        count = self.persistence.setdefault('count', 5)
23
        if not count:
24
            return
27
        if count == 5 and os.stat(feed.manager.db_filename).st_size / 1024 / 1024 >= 2:
28
            log.debug('Looks like old user, skipping welcome message')
29
            self.persistence['count'] = 0
30
            return
32
        count -= 1
33
        scheduler = 'scheduler' if sys.platform.startswith('win') else 'crontab'
34
        if not count:
35
            log.info('FlexGet has been successfully started from %s (--cron). '
36
                     'I hope you have %s under control now. This message will not be repeated again.' %
37
                     (scheduler, scheduler))
38
        else:
39
            log.info('%sFlexGet has been successfully started from %s (--cron). '
40
                     'This message will be repeated %i times for your set up verification conveniences.' %
41
                     ('Congratulations! ' if count == 4 else '',
42
                      scheduler, count))
43
        self.persistence['count'] = count
44
        self.executed = True
46
register_plugin(WelcomePlugin, 'welcome', builtin=True, api_ver=2)