Beispiel #1
0
    def settings(self, *path):
        page = path[0] if len(path) > 0 else 'server'

        if page == 'server':
            themes = [i[:-4] for i in os.listdir('static/css/themes/') if i.endswith('.css') and os.path.isfile(os.path.join(core.PROG_PATH, 'static/css/themes', i))]
            return App.server_template.render(config=core.CONFIG['Server'], themes=themes, version=core.CURRENT_HASH or '', languages=core.LANGUAGES.keys(), **self.defaults())
        elif page == 'search':
            return App.search_template.render(config=core.CONFIG['Search'], **self.defaults())
        elif page == 'quality':
            return App.quality_template.render(config=core.CONFIG['Quality'], sources=core.SOURCES, **self.defaults())
        elif page == 'categories':
            return App.categories_template.render(config=core.CONFIG['Categories'], sources=core.SOURCES, **self.defaults())
        elif page == 'languages':
            return App.languages_template.render(config=core.CONFIG['Languages'], **self.defaults())
        elif page == 'indexers':
            for indexer in core.CONFIG['Indexers']['TorzNab'].values():
                logging.debug(indexer)
            return App.indexers_template.render(config=core.CONFIG['Indexers'], **self.defaults())
        elif page == 'downloader':
            return App.downloader_template.render(config=core.CONFIG['Downloader'], **self.defaults())
        elif page == 'postprocessing':
            return App.postprocessing_template.render(config=core.CONFIG['Postprocessing'], os=core.PLATFORM, **self.defaults())
        elif page == 'plugins':
            plugs = plugins.list_plugins()
            return App.plugins_template.render(config=core.CONFIG['Plugins'], plugins=plugs, **self.defaults())
        elif page == 'logs':
            logdir = os.path.join(core.PROG_PATH, core.LOG_DIR)
            logfiles = [i for i in os.listdir(logdir) if os.path.isfile(os.path.join(logdir, i))]
            return App.logs_template.render(logdir=logdir, logfiles=logfiles, **self.defaults())
        elif page == 'download_log':
            if len(path) > 1:
                l = os.path.join(os.path.abspath(core.LOG_DIR), path[1])
                return cherrypy.lib.static.serve_file(l, 'application/x-download', 'attachment')
            else:
                raise cherrypy.HTTPError(400)
        elif page == 'system':
            tasks = {}
            for name, obj in core.scheduler_plugin.task_list.items():
                tasks[name] = {'name': name,
                               'interval': obj.interval,
                               'last_execution': obj.last_execution,
                               'enabled': obj.timer.is_alive() if obj.timer else False}

            system = {'database': {'file': core.DB_FILE,
                                   'size': os.path.getsize(core.DB_FILE) / 1024
                                   },
                      'config': {'file': core.CONF_FILE},
                      'system': {'path': core.PROG_PATH,
                                 'arguments': sys.argv,
                                 'version': sys.version[:5]}
                      }
            t = int(time.time())
            dt = time.strftime('%a, %B %d, %Y %H:%M:%S %z', time.localtime(t))
            
            return App.system_template.render(config=core.CONFIG['System'], tasks=json.dumps(tasks), system=system, server_time=[dt, t], **self.defaults())
        else:
            return self.error_page_404()
Beispiel #2
0
    def settings(self, *path):
        page = path[0] if len(path) > 0 else 'server'

        if page == 'server':
            themes = [
                i[:-4] for i in os.listdir('static/css/themes/')
                if i.endswith(".css") and os.path.isfile(
                    os.path.join(core.PROG_PATH, 'static/css/themes', i))
            ]
            return App.server_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Server'],
                themes=themes,
                version=core.CURRENT_HASH or '')
        elif page == 'search':
            return App.search_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Search'])
        elif page == 'quality':
            return App.quality_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Quality'],
                sources=core.SOURCES)
        elif page == 'indexers':
            return App.indexers_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Indexers'])
        elif page == 'downloader':
            return App.downloader_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Downloader'])
        elif page == 'postprocessing':
            return App.postprocessing_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Postprocessing'],
                os=core.PLATFORM)
        elif page == 'plugins':
            plugs = plugins.list_plugins()
            return App.plugins_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                config=core.CONFIG['Plugins'],
                plugins=plugs)
        elif page == 'logs':
            logdir = os.path.join(core.PROG_PATH, core.LOG_DIR)
            logfiles = [
                i for i in os.listdir(logdir)
                if os.path.isfile(os.path.join(logdir, i))
            ]
            return App.logs_template.render(
                url_base=core.URL_BASE,
                head=self.head(),
                navbar=self.nav_bar(current='settings'),
                logdir=logdir,
                logfiles=logfiles)
        else:
            return self.error_page_404()
Beispiel #3
0
    def settings(self, *path):
        page = path[0] if len(path) > 0 else 'server'

        if page == 'server':
            themes = [
                i[:-4] for i in os.listdir('static/css/themes/')
                if i.endswith(".css") and os.path.isfile(
                    os.path.join(core.PROG_PATH, 'static/css/themes', i))
            ]
            return App.server_template.render(config=core.CONFIG['Server'],
                                              themes=themes,
                                              version=core.CURRENT_HASH or '',
                                              **self.defaults())
        elif page == 'search':
            return App.search_template.render(config=core.CONFIG['Search'],
                                              **self.defaults())
        elif page == 'quality':
            return App.quality_template.render(config=core.CONFIG['Quality'],
                                               sources=core.SOURCES,
                                               **self.defaults())
        elif page == 'indexers':
            return App.indexers_template.render(config=core.CONFIG['Indexers'],
                                                **self.defaults())
        elif page == 'downloader':
            return App.downloader_template.render(
                config=core.CONFIG['Downloader'], **self.defaults())
        elif page == 'postprocessing':
            return App.postprocessing_template.render(
                config=core.CONFIG['Postprocessing'],
                os=core.PLATFORM,
                **self.defaults())
        elif page == 'plugins':
            plugs = plugins.list_plugins()
            return App.plugins_template.render(config=core.CONFIG['Plugins'],
                                               plugins=plugs,
                                               **self.defaults())
        elif page == 'logs':
            logdir = os.path.join(core.PROG_PATH, core.LOG_DIR)
            logfiles = [
                i for i in os.listdir(logdir)
                if os.path.isfile(os.path.join(logdir, i))
            ]
            return App.logs_template.render(logdir=logdir,
                                            logfiles=logfiles,
                                            **self.defaults())
        elif page == 'system':
            tasks = {}
            for name, obj in core.scheduler_plugin.task_list.items():
                tasks[name] = {
                    'name': name,
                    'interval': obj.interval,
                    'last_execution': obj.last_execution,
                    'enabled': obj.timer.is_alive()
                }

            system = {
                'database': {
                    'file': core.DB_FILE,
                    'size': os.path.getsize(core.DB_FILE) / 1024
                },
                'config': {
                    'file': core.CONF_FILE
                },
                'system': {
                    'path': core.PROG_PATH,
                    'arguments': sys.argv,
                    'version': sys.version[:5]
                }
            }
            t = int(time.time())
            dt = time.strftime('%a, %B %d, %Y %H:%M:%S %z', time.localtime(t))

            return App.system_template.render(tasks=json.dumps(tasks),
                                              system=system,
                                              server_time=[dt, t],
                                              **self.defaults())
        else:
            return self.error_page_404()