def __init__(self, *args, **kwargs): super(SiCKRAGETestCase, self).__init__(*args, **kwargs) threading.currentThread().setName('TESTS') self.TESTALL = False self.TESTSKIPPED = ['test_issue_submitter', 'test_ssl_sni'] self.TESTDIR = os.path.abspath(os.path.dirname(__file__)) self.TESTDB_DIR = os.path.join(self.TESTDIR, 'database') self.TESTDBBACKUP_DIR = os.path.join(self.TESTDIR, 'db_backup') self.TEST_CONFIG = os.path.join(self.TESTDIR, 'config.ini') self.SHOWNAME = "show name" self.SEASON = 4 self.EPISODE = 2 self.FILENAME = "show name - s0" + str(self.SEASON) + "e0" + str( self.EPISODE) + ".mkv" self.FILEDIR = os.path.join(self.TESTDIR, self.SHOWNAME) self.FILEPATH = os.path.join(self.FILEDIR, self.FILENAME) self.SHOWDIR = os.path.join(self.TESTDIR, self.SHOWNAME + " final") sickrage.app = Core() sickrage.app.search_providers = SearchProviders() sickrage.app.log = Logger() # sickrage.app.config = Config() sickrage.app.web_host = '0.0.0.0' sickrage.app.data_dir = self.TESTDIR sickrage.app.config_file = self.TEST_CONFIG sickrage.app.main_db = MainDB(db_type='sqlite', db_prefix='sickrage', db_host='localhost', db_port='3306', db_username='******', db_password='******') encryption.initialize() sickrage.app.config.load() sickrage.app.config.general.naming_pattern = 'Season.%0S/%S.N.S%0SE%0E.%E.N' sickrage.app.config.general.tv_download_dir = os.path.join( self.TESTDIR, 'Downloads') episode.TVEpisode.populate_episode = self._fake_specify_ep
def __init__(self, *args, **kwargs): super(SiCKRAGETestCase, self).__init__(*args, **kwargs) threading.currentThread().setName('TESTS') self.TESTALL = False self.TESTSKIPPED = ['test_issue_submitter', 'test_ssl_sni'] self.TESTDIR = os.path.abspath(os.path.dirname(__file__)) self.TESTDB_DIR = os.path.join(self.TESTDIR, 'database') self.TESTDBBACKUP_DIR = os.path.join(self.TESTDIR, 'db_backup') self.SHOWNAME = "show name" self.SEASON = 4 self.EPISODE = 2 self.FILENAME = "show name - s0" + str(self.SEASON) + "e0" + str( self.EPISODE) + ".mkv" self.FILEDIR = os.path.join(self.TESTDIR, self.SHOWNAME) self.FILEPATH = os.path.join(self.FILEDIR, self.FILENAME) self.SHOWDIR = os.path.join(self.TESTDIR, self.SHOWNAME + " final") sickrage.app = Core() sickrage.app.log = Logger() sickrage.app.data_dir = self.TESTDIR sickrage.app.config = Config() sickrage.app.config.quality_default = 4 # hdtv sickrage.app.config.naming_multi_ep = True sickrage.app.config.tv_download_dir = os.path.join( self.TESTDIR, 'Downloads') sickrage.app.config.ignore_words = "German,Core2HD" sickrage.app.search_providers = SearchProviders() sickrage.app.name_cache = NameCache() sickrage.app.search_providers.load() episode.TVEpisode.populateEpisode = self._fake_specify_ep
def main(): global app # set thread name threading.currentThread().setName('MAIN') # fix threading time bug time.strptime("2012", "%Y") # add sickrage libs path to python system path if not (LIBS_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(LIBS_DIR) sys.path.extend(remainder) # set system default language gettext.install('messages', LOCALE_DIR, codeset='UTF-8', names=["ngettext"]) # sickrage startup options parser = argparse.ArgumentParser(prog='sickrage') parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(version())) parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon (*NIX ONLY)') parser.add_argument('-q', '--quiet', action='store_true', help='Disables logging to CONSOLE') parser.add_argument('-p', '--port', default=0, type=int, help='Override default/configured port to listen on') parser.add_argument('-H', '--host', default='', help='Override default/configured host to listen on') parser.add_argument('--dev', action='store_true', help='Enable developer mode') parser.add_argument('--debug', action='store_true', help='Enable debugging') parser.add_argument('--datadir', default=os.path.abspath(os.path.join(os.path.expanduser("~"), '.sickrage')), help='Overrides data folder for database, config, cache and logs (specify full path)') parser.add_argument('--config', default='config.ini', help='Overrides config filename (specify full path and filename if outside datadir path)') parser.add_argument('--pidfile', default='sickrage.pid', help='Creates a PID file (specify full path and filename if outside datadir path)') parser.add_argument('--no_clean', action='store_true', help='Suppress cleanup of files not present in checksum.md5') parser.add_argument('--nolaunch', action='store_true', help='Suppress launching web browser on startup') parser.add_argument('--disable_updates', action='store_true', help='Disable application updates') parser.add_argument('--web_root', default='', type=str, help='Overrides URL web root') parser.add_argument('--db_type', default='sqlite', help='Database type: sqlite or mysql') parser.add_argument('--db_prefix', default='sickrage', help='Database prefix you want prepended to database table names') parser.add_argument('--db_host', default='localhost', help='Database hostname (not used for sqlite)') parser.add_argument('--db_port', default='3306', help='Database port number (not used for sqlite)') parser.add_argument('--db_username', default='sickrage', help='Database username (not used for sqlite)') parser.add_argument('--db_password', default='sickrage', help='Database password (not used for sqlite)') # Parse startup args args = parser.parse_args() # check lib requirements check_requirements() # cleanup unwanted files file_cleanup(remove=not args.no_clean) try: from sickrage.core import Core # main app instance app = Core() app.quiet = args.quiet app.host = args.host app.web_port = int(args.port) app.web_root = args.web_root.lstrip('/').rstrip('/') app.no_launch = args.nolaunch app.disable_updates = args.disable_updates app.developer = args.dev app.db_type = args.db_type app.db_prefix = args.db_prefix app.db_host = args.db_host app.db_port = args.db_port app.db_username = args.db_username app.db_password = args.db_password app.debug = args.debug app.data_dir = os.path.abspath(os.path.realpath(os.path.expanduser(args.datadir))) app.cache_dir = os.path.abspath(os.path.realpath(os.path.join(app.data_dir, 'cache'))) app.config_file = args.config daemonize = (False, args.daemon)[not sys.platform == 'win32'] pid_file = args.pidfile if not os.path.isabs(app.config_file): app.config_file = os.path.join(app.data_dir, app.config_file) if not os.path.isabs(pid_file): pid_file = os.path.join(app.data_dir, pid_file) # add sickrage module to python system path if not (PROG_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(PROG_DIR) sys.path.extend(remainder) # Make sure that we can create the data dir if not os.access(app.data_dir, os.F_OK): try: os.makedirs(app.data_dir, 0o744) except os.error: sys.exit("Unable to create data directory '" + app.data_dir + "'") # Make sure we can write to the data dir if not os.access(app.data_dir, os.W_OK): sys.exit("Data directory must be writeable '" + app.data_dir + "'") # Make sure that we can create the cache dir if not os.access(app.cache_dir, os.F_OK): try: os.makedirs(app.cache_dir, 0o744) except os.error: sys.exit("Unable to create cache directory '" + app.cache_dir + "'") # Make sure we can write to the cache dir if not os.access(app.cache_dir, os.W_OK): sys.exit("Cache directory must be writeable '" + app.cache_dir + "'") # daemonize if requested if daemonize: app.no_launch = True app.quiet = True app.daemon = Daemon(pid_file, app.data_dir) app.daemon.daemonize() app.pid = app.daemon.pid # start app app.start() while app.started: time.sleep(0.1) except (SystemExit, KeyboardInterrupt): if app: app.shutdown() except Exception: traceback.print_exc()
def main(): global app # set thread name threading.currentThread().setName('MAIN') # fix threading time bug time.strptime("2012", "%Y") # add sickrage libs path to python system path if not (LIBS_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(LIBS_DIR) sys.path.extend(remainder) # set system default language gettext.install('messages', LOCALE_DIR, unicode=1, codeset='UTF-8', names=["ngettext"]) try: from sickrage.core import Core # main app instance app = Core() # sickrage startup options parser = argparse.ArgumentParser(prog='sickrage') parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(version())) parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon (*NIX ONLY)') parser.add_argument('-q', '--quite', action='store_true', help='Disables logging to CONSOLE') parser.add_argument( '-p', '--port', default=0, type=int, help='Override default/configured port to listen on') parser.add_argument('--dev', action='store_true', help='Enable developer mode') parser.add_argument('--debug', action='store_true', help='Enable debugging') parser.add_argument( '--datadir', default=os.path.abspath( os.path.join(os.path.expanduser("~"), '.sickrage')), help= 'Overrides data folder for database, config, cache and logs (specify full path)' ) parser.add_argument( '--config', default='config.ini', help= 'Overrides config filename (specify full path and filename if outside datadir path)' ) parser.add_argument( '--pidfile', default='sickrage.pid', help= 'Creates a PID file (specify full path and filename if outside datadir path)' ) parser.add_argument('--nolaunch', action='store_true', help='Suppress launching web browser on startup') # Parse startup args args = parser.parse_args() app.quite = args.quite app.web_port = int(args.port) app.no_launch = args.nolaunch app.developer = args.dev app.debug = args.debug app.data_dir = os.path.abspath( os.path.realpath(os.path.expanduser(args.datadir))) app.cache_dir = os.path.abspath( os.path.realpath(os.path.join(app.data_dir, 'cache'))) app.config_file = args.config daemonize = (False, args.daemon)[not sys.platform == 'win32'] pid_file = args.pidfile if not os.path.isabs(app.config_file): app.config_file = os.path.join(app.data_dir, app.config_file) if not os.path.isabs(pid_file): pid_file = os.path.join(app.data_dir, pid_file) # check lib requirements check_requirements() # add sickrage module to python system path if not (PROG_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(PROG_DIR) sys.path.extend(remainder) # Make sure that we can create the data dir if not os.access(app.data_dir, os.F_OK): try: os.makedirs(app.data_dir, 0o744) except os.error: sys.exit("Unable to create data directory '" + app.data_dir + "'") # Make sure we can write to the data dir if not os.access(app.data_dir, os.W_OK): sys.exit("Data directory must be writeable '" + app.data_dir + "'") # Make sure that we can create the cache dir if not os.access(app.cache_dir, os.F_OK): try: os.makedirs(app.cache_dir, 0o744) except os.error: sys.exit("Unable to create cache directory '" + app.cache_dir + "'") # Make sure we can write to the cache dir if not os.access(app.cache_dir, os.W_OK): sys.exit("Cache directory must be writeable '" + app.cache_dir + "'") # daemonize if requested if daemonize: app.no_launch = True app.quite = True app.daemon = Daemon(pid_file, app.data_dir) app.daemon.daemonize() app.pid = app.daemon.pid # start app app.start() except (SystemExit, KeyboardInterrupt): if app: app.shutdown() except ImportError: traceback.print_exc() if os.path.isfile(REQS_FILE): print( "Failed to import required libs, please run " "'pip install --user -U -r {}' from console".format(REQS_FILE)) except Exception: traceback.print_exc()
def main(): global app # set thread name threading.currentThread().setName('MAIN') # fix threading time bug time.strptime("2012", "%Y") # add sickrage libs path to python system path if not (LIBS_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(LIBS_DIR) sys.path.extend(remainder) # set system default language gettext.install('messages', LOCALE_DIR, unicode=1, codeset='UTF-8', names=["ngettext"]) try: from sickrage.core import Core # main app instance app = Core() # sickrage startup options parser = argparse.ArgumentParser(prog='sickrage') parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(version())) parser.add_argument('-d', '--daemon', action='store_true', help='Run as a daemon (*NIX ONLY)') parser.add_argument('-q', '--quiet', action='store_true', help='Disables logging to CONSOLE') parser.add_argument('-p', '--port', default=0, type=int, help='Override default/configured port to listen on') parser.add_argument('--dev', action='store_true', help='Enable developer mode') parser.add_argument('--debug', action='store_true', help='Enable debugging') parser.add_argument('--datadir', default=os.path.abspath(os.path.join(os.path.expanduser("~"), '.sickrage')), help='Overrides data folder for database, config, cache and logs (specify full path)') parser.add_argument('--config', default='config.ini', help='Overrides config filename (specify full path and filename if outside datadir path)') parser.add_argument('--pidfile', default='sickrage.pid', help='Creates a PID file (specify full path and filename if outside datadir path)') parser.add_argument('--nolaunch', action='store_true', help='Suppress launching web browser on startup') # Parse startup args args = parser.parse_args() app.quiet = args.quiet app.web_port = int(args.port) app.no_launch = args.nolaunch app.developer = args.dev app.debug = args.debug app.data_dir = os.path.abspath(os.path.realpath(os.path.expanduser(args.datadir))) app.cache_dir = os.path.abspath(os.path.realpath(os.path.join(app.data_dir, 'cache'))) app.config_file = args.config daemonize = (False, args.daemon)[not sys.platform == 'win32'] pid_file = args.pidfile if not os.path.isabs(app.config_file): app.config_file = os.path.join(app.data_dir, app.config_file) if not os.path.isabs(pid_file): pid_file = os.path.join(app.data_dir, pid_file) # check lib requirements check_requirements() # add sickrage module to python system path if not (PROG_DIR in sys.path): sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(PROG_DIR) sys.path.extend(remainder) # Make sure that we can create the data dir if not os.access(app.data_dir, os.F_OK): try: os.makedirs(app.data_dir, 0o744) except os.error: sys.exit("Unable to create data directory '" + app.data_dir + "'") # Make sure we can write to the data dir if not os.access(app.data_dir, os.W_OK): sys.exit("Data directory must be writeable '" + app.data_dir + "'") # Make sure that we can create the cache dir if not os.access(app.cache_dir, os.F_OK): try: os.makedirs(app.cache_dir, 0o744) except os.error: sys.exit("Unable to create cache directory '" + app.cache_dir + "'") # Make sure we can write to the cache dir if not os.access(app.cache_dir, os.W_OK): sys.exit("Cache directory must be writeable '" + app.cache_dir + "'") # daemonize if requested if daemonize: app.no_launch = True app.quiet = True app.daemon = Daemon(pid_file, app.data_dir) app.daemon.daemonize() app.pid = app.daemon.pid # start app app.start() except (SystemExit, KeyboardInterrupt): if app: app.shutdown() except ImportError: traceback.print_exc() if os.path.isfile(REQS_FILE): print('Failed to import required libs, please run "pip install -r {}" from console'.format(REQS_FILE)) except Exception: traceback.print_exc()
TESTALL = True return tests # ================= # test globals # ================= threading.currentThread().setName('TESTS') PROG_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'sickrage')) if PROG_DIR not in sys.path: sys.path.insert(0, PROG_DIR) sickrage.DATA_DIR = TESTDIR = os.path.abspath(os.path.dirname(__file__)) sickrage.CONFIG_FILE = TESTCONFIGNAME = os.path.abspath(os.path.join(TESTDIR, "config.ini")) sickrage.NOLAUNCH = True sickrage.srCore = Core() TESTALL = False TESTSKIPPED = ['test_issue_submitter', 'test_ssl_sni'] TESTDBNAME = "sickrage.db" TESTCACHEDBNAME = "cache.db" TESTFAILEDDBNAME = "failed.db" TESTDB_INITALIZED = False SHOWNAME = "show name" SEASON = 4 EPISODE = 2 FILENAME = "show name - s0" + str(SEASON) + "e0" + str(EPISODE) + ".mkv" FILEDIR = os.path.join(TESTDIR, SHOWNAME) FILEPATH = os.path.join(FILEDIR, FILENAME) SHOWDIR = os.path.join(TESTDIR, SHOWNAME + " final")