sickrage.WEB_ROOT = "" sickrage.WEB_SERVER = None sickrage.CPU_PRESET = "NORMAL" sickrage.EXTRA_SCRIPTS = [] sickrage.CACHE_DIR = os.path.join(TESTDIR, 'cache') createTestCacheFolder() sickrage.LOG_DIR = os.path.join(TESTDIR, 'Logs') createTestLogFolder() sickrage.LOG_FILE = os.path.join(sickrage.LOG_DIR, 'sickrage.log') sickrage.LOG_NR = 5 sickrage.LOG_SIZE = 1048576 sickrage.LOGGER = srLogger(logFile=sickrage.LOG_FILE, logSize=sickrage.LOG_SIZE, logNr=sickrage.LOG_NR, fileLogging=sickrage.LOG_DIR, debugLogging=True) sickrage.CUR_COMMIT_HASH = srConfig.check_setting_str(sickrage.CFG, 'General', 'cur_commit_hash', '') sickrage.GIT_USERNAME = srConfig.check_setting_str(sickrage.CFG, 'General', 'git_username', '') sickrage.GIT_PASSWORD = srConfig.check_setting_str(sickrage.CFG, 'General', 'git_password', '', censor_log=True) sickrage.providersDict = { GenericProvider.NZB: {p.id: p for p in NZBProvider.getProviderList()}, GenericProvider.TORRENT: {p.id: p for p in TorrentProvider.getProviderList()}, } sickrage.Scheduler = Scheduler() # ================= # dummy functions
def __init__(self): self.started = False # process id self.PID = os.getpid() # cpu count self.CPU_COUNT = cpu_count() # generate notifiers dict self.notifiersDict = AttrDict(libnotify=LibnotifyNotifier(), kodi_notifier=KODINotifier(), plex_notifier=PLEXNotifier(), emby_notifier=EMBYNotifier(), nmj_notifier=NMJNotifier(), nmjv2_notifier=NMJv2Notifier(), synoindex_notifier=synoIndexNotifier(), synology_notifier=synologyNotifier(), pytivo_notifier=pyTivoNotifier(), growl_notifier=GrowlNotifier(), prowl_notifier=ProwlNotifier(), libnotify_notifier=LibnotifyNotifier(), pushover_notifier=PushoverNotifier(), boxcar_notifier=BoxcarNotifier(), boxcar2_notifier=Boxcar2Notifier(), nma_notifier=NMA_Notifier(), pushalot_notifier=PushalotNotifier(), pushbullet_notifier=PushbulletNotifier(), freemobile_notifier=FreeMobileNotifier(), twitter_notifier=TwitterNotifier(), trakt_notifier=TraktNotifier(), email_notifier=EmailNotifier()) # generate metadata providers dict self.metadataProviderDict = get_metadata_generator_dict() # generate providers dict self.providersDict = providersDict() # init notification queue self.srNotifications = Notifications() # init logger self.srLogger = srLogger() # init config self.srConfig = srConfig() # init scheduler service self.srScheduler = TornadoScheduler() # init web server self.srWebServer = srWebServer() # init web client session self.srWebSession = srSession() # google api self.googleAuth = googleAuth() # name cache self.NAMECACHE = srNameCache() # queues self.SHOWQUEUE = srShowQueue() self.SEARCHQUEUE = srSearchQueue() # updaters self.VERSIONUPDATER = srVersionUpdater() self.SHOWUPDATER = srShowUpdater() # searchers self.DAILYSEARCHER = srDailySearcher() self.BACKLOGSEARCHER = srBacklogSearcher() self.PROPERSEARCHER = srProperSearcher() self.TRAKTSEARCHER = srTraktSearcher() self.SUBTITLESEARCHER = srSubtitleSearcher() # auto postprocessor self.AUTOPOSTPROCESSOR = srPostProcessor() # sickrage version self.NEWEST_VERSION = None self.NEWEST_VERSION_STRING = None # anidb connection self.ADBA_CONNECTION = None # show list self.SHOWLIST = []
def __init__(self): self.started = False # process id self.PID = os.getpid() # generate notifiers dict self.notifiersDict = AttrDict( libnotify=LibnotifyNotifier(), kodi_notifier=KODINotifier(), plex_notifier=PLEXNotifier(), emby_notifier=EMBYNotifier(), nmj_notifier=NMJNotifier(), nmjv2_notifier=NMJv2Notifier(), synoindex_notifier=synoIndexNotifier(), synology_notifier=synologyNotifier(), pytivo_notifier=pyTivoNotifier(), growl_notifier=GrowlNotifier(), prowl_notifier=ProwlNotifier(), libnotify_notifier=LibnotifyNotifier(), pushover_notifier=PushoverNotifier(), boxcar_notifier=BoxcarNotifier(), boxcar2_notifier=Boxcar2Notifier(), nma_notifier=NMA_Notifier(), pushalot_notifier=PushalotNotifier(), pushbullet_notifier=PushbulletNotifier(), freemobile_notifier=FreeMobileNotifier(), twitter_notifier=TwitterNotifier(), trakt_notifier=TraktNotifier(), email_notifier=EmailNotifier() ) # generate metadata providers dict self.metadataProviderDict = get_metadata_generator_dict() # generate providers dict self.providersDict = providersDict() # init notification queue self.srNotifications = Notifications() # init logger self.srLogger = srLogger() # init config self.srConfig = srConfig() # init scheduler service self.srScheduler = TornadoScheduler() # init web server self.srWebServer = srWebServer() # init web client session self.srWebSession = srSession() # google api self.googleAuth = googleAuth() # name cache self.NAMECACHE = srNameCache() # queues self.SHOWQUEUE = srShowQueue() self.SEARCHQUEUE = srSearchQueue() # updaters self.VERSIONUPDATER = srVersionUpdater() self.SHOWUPDATER = srShowUpdater() # searchers self.DAILYSEARCHER = srDailySearcher() self.BACKLOGSEARCHER = srBacklogSearcher() self.PROPERSEARCHER = srProperSearcher() self.TRAKTSEARCHER = srTraktSearcher() self.SUBTITLESEARCHER = srSubtitleSearcher() # auto postprocessor self.AUTOPOSTPROCESSOR = srPostProcessor() # sickrage version self.NEWEST_VERSION = None self.NEWEST_VERSION_STRING = None # anidb connection self.ADBA_CONNECTION = None # show list self.SHOWLIST = []
def __init__(self): self.started = False self.io_loop = IOLoop.current() # process id self.PID = os.getpid() # generate notifiers dict self.notifiersDict = notifiersDict() # generate metadata providers dict self.metadataProvidersDict = metadataProvidersDict() # generate providers dict self.providersDict = providersDict() # init notification queue self.srNotifications = Notifications() # init logger self.srLogger = srLogger() # init config self.srConfig = srConfig() # init databases self.mainDB = MainDB() self.cacheDB = CacheDB() self.failedDB = FailedDB() # init scheduler service self.srScheduler = TornadoScheduler() # init web server self.srWebServer = srWebServer() # init web client session self.srWebSession = srSession() # google api self.googleAuth = googleAuth() # name cache self.NAMECACHE = srNameCache() # queues self.SHOWQUEUE = srShowQueue() self.SEARCHQUEUE = srSearchQueue() # updaters self.VERSIONUPDATER = srVersionUpdater() self.SHOWUPDATER = srShowUpdater() # searchers self.DAILYSEARCHER = srDailySearcher() self.BACKLOGSEARCHER = srBacklogSearcher() self.PROPERSEARCHER = srProperSearcher() self.TRAKTSEARCHER = srTraktSearcher() self.SUBTITLESEARCHER = srSubtitleSearcher() # auto postprocessor self.AUTOPOSTPROCESSOR = srPostProcessor() # sickrage version self.NEWEST_VERSION = None self.NEWEST_VERSION_STRING = None # anidb connection self.ADBA_CONNECTION = None # show list self.SHOWLIST = []
sickrage.CPU_PRESET = "NORMAL" sickrage.EXTRA_SCRIPTS = [] sickrage.CACHE_DIR = os.path.join(TESTDIR, 'cache') createTestCacheFolder() sickrage.LOG_DIR = os.path.join(TESTDIR, 'Logs') createTestLogFolder() sickrage.LOG_FILE = os.path.join(sickrage.LOG_DIR, 'sickrage.log') sickrage.LOG_NR = 5 sickrage.LOG_SIZE = 1048576 sickrage.LOGGER = srLogger(logFile=sickrage.LOG_FILE, logSize=sickrage.LOG_SIZE, logNr=sickrage.LOG_NR, fileLogging=sickrage.LOG_DIR, debugLogging=True) sickrage.CUR_COMMIT_HASH = srConfig.check_setting_str(sickrage.CFG, 'General', 'cur_commit_hash', '') sickrage.GIT_USERNAME = srConfig.check_setting_str(sickrage.CFG, 'General', 'git_username', '') sickrage.GIT_PASSWORD = srConfig.check_setting_str(sickrage.CFG, 'General', 'git_password', '', censor_log=True) sickrage.providersDict = { GenericProvider.NZB: {p.id: p
def main(): global APP_NAME, MY_FULLNAME, NO_RESIZE, MY_ARGS, WEB_PORT, WEB_NOLAUNCH, CREATEPID, DAEMONIZE, PIDFILE, \ ROOT_DIR, PROG_DIR, DATA_DIR, CONFIG_FILE, WEB_SERVER, VERSIONUPDATER, DEVELOPER, LOGGER, ENABLE_HTTPS if sys.version_info < (2, 7): print("Sorry, SiCKRAGE requires Python 2.7+") sys.exit(1) # set thread name threading.currentThread().setName('MAIN') APP_NAME = 'SiCKRAGE' DATA_DIR = ROOT_DIR = os.path.abspath( os.path.dirname(os.path.dirname(__file__))) PROG_DIR = os.path.abspath(os.path.dirname(__file__)) MY_ARGS = sys.argv[1:] consoleLogging = (not hasattr( sys, "frozen")) or (APP_NAME.lower().find('-console') > 0) # defaults INSTALL_OPTIONAL = False # auto-detect user rights USER = root_check() try: opts, _ = getopt.getopt(sys.argv[1:], "hqdp::", [ 'help', 'dev', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize', 'install-optional', 'ssl' 'user' ]) except getopt.GetoptError: sys.exit(help_message()) for o, a in opts: # help message if o in ('-h', '--help'): sys.exit(help_message()) # For now we'll just silence the logging if o in ('-q', '--quiet'): consoleLogging = False # developer mode if o in ('--dev', ): print("!!! DEVELOPER MODE ENABLED !!!") DEVELOPER = True # Suppress launching web browser # Needed for OSes without default browser assigned # Prevent duplicate browser window when restarting in the app if o in ('--nolaunch', ): WEB_NOLAUNCH = True # Override default/configured port if o in ('-p', '--port'): try: WEB_PORT = int(a) except ValueError: sys.exit("Port: " + str(a) + " is not a number. Exiting.") # Run as a double forked daemon if o in ('-d', '--daemon'): DAEMONIZE = True WEB_NOLAUNCH = True consoleLogging = False if sys.platform == 'win32' or sys.platform == 'darwin': DAEMONIZE = False # Write a pidfile if requested if o in ('--pidfile', ): CREATEPID = True PIDFILE = str(a) # If the pidfile already exists, sickrage may still be running, so exit if os.path.exists(PIDFILE): sys.exit("PID file: " + PIDFILE + " already exists. Exiting.") # Specify folder to load the config file from if o in ('--config', ): CONFIG_FILE = os.path.abspath(a) # Specify folder to use as the data dir if o in ('--datadir', ): DATA_DIR = os.path.abspath(a) # Prevent resizing of the banner/posters even if PIL is installed if o in ('--noresize', ): NO_RESIZE = True # Install optional packages from requirements folder if o in ('--install-optional', ): INSTALL_OPTIONAL = True # Install ssl packages from requirements folder if o in ('--ssl', ): ENABLE_HTTPS = True # Installs packages for non-root users if o in ('--user', ): USER = True # install/upgrade pip and ssl contexts for required/optional imports if not DEVELOPER: # install pip package manager install_pip(user=USER) # install required packages install_reqs(optional=INSTALL_OPTIONAL, ssl=ENABLE_HTTPS, user=USER) # init logging from sickrage.core.srlogger import srLogger LOGGER = srLogger(consoleLogging=consoleLogging) # The pidfile is only useful in daemon mode, make sure we can write the file properly if CREATEPID: if DAEMONIZE: pid_dir = os.path.dirname(PIDFILE) if not os.access(pid_dir, os.F_OK): sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.") if not os.access(pid_dir, os.W_OK): sys.exit("PID dir: " + pid_dir + " must be writable (write permissions). Exiting.") else: CREATEPID = False LOGGER.info( "Not running in daemon mode. PID file creation disabled.\n") # If they don't specify a config file then put it in the data dir if not CONFIG_FILE: CONFIG_FILE = os.path.join(DATA_DIR, "config.ini") # Make sure that we can create the data dir if not os.access(DATA_DIR, os.F_OK): try: os.makedirs(DATA_DIR, 0o744) except os.error: raise SystemExit("Unable to create datadir '" + DATA_DIR + "'") # Make sure we can write to the data dir if not os.access(DATA_DIR, os.W_OK): raise SystemExit("Datadir must be writeable '" + DATA_DIR + "'") # Make sure we can write to the config file if not os.access(CONFIG_FILE, os.W_OK): if os.path.isfile(CONFIG_FILE): raise SystemExit("Config file '" + CONFIG_FILE + "' must be writeable.") elif not os.access(os.path.dirname(CONFIG_FILE), os.W_OK): raise SystemExit("Config file root dir '" + os.path.dirname(CONFIG_FILE) + "' must be writeable.") try: # initialize and startup sickrage from sickrage import core if core.initialize(): WEB_SERVER.start() except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback) traceback.print_exception(exc_type, exc_value, exc_traceback) sys.exit(1) sys.exit(0)
def main(): global APP_NAME, MY_FULLNAME, NO_RESIZE, MY_ARGS, WEB_PORT, WEB_NOLAUNCH, CREATEPID, DAEMONIZE, PIDFILE, \ ROOT_DIR, PROG_DIR, DATA_DIR, CONFIG_FILE, WEB_SERVER, VERSIONUPDATER, DEVELOPER, LOGGER if sys.version_info < (2, 7): print("Sorry, SiCKRAGE requires Python 2.7+") sys.exit(1) # set thread name threading.currentThread().setName('MAIN') APP_NAME = 'SiCKRAGE' DATA_DIR = ROOT_DIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) PROG_DIR = os.path.abspath(os.path.dirname(__file__)) MY_ARGS = sys.argv[1:] consoleLogging = (not hasattr(sys, "frozen")) or (APP_NAME.lower().find('-console') > 0) # defaults INSTALL_OPTIONAL = False # auto-detect user rights USER = root_check() try: opts, _ = getopt.getopt( sys.argv[1:], "hqdp::", ['help', 'dev', 'quiet', 'nolaunch', 'daemon', 'pidfile=', 'port=', 'datadir=', 'config=', 'noresize', 'install-optional', 'user'] ) except getopt.GetoptError: sys.exit(help_message()) for o, a in opts: # help message if o in ('-h', '--help'): sys.exit(help_message()) # For now we'll just silence the logging if o in ('-q', '--quiet'): consoleLogging = False # developer mode if o in ('--dev',): print("!!! DEVELOPER MODE ENABLED !!!") DEVELOPER = True # Suppress launching web browser # Needed for OSes without default browser assigned # Prevent duplicate browser window when restarting in the app if o in ('--nolaunch',): WEB_NOLAUNCH = True # Override default/configured port if o in ('-p', '--port'): try: WEB_PORT = int(a) except ValueError: sys.exit("Port: " + str(a) + " is not a number. Exiting.") # Run as a double forked daemon if o in ('-d', '--daemon'): DAEMONIZE = True WEB_NOLAUNCH = True consoleLogging = False if sys.platform == 'win32' or sys.platform == 'darwin': DAEMONIZE = False # Write a pidfile if requested if o in ('--pidfile',): CREATEPID = True PIDFILE = str(a) # If the pidfile already exists, sickrage may still be running, so exit if os.path.exists(PIDFILE): sys.exit("PID file: " + PIDFILE + " already exists. Exiting.") # Specify folder to load the config file from if o in ('--config',): CONFIG_FILE = os.path.abspath(a) # Specify folder to use as the data dir if o in ('--datadir',): DATA_DIR = os.path.abspath(a) # Prevent resizing of the banner/posters even if PIL is installed if o in ('--noresize',): NO_RESIZE = True # Install optional packages from requirements folder if o in ('--install-optional',): INSTALL_OPTIONAL = True # Install optional packages from requirements folder if o in ('--user',): USER = True # install/upgrade pip and ssl contexts for required/optional imports if not DEVELOPER: install_reqs(optional=INSTALL_OPTIONAL, user=USER) # init logging from sickrage.core.srlogger import srLogger LOGGER = srLogger(consoleLogging=consoleLogging) # The pidfile is only useful in daemon mode, make sure we can write the file properly if CREATEPID: if DAEMONIZE: pid_dir = os.path.dirname(PIDFILE) if not os.access(pid_dir, os.F_OK): sys.exit("PID dir: " + pid_dir + " doesn't exist. Exiting.") if not os.access(pid_dir, os.W_OK): sys.exit("PID dir: " + pid_dir + " must be writable (write permissions). Exiting.") else: CREATEPID = False LOGGER.info("Not running in daemon mode. PID file creation disabled.\n") # If they don't specify a config file then put it in the data dir if not CONFIG_FILE: CONFIG_FILE = os.path.join(DATA_DIR, "config.ini") # Make sure that we can create the data dir if not os.access(DATA_DIR, os.F_OK): try: os.makedirs(DATA_DIR, 0o744) except os.error: raise SystemExit("Unable to create datadir '" + DATA_DIR + "'") # Make sure we can write to the data dir if not os.access(DATA_DIR, os.W_OK): raise SystemExit("Datadir must be writeable '" + DATA_DIR + "'") # Make sure we can write to the config file if not os.access(CONFIG_FILE, os.W_OK): if os.path.isfile(CONFIG_FILE): raise SystemExit("Config file '" + CONFIG_FILE + "' must be writeable.") elif not os.access(os.path.dirname(CONFIG_FILE), os.W_OK): raise SystemExit( "Config file root dir '" + os.path.dirname(CONFIG_FILE) + "' must be writeable.") try: # initialize and startup sickrage from sickrage import core if core.initialize(): WEB_SERVER.start() except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback) traceback.print_exception(exc_type, exc_value, exc_traceback) sys.exit(1) sys.exit(0)
def __init__(self): self.started = False # process id self.PID = os.getpid() # generate notifiers dict self.notifiersDict = notifiersDict() # generate metadata providers dict self.metadataProvidersDict = metadataProvidersDict() # generate providers dict self.providersDict = providersDict() # init notification queue self.srNotifications = Notifications() # init logger self.srLogger = srLogger() # init config self.srConfig = srConfig() # init databases self.mainDB = MainDB() self.cacheDB = CacheDB() self.failedDB = FailedDB() # init scheduler service self.srScheduler = BackgroundScheduler() # init web server self.srWebServer = srWebServer() # init web client session self.srWebSession = srSession() # google api self.googleAuth = googleAuth() # name cache self.NAMECACHE = srNameCache() # queues self.SHOWQUEUE = srShowQueue() self.SEARCHQUEUE = srSearchQueue() # updaters self.VERSIONUPDATER = srVersionUpdater() self.SHOWUPDATER = srShowUpdater() # searchers self.DAILYSEARCHER = srDailySearcher() self.BACKLOGSEARCHER = srBacklogSearcher() self.PROPERSEARCHER = srProperSearcher() self.TRAKTSEARCHER = srTraktSearcher() self.SUBTITLESEARCHER = srSubtitleSearcher() # auto postprocessor self.AUTOPOSTPROCESSOR = srPostProcessor() # sickrage version self.NEWEST_VERSION = None self.NEWEST_VERSION_STRING = None # anidb connection self.ADBA_CONNECTION = None # show list self.SHOWLIST = [] self.USER_AGENT = 'SiCKRAGE.CE.1/({};{};{})'.format( platform.system(), platform.release(), str(uuid.uuid1())) self.SYS_ENCODING = get_sys_encoding() # patch modules with encoding kludge patch_modules()