From ed098144605153228dc6ee9679ff7651e4421d4f Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 28 May 2023 20:32:19 +0200 Subject: [PATCH] Prevent log_message on startup logfile Parameter --- cps/__init__.py | 4 ++-- cps/cli.py | 2 ++ cps/config_sql.py | 13 ++++++++----- optional-requirements.txt | 4 ++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cps/__init__.py b/cps/__init__.py index 269e4aca..8b0b86ad 100644 --- a/cps/__init__.py +++ b/cps/__init__.py @@ -86,10 +86,10 @@ app.config.update( lm = MyLoginManager() -config = config_sql.ConfigSQL() - cli_param = CliParameter() +config = config_sql.ConfigSQL() + if wtf_present: csrf = CSRFProtect() else: diff --git a/cps/cli.py b/cps/cli.py index 6f58dcc4..e9b97b9d 100644 --- a/cps/cli.py +++ b/cps/cli.py @@ -48,6 +48,7 @@ class CliParameter(object): 'works only in combination with keyfile') parser.add_argument('-k', metavar='path', help='path and name to SSL keyfile, e.g. /opt/test.key, ' 'works only in combination with certfile') + parser.add_argument('-o', metavar='path', help='path and name Calibre-Web logfile') parser.add_argument('-v', '--version', action='version', help='Shows version number and exits Calibre-Web', version=version_info()) parser.add_argument('-i', metavar='ip-address', help='Server IP-Address to listen') @@ -60,6 +61,7 @@ class CliParameter(object): parser.add_argument('-r', action='store_true', help='Enable public database reconnect route under /reconnect') args = parser.parse_args() + self.logpath = args.o or "" self.settings_path = args.p or os.path.join(_CONFIG_DIR, DEFAULT_SETTINGS_FILE) self.gd_path = args.g or os.path.join(_CONFIG_DIR, DEFAULT_GDRIVE_FILE) diff --git a/cps/config_sql.py b/cps/config_sql.py index 91e4b6af..21644ccd 100644 --- a/cps/config_sql.py +++ b/cps/config_sql.py @@ -83,9 +83,9 @@ class _Settings(_Base): config_theme = Column(Integer, default=0) config_log_level = Column(SmallInteger, default=logger.DEFAULT_LOG_LEVEL) - config_logfile = Column(String) + config_logfile = Column(String, default=logger.DEFAULT_LOG_FILE) config_access_log = Column(SmallInteger, default=0) - config_access_logfile = Column(String) + config_access_logfile = Column(String, default=logger.DEFAULT_ACCESS_LOG) config_uploading = Column(SmallInteger, default=0) config_anonbrowse = Column(SmallInteger, default=0) @@ -341,14 +341,17 @@ class ConfigSQL(object): have_metadata_db = os.path.isfile(db_file) self.db_configured = have_metadata_db constants.EXTENSIONS_UPLOAD = [x.lstrip().rstrip().lower() for x in self.config_upload_formats.split(',')] + from . import cli_param if os.environ.get('FLASK_DEBUG'): logfile = logger.setup(logger.LOG_TO_STDOUT, logger.logging.DEBUG) else: # pylint: disable=access-member-before-definition - logfile = logger.setup(self.config_logfile, self.config_log_level) - if logfile != self.config_logfile: - log.warning("Log path %s not valid, falling back to default", self.config_logfile) + logfile = logger.setup(cli_param.logpath or self.config_logfile, self.config_log_level) + if logfile != os.path.abspath(self.config_logfile): + if logfile != os.path.abspath(cli_param.logpath): + log.warning("Log path %s not valid, falling back to default", self.config_logfile) self.config_logfile = logfile + s.config_logfile = logfile self._session.merge(s) try: self._session.commit() diff --git a/optional-requirements.txt b/optional-requirements.txt index ad2b56c0..5714ac88 100644 --- a/optional-requirements.txt +++ b/optional-requirements.txt @@ -5,8 +5,8 @@ greenlet>=0.4.17,<2.1.0 httplib2>=0.9.2,<0.23.0 oauth2client>=4.0.0,<4.1.4 uritemplate>=3.0.0,<4.2.0 -pyasn1-modules>=0.0.8,<0.3.0 -pyasn1>=0.1.9,<0.5.0 +pyasn1-modules>=0.0.8,<0.4.0 +pyasn1>=0.1.9,<0.6.0 PyDrive2>=1.3.1,<1.16.0 PyYAML>=3.12 rsa>=3.4.2,<4.10.0