annotate roundup/version_check.py @ 6823:fe0091279f50

Refactor session db logging and key generation for sessions/otks While I was working on the redis sessiondb stuff, I noticed that log_wanrning, get_logger ... was duplicated. Also there was code to generate a unique key for otks that was duplicated. Changes: creating new sessions_common.py and SessionsCommon class to provide methods: log_warning, log_info, log_debug, get_logger, getUniqueKey getUniqueKey method is closer to the method used to make session keys in client.py. sessions_common.py now report when random_.py chooses a weak random number generator. Removed same from rest.py. get_logger reconciles all logging under roundup.hyperdb.backends.<name of BasicDatabase class> some backends used to log to root logger. have BasicDatabase in other sessions_*.py modules inherit from SessionCommon. change logging to use log_* methods. In addition: remove unused imports reported by flake8 and other formatting changes modify actions.py, rest.py, templating.py to use getUniqueKey method. add tests for new methods test_redis_session.py swap out ModuleNotFoundError for ImportError to prevent crash in python2 when redis is not present. allow injection of username:password or just password into redis connection URL. set pytest_redis_pw envirnment variable to password or user:password when running test.
author John Rouillard <rouilj@ieee.org>
date Sun, 07 Aug 2022 01:51:11 -0400
parents 9223ed67af05
children f72381d300a4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
449
141aacfdb34f Centralised the python version check code, bumped version to 2.1.1
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
1 #!/usr/bin/env python
2005
fc52d57c6c3e documentation cleanup
Richard Jones <richard@users.sourceforge.net>
parents: 1090
diff changeset
2
5321
4566360871dc Raises python requirement to 2.7.
Bernhard Reiter <bernhard@intevation.de>
parents: 4682
diff changeset
3 # Roundup requires Python 2.7+ as mentioned in doc\installation.txt
5376
64b05e24dbd8 Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5321
diff changeset
4 from __future__ import print_function
6016
9223ed67af05 flake8 cleanup: move module import before statement.
John Rouillard <rouilj@ieee.org>
parents: 5376
diff changeset
5 import sys
449
141aacfdb34f Centralised the python version check code, bumped version to 2.1.1
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
6
6016
9223ed67af05 flake8 cleanup: move module import before statement.
John Rouillard <rouilj@ieee.org>
parents: 5376
diff changeset
7 VERSION_NEEDED = (2, 7)
9223ed67af05 flake8 cleanup: move module import before statement.
John Rouillard <rouilj@ieee.org>
parents: 5376
diff changeset
8
4682
0c2cad65ebba version_check.py: Bump required Python version from 2.1.1+ to 2.5+
anatoly techtonik <techtonik@gmail.com>
parents: 4570
diff changeset
9 if sys.version_info < VERSION_NEEDED:
5376
64b05e24dbd8 Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5321
diff changeset
10 print("Content-Type: text/plain\n")
64b05e24dbd8 Python 3 preparation: convert print to a function.
Joseph Myers <jsm@polyomino.org.uk>
parents: 5321
diff changeset
11 print("Roundup requires Python %s.%s or newer." % VERSION_NEEDED)
449
141aacfdb34f Centralised the python version check code, bumped version to 2.1.1
Richard Jones <richard@users.sourceforge.net>
parents:
diff changeset
12 sys.exit(0)

Roundup Issue Tracker: http://roundup-tracker.org/