Exemplo n.º 1
0
def backupDatabase(version):
    log.info(u'Backing up database before upgrade')
    if not helpers.backup_versioned_file(db.dbFilename(), version):
        log.error(u'Database backup failed, abort upgrading database')
        sys.exit(1)
    else:
        log.info(u'Proceeding with upgrade')
Exemplo n.º 2
0
def config(monkeypatch, app_config):
    python_version = 'Python Test v1.2.3.4'
    monkeypatch.setattr(sys, 'version', python_version)
    os_user = app_config('OS_USER', 'superuser')
    app_config('LOCALE', (None, 'ABC'))
    app_locale = 'Unknown.ABC'

    config_data = NonEmptyDict()
    config_data['anonRedirect'] = app.ANON_REDIRECT
    config_data['animeSplitHome'] = app.ANIME_SPLIT_HOME
    config_data['comingEpsSort'] = app.COMING_EPS_SORT
    config_data['datePreset'] = app.DATE_PRESET
    config_data['fuzzyDating'] = app.FUZZY_DATING
    config_data['themeName'] = app.THEME_NAME
    config_data['posterSortby'] = app.POSTER_SORTBY
    config_data['posterSortdir'] = app.POSTER_SORTDIR
    config_data['rootDirs'] = app.ROOT_DIRS
    config_data['sortArticle'] = app.SORT_ARTICLE
    config_data['timePreset'] = app.TIME_PRESET
    config_data['trimZero'] = app.TRIM_ZERO
    config_data['fanartBackground'] = app.FANART_BACKGROUND
    config_data['fanartBackgroundOpacity'] = float(
        app.FANART_BACKGROUND_OPACITY or 0)
    config_data['branch'] = app.BRANCH
    config_data['commitHash'] = app.CUR_COMMIT_HASH
    config_data['release'] = app.APP_VERSION
    config_data['sslVersion'] = app.OPENSSL_VERSION
    config_data['pythonVersion'] = sys.version
    config_data['databaseVersion'] = NonEmptyDict()
    config_data['databaseVersion']['major'] = app.MAJOR_DB_VERSION
    config_data['databaseVersion']['minor'] = app.MINOR_DB_VERSION
    config_data['os'] = platform.platform()
    config_data['locale'] = app_locale
    config_data['localUser'] = os_user
    config_data['programDir'] = app.PROG_DIR
    config_data['configFile'] = app.CONFIG_FILE
    config_data['dbFilename'] = db.dbFilename()
    config_data['cacheDir'] = app.CACHE_DIR
    config_data['logDir'] = app.LOG_DIR
    config_data['appArgs'] = app.MY_ARGS
    config_data['webRoot'] = app.WEB_ROOT
    config_data['githubUrl'] = app.GITHUB_IO_URL
    config_data['wikiUrl'] = app.WIKI_URL
    config_data['sourceUrl'] = app.APPLICATION_URL
    config_data['downloadUrl'] = app.DOWNLOAD_URL
    config_data['subtitlesMulti'] = app.SUBTITLES_MULTI
    config_data['namingForceFolders'] = app.NAMING_FORCE_FOLDERS
    config_data['subtitles'] = NonEmptyDict()
    config_data['subtitles']['enabled'] = bool(app.USE_SUBTITLES)
    config_data['kodi'] = NonEmptyDict()
    config_data['kodi']['enabled'] = bool(app.USE_KODI
                                          and app.KODI_UPDATE_LIBRARY)
    config_data['plex'] = NonEmptyDict()
    config_data['plex']['server'] = NonEmptyDict()
    config_data['plex']['server']['enabled'] = bool(app.USE_PLEX_SERVER)
    config_data['plex']['server']['notify'] = NonEmptyDict()
    config_data['plex']['server']['notify']['snatch'] = bool(
        app.PLEX_NOTIFY_ONSNATCH)
    config_data['plex']['server']['notify']['download'] = bool(
        app.PLEX_NOTIFY_ONDOWNLOAD)
    config_data['plex']['server']['notify']['subtitleDownload'] = bool(
        app.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD)

    config_data['plex']['server']['updateLibrary'] = bool(
        app.PLEX_UPDATE_LIBRARY)
    config_data['plex']['server']['host'] = app.PLEX_SERVER_HOST
    config_data['plex']['server']['token'] = app.PLEX_SERVER_TOKEN
    config_data['plex']['server']['username'] = app.PLEX_SERVER_USERNAME
    config_data['plex']['server']['password'] = app.PLEX_SERVER_PASSWORD
    config_data['plex']['client'] = NonEmptyDict()
    config_data['plex']['client']['enabled'] = bool(app.USE_PLEX_CLIENT)
    config_data['plex']['client']['username'] = app.PLEX_CLIENT_USERNAME
    config_data['plex']['client']['password'] = app.PLEX_CLIENT_PASSWORD
    config_data['plex']['client']['host'] = app.PLEX_CLIENT_HOST
    config_data['emby'] = NonEmptyDict()
    config_data['emby']['enabled'] = bool(app.USE_EMBY)
    config_data['torrents'] = NonEmptyDict()
    config_data['torrents']['enabled'] = bool(app.USE_TORRENTS)
    config_data['torrents']['method'] = app.TORRENT_METHOD
    config_data['torrents']['username'] = app.TORRENT_USERNAME
    config_data['torrents']['password'] = app.TORRENT_PASSWORD
    config_data['torrents']['label'] = app.TORRENT_LABEL
    config_data['torrents']['labelAnime'] = app.TORRENT_LABEL_ANIME
    config_data['torrents']['verifySSL'] = app.TORRENT_VERIFY_CERT
    config_data['torrents']['path'] = app.TORRENT_PATH
    config_data['torrents']['seedTime'] = app.TORRENT_SEED_TIME
    config_data['torrents']['paused'] = app.TORRENT_PAUSED
    config_data['torrents']['highBandwidth'] = app.TORRENT_HIGH_BANDWIDTH
    config_data['torrents']['host'] = app.TORRENT_HOST
    config_data['torrents']['rpcurl'] = app.TORRENT_RPCURL
    config_data['torrents']['authType'] = app.TORRENT_AUTH_TYPE
    config_data['nzb'] = NonEmptyDict()
    config_data['nzb']['enabled'] = bool(app.USE_NZBS)
    config_data['nzb']['username'] = app.NZBGET_USERNAME
    config_data['nzb']['password'] = app.NZBGET_PASSWORD
    # app.NZBGET_CATEGORY
    # app.NZBGET_CATEGORY_BACKLOG
    # app.NZBGET_CATEGORY_ANIME
    # app.NZBGET_CATEGORY_ANIME_BACKLOG
    config_data['nzb']['host'] = app.NZBGET_HOST
    config_data['nzb']['priority'] = app.NZBGET_PRIORITY
    config_data['layout'] = NonEmptyDict()
    config_data['layout']['schedule'] = app.COMING_EPS_LAYOUT
    config_data['layout']['history'] = app.HISTORY_LAYOUT
    config_data['layout']['home'] = app.HOME_LAYOUT
    config_data['layout']['show'] = NonEmptyDict()
    config_data['layout']['show']['allSeasons'] = bool(app.DISPLAY_ALL_SEASONS)
    config_data['layout']['show']['specials'] = bool(app.DISPLAY_SHOW_SPECIALS)
    config_data['selectedRootIndex'] = int(
        app.SELECTED_ROOT
    ) if app.SELECTED_ROOT is not None else -1  # All paths
    config_data['backlogOverview'] = NonEmptyDict()
    config_data['backlogOverview']['period'] = app.BACKLOG_PERIOD
    config_data['backlogOverview']['status'] = app.BACKLOG_STATUS

    return config_data
Exemplo n.º 3
0
    def get(self, identifier, path_param=None):
        """Query general configuration.

        :param identifier:
        :param path_param:
        :type path_param: str
        """
        if identifier and identifier != 'main':
            return self._not_found('Config not found')

        config_data = NonEmptyDict()
        config_data['anonRedirect'] = app.ANON_REDIRECT
        config_data['animeSplitHome'] = app.ANIME_SPLIT_HOME
        config_data['comingEpsSort'] = app.COMING_EPS_SORT
        config_data['datePreset'] = app.DATE_PRESET
        config_data['fuzzyDating'] = app.FUZZY_DATING
        config_data['themeName'] = app.THEME_NAME
        config_data['posterSortby'] = app.POSTER_SORTBY
        config_data['posterSortdir'] = app.POSTER_SORTDIR
        config_data['rootDirs'] = app.ROOT_DIRS
        config_data['sortArticle'] = app.SORT_ARTICLE
        config_data['timePreset'] = app.TIME_PRESET
        config_data['trimZero'] = app.TRIM_ZERO
        config_data['fanartBackground'] = app.FANART_BACKGROUND
        config_data['fanartBackgroundOpacity'] = float(
            app.FANART_BACKGROUND_OPACITY or 0)
        config_data['branch'] = app.BRANCH
        config_data['commitHash'] = app.CUR_COMMIT_HASH
        config_data['release'] = app.APP_VERSION
        config_data['sslVersion'] = app.OPENSSL_VERSION
        config_data['pythonVersion'] = sys.version
        config_data['databaseVersion'] = NonEmptyDict()
        config_data['databaseVersion']['major'] = app.MAJOR_DB_VERSION
        config_data['databaseVersion']['minor'] = app.MINOR_DB_VERSION
        config_data['os'] = platform.platform()
        config_data['locale'] = '.'.join(
            [text_type(loc or 'Unknown') for loc in app.LOCALE])
        config_data['localUser'] = app.OS_USER or 'Unknown'
        config_data['programDir'] = app.PROG_DIR
        config_data['configFile'] = app.CONFIG_FILE
        config_data['dbFilename'] = db.dbFilename()
        config_data['cacheDir'] = app.CACHE_DIR
        config_data['logDir'] = app.LOG_DIR
        config_data['appArgs'] = app.MY_ARGS
        config_data['webRoot'] = app.WEB_ROOT
        config_data['githubUrl'] = app.GITHUB_IO_URL
        config_data['wikiUrl'] = app.WIKI_URL
        config_data['sourceUrl'] = app.APPLICATION_URL
        config_data['downloadUrl'] = app.DOWNLOAD_URL
        config_data['subtitlesMulti'] = app.SUBTITLES_MULTI
        config_data['namingForceFolders'] = app.NAMING_FORCE_FOLDERS
        config_data['subtitles'] = NonEmptyDict()
        config_data['subtitles']['enabled'] = bool(app.USE_SUBTITLES)
        config_data['kodi'] = NonEmptyDict()
        config_data['kodi']['enabled'] = bool(app.USE_KODI
                                              and app.KODI_UPDATE_LIBRARY)
        config_data['plex'] = NonEmptyDict()
        config_data['plex']['server'] = NonEmptyDict()
        config_data['plex']['server']['enabled'] = bool(app.USE_PLEX_SERVER)
        config_data['plex']['server']['notify'] = NonEmptyDict()
        config_data['plex']['server']['notify']['snatch'] = bool(
            app.PLEX_NOTIFY_ONSNATCH)
        config_data['plex']['server']['notify']['download'] = bool(
            app.PLEX_NOTIFY_ONDOWNLOAD)
        config_data['plex']['server']['notify']['subtitleDownload'] = bool(
            app.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD)

        config_data['plex']['server']['updateLibrary'] = bool(
            app.PLEX_UPDATE_LIBRARY)
        config_data['plex']['server']['host'] = app.PLEX_SERVER_HOST
        config_data['plex']['server']['token'] = app.PLEX_SERVER_TOKEN
        config_data['plex']['server']['username'] = app.PLEX_SERVER_USERNAME
        config_data['plex']['server']['password'] = app.PLEX_SERVER_PASSWORD
        config_data['plex']['client'] = NonEmptyDict()
        config_data['plex']['client']['enabled'] = bool(app.USE_PLEX_CLIENT)
        config_data['plex']['client']['username'] = app.PLEX_CLIENT_USERNAME
        config_data['plex']['client']['password'] = app.PLEX_CLIENT_PASSWORD
        config_data['plex']['client']['host'] = app.PLEX_CLIENT_HOST
        config_data['emby'] = NonEmptyDict()
        config_data['emby']['enabled'] = bool(app.USE_EMBY)
        config_data['torrents'] = NonEmptyDict()
        config_data['torrents']['enabled'] = bool(app.USE_TORRENTS)
        config_data['torrents']['method'] = app.TORRENT_METHOD
        config_data['torrents']['username'] = app.TORRENT_USERNAME
        config_data['torrents']['password'] = app.TORRENT_PASSWORD
        config_data['torrents']['label'] = app.TORRENT_LABEL
        config_data['torrents']['labelAnime'] = app.TORRENT_LABEL_ANIME
        config_data['torrents']['verifySSL'] = app.TORRENT_VERIFY_CERT
        config_data['torrents']['path'] = app.TORRENT_PATH
        config_data['torrents']['seedTime'] = app.TORRENT_SEED_TIME
        config_data['torrents']['paused'] = app.TORRENT_PAUSED
        config_data['torrents']['highBandwidth'] = app.TORRENT_HIGH_BANDWIDTH
        config_data['torrents']['host'] = app.TORRENT_HOST
        config_data['torrents']['rpcurl'] = app.TORRENT_RPCURL
        config_data['torrents']['authType'] = app.TORRENT_AUTH_TYPE
        config_data['nzb'] = NonEmptyDict()
        config_data['nzb']['enabled'] = bool(app.USE_NZBS)
        config_data['nzb']['username'] = app.NZBGET_USERNAME
        config_data['nzb']['password'] = app.NZBGET_PASSWORD
        # app.NZBGET_CATEGORY
        # app.NZBGET_CATEGORY_BACKLOG
        # app.NZBGET_CATEGORY_ANIME
        # app.NZBGET_CATEGORY_ANIME_BACKLOG
        config_data['nzb']['host'] = app.NZBGET_HOST
        config_data['nzb']['priority'] = app.NZBGET_PRIORITY
        config_data['layout'] = NonEmptyDict()
        config_data['layout']['schedule'] = app.COMING_EPS_LAYOUT
        config_data['layout']['history'] = app.HISTORY_LAYOUT
        config_data['layout']['home'] = app.HOME_LAYOUT
        config_data['layout']['show'] = NonEmptyDict()
        config_data['layout']['show']['allSeasons'] = bool(
            app.DISPLAY_ALL_SEASONS)
        config_data['layout']['show']['specials'] = bool(
            app.DISPLAY_SHOW_SPECIALS)
        config_data['selectedRootIndex'] = int(
            app.SELECTED_ROOT
        ) if app.SELECTED_ROOT is not None else -1  # All paths
        config_data['backlogOverview'] = NonEmptyDict()
        config_data['backlogOverview']['period'] = app.BACKLOG_PERIOD
        config_data['backlogOverview']['status'] = app.BACKLOG_STATUS

        if not identifier:
            return self._paginate([config_data])

        if path_param:
            if path_param not in config_data:
                return self._bad_request(
                    '{key} is a invalid path'.format(key=path_param))

            config_data = config_data[path_param]

        return self._ok(data=config_data)
Exemplo n.º 4
0
def config(monkeypatch, app_config):
    python_version = 'Python Test v1.2.3.4'
    monkeypatch.setattr(sys, 'version', python_version)
    os_user = app_config('OS_USER', 'superuser')
    app_config('LOCALE', (None, 'ABC'))
    app_locale = 'Unknown.ABC'

    return {
        'anonRedirect': app.ANON_REDIRECT,
        'anonSplitHome': app.ANIME_SPLIT_HOME,
        'comingEpsLayout': app.COMING_EPS_LAYOUT,
        'comingEpsSort': app.COMING_EPS_SORT,
        'datePreset': app.DATE_PRESET,
        'fuzzyDating': app.FUZZY_DATING,
        'historyLayout': app.HISTORY_LAYOUT,
        'homeLayout': app.HOME_LAYOUT,
        'themeName': app.THEME_NAME,
        'posterSortby': app.POSTER_SORTBY,
        'posterSortdir': app.POSTER_SORTDIR,
        'rootDirs': app.ROOT_DIRS,
        'sortArticle': app.SORT_ARTICLE,
        'timePreset': app.TIME_PRESET,
        'trimZero': app.TRIM_ZERO,
        'fanartBackground': app.FANART_BACKGROUND,
        'fanartBackgroundOpacity': app.FANART_BACKGROUND_OPACITY,
        'branch': app.BRANCH,
        'commitHash': app.CUR_COMMIT_HASH,
        'release': app.APP_VERSION,
        'sslVersion': app.OPENSSL_VERSION,
        'pythonVersion': python_version,
        'databaseVersion': {
            'major': app.MAJOR_DB_VERSION,
            'minor': app.MINOR_DB_VERSION
        },
        'os': platform.platform(),
        'locale': app_locale,
        'localUser': os_user,
        'programDir': app.PROG_DIR,
        'configFile': app.CONFIG_FILE,
        'dbFilename': db.dbFilename(),
        'cacheDir': app.CACHE_DIR,
        'logDir': app.LOG_DIR,
        'appArgs': app.MY_ARGS,
        'webRoot': app.WEB_ROOT,
        'githubUrl': app.GITHUB_IO_URL,
        'wikiUrl': app.WIKI_URL,
        'sourceUrl': app.APPLICATION_URL,
        'displayAllSeasons': app.DISPLAY_ALL_SEASONS,
        'displayShowSpecials': app.DISPLAY_SHOW_SPECIALS,
        'downloadUrl': app.DOWNLOAD_URL,
        'subtitlesMulti': app.SUBTITLES_MULTI,
        'namingForceFolders': app.NAMING_FORCE_FOLDERS,
        'subtitles': {
            'enabled': bool(app.USE_SUBTITLES)
        },
        'kodi': {
            'enabled': bool(app.USE_KODI and app.KODI_UPDATE_LIBRARY)
        },
        'plex': {
            'server': {
                'enabled': bool(app.USE_PLEX_SERVER and app.PLEX_UPDATE_LIBRARY)
            },
            'client': {
                'enabled': False  # Replace this with plex client code
            }
        },
        'emby': {
            'enabled': bool(app.USE_EMBY)
        },
        'torrents': {
            'enabled': bool(app.USE_TORRENTS and app.TORRENT_METHOD != 'blackhole' and
                            (app.ENABLE_HTTPS and app.TORRENT_HOST[:5] == 'https' or
                             not app.ENABLE_HTTPS and app.TORRENT_HOST[:5] == 'http:'))
        }
    }