Mercurial > p > roundup > code
annotate roundup/configuration.py @ 8447:d06be9346c68
bug, test: fix tests for trace_id; readd import logging.config
Made save_restore_logging a test level fixture. It was a class level
which worked fine until I started using caplog for tests in the same
class. Due to loading config from dict, the roundup channel was set to
not propagate which broke the new formatting test used for trace_id.
Forgot to update some tests due to change in default format adding
%(trace_id).
Also re-added logging.config import which broke loading logging config
files in configuration.py.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 17 Sep 2025 00:45:04 -0400 |
| parents | 14c7c07b32d8 |
| children | 401c6f0be6c5 |
| rev | line source |
|---|---|
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1 # Roundup Issue Tracker configuration support |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2 # |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
3 __docformat__ = "restructuredtext" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
4 |
|
5517
0cdf19b82354
Fix issue2550994: breakage caused by configparser backports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5494
diff
changeset
|
5 # Some systems have a backport of the Python 3 configparser module to |
|
0cdf19b82354
Fix issue2550994: breakage caused by configparser backports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5494
diff
changeset
|
6 # Python 2: <https://pypi.org/project/configparser/>. That breaks |
|
0cdf19b82354
Fix issue2550994: breakage caused by configparser backports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5494
diff
changeset
|
7 # Roundup if used with Python 2 because it generates unicode objects |
|
0cdf19b82354
Fix issue2550994: breakage caused by configparser backports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5494
diff
changeset
|
8 # where not expected by the Python code. Thus, a version check is |
|
0cdf19b82354
Fix issue2550994: breakage caused by configparser backports.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5494
diff
changeset
|
9 # used here instead of try/except. |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
10 import binascii |
|
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
11 import errno |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
12 import getopt |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
13 import logging |
|
8447
d06be9346c68
bug, test: fix tests for trace_id; readd import logging.config
John Rouillard <rouilj@ieee.org>
parents:
8446
diff
changeset
|
14 import logging.config |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
15 import os |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
16 import re |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
17 import smtplib |
|
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
18 import sys |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
19 import time |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
20 import traceback |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
21 |
|
3620
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
22 import roundup.date |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
23 from roundup.anypy import random_ |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
24 from roundup.anypy.strings import b2s |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
25 from roundup.backends import list_backends |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
26 from roundup.i18n import _ |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
27 from roundup.logcontext import gen_trace_id, get_context_info |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
28 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
29 if sys.version_info[0] > 2: |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
30 import configparser # Python 3 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
31 else: |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
32 import ConfigParser as configparser # Python 2 |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
33 |
| 6126 | 34 from roundup.exceptions import RoundupException |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6053
diff
changeset
|
35 |
| 6966 | 36 # Exceptions |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
37 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
38 |
|
6123
c177e7128dc9
issue2551083 Replace BaseException and Exception with RoundupException
John Rouillard <rouilj@ieee.org>
parents:
6053
diff
changeset
|
39 class ConfigurationError(RoundupException): |
|
3777
74aebbbea305
Sorry for the mega-patch - was all done on the train:
Richard Jones <richard@users.sourceforge.net>
parents:
3725
diff
changeset
|
40 pass |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
41 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
42 |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
43 class ParsingOptionError(ConfigurationError): |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
44 def __str__(self): |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
45 return self.args[0] |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
46 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
47 |
|
8423
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
48 class LoggingConfigError(ConfigurationError): |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
49 def __init__(self, message, **attrs): |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
50 super().__init__(message) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
51 for key, value in attrs.items(): |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
52 self.__setattr__(key, value) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
53 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
54 def __str__(self): |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
55 return self.args[0] |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
56 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
57 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
58 class NoConfigError(ConfigurationError): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
59 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
60 """Raised when configuration loading fails |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
61 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
62 Constructor parameters: path to the directory that was used as HOME |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
63 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
64 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
65 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
66 def __str__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
67 return "No valid configuration files found in directory %s" \ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
68 % self.args[0] |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
69 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
70 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
71 class InvalidOptionError(ConfigurationError, KeyError, AttributeError): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
72 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
73 """Attempted access to non-existing configuration option |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
74 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
75 Configuration options may be accessed as configuration object |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
76 attributes or items. So this exception instances also are |
|
3820
771248aa8302
typos in docstrings
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3788
diff
changeset
|
77 instances of KeyError (invalid item access) and AttributeError |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
78 (invalid attribute access). |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
79 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
80 Constructor parameter: option name |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
81 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
82 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
83 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
84 def __str__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
85 return "Unsupported configuration option: %s" % self.args[0] |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
86 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
87 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
88 class OptionValueError(ConfigurationError, ValueError): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
89 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
90 """Raised upon attempt to assign an invalid value to config option |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
91 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
92 Constructor parameters: Option instance, offending value |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
93 and optional info string. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
94 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
95 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
96 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
97 def __str__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
98 _args = self.args |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
99 _rv = "Invalid value for %(option)s: %(value)r" % { |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
100 "option": _args[0].name, "value": _args[1]} |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
101 if len(_args) > 2: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
102 _rv += "\n".join(("",) + _args[2:]) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
103 return _rv |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
104 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
105 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
106 class OptionUnsetError(ConfigurationError): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
107 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
108 """Raised when no Option value is available - neither set, nor default |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
109 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
110 Constructor parameters: Option instance. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
111 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
112 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
113 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
114 def __str__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
115 return "%s is not set and has no default" % self.args[0].name |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
116 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
117 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
118 class UnsetDefaultValue: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
119 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
120 """Special object meaning that default value for Option is not specified""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
121 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
122 def __str__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
123 return "NO DEFAULT" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
124 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
125 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
126 NODEFAULT = UnsetDefaultValue() |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
127 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
128 |
|
5878
1b57d8f3eb97
Add rudimentery experiment JSON Web Token (jwt) support
John Rouillard <rouilj@ieee.org>
parents:
5809
diff
changeset
|
129 def create_token(size=32): |
|
1b57d8f3eb97
Add rudimentery experiment JSON Web Token (jwt) support
John Rouillard <rouilj@ieee.org>
parents:
5809
diff
changeset
|
130 return b2s(binascii.b2a_base64(random_.token_bytes(size)).strip()) |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
131 |
| 6966 | 132 # Option classes |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
133 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
134 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
135 class Option: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
136 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
137 """Single configuration option. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
138 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
139 Options have following attributes: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
140 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
141 config |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
142 reference to the containing Config object |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
143 section |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
144 name of the section in the tracker .ini file |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
145 setting |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
146 option name in the tracker .ini file |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
147 default |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
148 default option value |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
149 description |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
150 option description. Makes a comment in the tracker .ini file |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
151 name |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
152 "canonical name" of the configuration option. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
153 For items in the 'main' section this is uppercased |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
154 'setting' name. For other sections, the name is |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
155 composed of the section name and the setting name, |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
156 joined with underscore. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
157 aliases |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
158 list of "also known as" names. Used to access the settings |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
159 by old names used in previous Roundup versions. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
160 "Canonical name" is also included. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
161 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
162 The name and aliases are forced to be uppercase. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
163 The setting name is forced to lowercase. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
164 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
165 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
166 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
167 class_description = None |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
168 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
169 def __init__(self, config, section, setting, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
170 default=NODEFAULT, description=None, aliases=None): |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
171 self.config = config |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
172 self.section = section |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
173 self.setting = setting.lower() |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
174 self.default = default |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
175 self.description = description |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
176 self.name = setting.upper() |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
177 if section != "main": |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
178 self.name = "_".join((section.upper(), self.name)) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
179 if aliases: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
180 self.aliases = [alias.upper() for alias in list(aliases)] |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
181 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
182 self.aliases = [] |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
183 self.aliases.insert(0, self.name) |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
184 # convert default to internal representation |
|
7811
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
185 _value = default if default is NODEFAULT else self.str2value(default) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
186 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
187 # value is private. use get() and set() to access |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
188 self._value = self._default_value = _value |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
189 |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
190 def str2value(self, value): |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
191 """Return 'value' argument converted to internal representation""" |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
192 return value |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
193 |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
194 def _value2str(self, value): |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
195 """Return 'value' argument converted to external representation |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
196 |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
197 This is actual conversion method called only when value |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
198 is not NODEFAULT. Heirs with different conversion rules |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
199 override this method, not the public .value2str(). |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
200 |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
201 """ |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
202 return str(value) |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
203 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
204 def value2str(self, value=NODEFAULT, current=0): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
205 """Return 'value' argument converted to external representation |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
206 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
207 If 'current' is True, use current option value. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
208 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
209 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
210 if current: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
211 value = self._value |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
212 if value is NODEFAULT: |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
213 return str(value) |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
214 else: |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
215 return self._value2str(value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
216 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
217 def get(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
218 """Return current option value""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
219 if self._value is NODEFAULT: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
220 raise OptionUnsetError(self) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
221 return self._value |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
222 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
223 def set(self, value): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
224 """Update the value""" |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
225 self._value = self.str2value(value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
226 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
227 def reset(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
228 """Reset the value to default""" |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
229 self._value = self._default_value |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
230 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
231 def isdefault(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
232 """Return True if current value is the default one""" |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
233 return self._value == self._default_value |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
234 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
235 def isset(self): |
|
3820
771248aa8302
typos in docstrings
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3788
diff
changeset
|
236 """Return True if the value is available (either set or default)""" |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
237 return self._value != NODEFAULT |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
238 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
239 def __str__(self): |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
240 return self.value2str(self._value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
241 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
242 def __repr__(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
243 if self.isdefault(): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
244 _format = "<%(class)s %(name)s (default): %(value)s>" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
245 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
246 _format = "<%(class)s %(name)s (default: %(default)s): %(value)s>" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
247 return _format % { |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
248 "class": self.__class__.__name__, |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
249 "name": self.name, |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
250 "default": self.value2str(self._default_value), |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
251 "value": self.value2str(self._value), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
252 } |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
253 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
254 def format(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
255 """Return .ini file fragment for this option""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
256 _desc_lines = [] |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
257 for _description in (self.description, self.class_description): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
258 if _description: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
259 _desc_lines.extend(_description.split("\n")) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
260 # comment out the setting line if there is no value |
|
7811
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
261 _is_set = "" if self.isset() else "#" |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
262 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
263 _rv = "# %(description)s\n# Default: %(default)s\n" \ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
264 "%(is_set)s%(name)s = %(value)s\n" % { |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
265 "description": "\n# ".join(_desc_lines), |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
266 "default": self.value2str(self._default_value), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
267 "name": self.setting, |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
268 "value": self.value2str(self._value), |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
269 "is_set": _is_set, |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
270 } |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
271 return _rv |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
272 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
273 def load_ini(self, config): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
274 """Load value from ConfigParser object""" |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
275 try: |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
276 if config.has_option(self.section, self.setting): |
|
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
277 self.set(config.get(self.section, self.setting)) |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
278 except (configparser.InterpolationSyntaxError, |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
279 configparser.InterpolationMissingOptionError) as e: |
|
6557
8687c096a945
Handle configparser.InterpolationSyntaxError
John Rouillard <rouilj@ieee.org>
parents:
6514
diff
changeset
|
280 raise ParsingOptionError( |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
281 _("Error in %(filepath)s with section [%(section)s] at " |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
282 "option %(option)s: %(message)s") % { |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
283 "filepath": self.config.filepath, |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
284 "section": e.section, |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
285 "option": e.option, |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
286 "message": str(e)}) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
287 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
288 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
289 class BooleanOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
290 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
291 """Boolean option: yes or no""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
292 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
293 class_description = "Allowed values: yes, no" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
294 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
295 def _value2str(self, value): |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
296 if value: |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
297 return "yes" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
298 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
299 return "no" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
300 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
301 def str2value(self, value): |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
302 if isinstance(value, type("")): |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
303 _val = value.lower() |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
304 if _val in ("yes", "true", "on", "1"): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
305 _val = 1 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
306 elif _val in ("no", "false", "off", "0"): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
307 _val = 0 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
308 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
309 raise OptionValueError(self, value, self.class_description) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
310 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
311 _val = value and 1 or 0 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
312 return _val |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
313 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
314 |
|
3544
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
315 class WordListOption(Option): |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
316 |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
317 """List of strings""" |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
318 |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
319 class_description = "Allowed values: comma-separated list of words" |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
320 |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
321 def _value2str(self, value): |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
322 return ','.join(value) |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
323 |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
324 def str2value(self, value): |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
325 return value.split(',') |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
326 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
327 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
328 class RunDetectorOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
329 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
330 """When a detector is run: always, never or for new items only""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
331 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
332 class_description = "Allowed values: yes, no, new" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
333 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
334 def str2value(self, value): |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
335 _val = value.lower() |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
336 if _val in ("yes", "no", "new"): |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
337 return _val |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
338 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
339 raise OptionValueError(self, value, self.class_description) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
340 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
341 |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
342 class CsrfSettingOption(Option): |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
343 |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
344 """How should a csrf measure be enforced: required, yes, logfailure, no""" |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
345 |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
346 class_description = "Allowed values: required, yes, logfailure, no" |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
347 |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
348 def str2value(self, value): |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
349 _val = value.lower() |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
350 if _val in ("required", "yes", "logfailure", "no"): |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
351 return _val |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
352 else: |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
353 raise OptionValueError(self, value, self.class_description) |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
354 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
355 |
|
5212
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
356 class SameSiteSettingOption(Option): |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
357 |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
358 """How should the SameSite cookie setting be set: strict, lax |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
359 or should it not be added (none)""" |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
360 |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
361 class_description = "Allowed values: Strict, Lax, None" |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
362 |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
363 def str2value(self, value): |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
364 _val = value.lower() |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
365 if _val in ("strict", "lax", "none"): |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
366 return _val.capitalize() |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
367 else: |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
368 raise OptionValueError(self, value, self.class_description) |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
369 |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
370 |
|
5748
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
371 class DatabaseBackend(Option): |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
372 """handle exact text of backend and make sure it's available""" |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
373 class_description = "Available backends: %s" % ", ".join(list_backends()) |
|
5748
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
374 |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
375 def str2value(self, value): |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
376 _val = value.lower() |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
377 if _val in list_backends(): |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
378 return _val |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
379 else: |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
380 raise OptionValueError(self, value, self.class_description) |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
381 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
382 |
|
5305
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
383 class HtmlToTextOption(Option): |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
384 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
385 """What module should be used to convert emails with only text/html |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
386 parts into text for display in roundup. Choose from beautifulsoup |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
387 4, dehtml - the internal code or none to disable html to text |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
388 conversion. If beautifulsoup chosen but not available, dehtml will |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
389 be used. |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
390 |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
391 """ |
|
5305
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
392 |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
393 class_description = "Allowed values: beautifulsoup, dehtml, none" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
394 |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
395 def str2value(self, value): |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
396 _val = value.lower() |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
397 if _val in ("beautifulsoup", "dehtml", "none"): |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
398 return _val |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
399 else: |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
400 raise OptionValueError(self, value, self.class_description) |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
401 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
402 |
|
7964
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
403 class HtmlVersionOption(Option): |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
404 """Accept html4 only for now. Raise error for xhtml which is not |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
405 supported in roundup 2.4 and newer.""" |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
406 |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
407 class_description = "Allowed values: html4" |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
408 |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
409 def str2value(self, value): |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
410 _val = value.lower() |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
411 if _val in ("html4"): |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
412 return _val |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
413 else: |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
414 raise OptionValueError(self, value, self.class_description) |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
415 |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
416 class EmailBodyOption(Option): |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
417 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
418 """When to replace message body or strip quoting: always, never |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
419 or for new items only""" |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
420 |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
421 class_description = "Allowed values: yes, no, new" |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
422 |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
423 def str2value(self, value): |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
424 _val = value.lower() |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
425 if _val in ("yes", "no", "new"): |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
426 return _val |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
427 else: |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
428 raise OptionValueError(self, value, self.class_description) |
|
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
429 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
430 |
|
4887
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
431 class IsolationOption(Option): |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
432 """Database isolation levels""" |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
433 |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
434 allowed = ('read uncommitted', 'read committed', 'repeatable read', |
|
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
435 'serializable') |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
436 class_description = "Allowed values: %s" % ', '.join("'%s'" % a |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
437 for a in allowed) |
|
4887
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
438 |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
439 def str2value(self, value): |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
440 _val = value.lower() |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
441 if _val in self.allowed: |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
442 return _val |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
443 raise OptionValueError(self, value, self.class_description) |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
444 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
445 |
| 6358 | 446 class IndexerOption(Option): |
| 447 """Valid options for indexer""" | |
| 448 | |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
449 allowed = ('', 'xapian', 'whoosh', 'native', 'native-fts') |
| 6358 | 450 class_description = "Allowed values: %s" % ', '.join("'%s'" % a |
| 451 for a in allowed) | |
| 452 | |
|
6604
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
453 # FIXME this is the result of running: |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
454 # SELECT cfgname FROM pg_ts_config; |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
455 # on a postgresql 14.1 server. |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
456 # So the best we can do is hardcode this. |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
457 valid_langs = ("simple", |
| 6966 | 458 "custom1", |
| 459 "custom2", | |
| 460 "custom3", | |
| 461 "custom4", | |
| 462 "custom5", | |
| 463 "arabic", | |
| 464 "armenian", | |
| 465 "basque", | |
| 466 "catalan", | |
| 467 "danish", | |
| 468 "dutch", | |
| 469 "english", | |
| 470 "finnish", | |
| 471 "french", | |
| 472 "german", | |
| 473 "greek", | |
| 474 "hindi", | |
| 475 "hungarian", | |
| 476 "indonesian", | |
| 477 "irish", | |
| 478 "italian", | |
| 479 "lithuanian", | |
| 480 "nepali", | |
| 481 "norwegian", | |
| 482 "portuguese", | |
| 483 "romanian", | |
| 484 "russian", | |
| 485 "serbian", | |
| 486 "spanish", | |
| 487 "swedish", | |
| 488 "tamil", | |
| 489 "turkish", | |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
490 "yiddish") |
| 6966 | 491 |
| 6358 | 492 def str2value(self, value): |
| 493 _val = value.lower() | |
| 494 if _val in self.allowed: | |
| 495 return _val | |
| 496 raise OptionValueError(self, value, self.class_description) | |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
497 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
498 def validate(self, options): |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
499 |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
500 if self._value in ("", "xapian"): |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
501 try: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
502 import xapian |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
503 except ImportError: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
504 # indexer is probably '' and xapian isn't present |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
505 # so just return at end of method |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
506 pass |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
507 else: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
508 try: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
509 lang = options["INDEXER_LANGUAGE"]._value |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
510 xapian.Stem(lang) |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
511 except xapian.InvalidArgumentError: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
512 import textwrap |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
513 lang_avail = b2s(xapian.Stem.get_available_languages()) |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
514 languages = textwrap.fill(_("Valid languages: ") + |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
515 lang_avail, 75, |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
516 subsequent_indent=" ") |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
517 raise OptionValueError(options["INDEXER_LANGUAGE"], |
| 6966 | 518 lang, languages) |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
519 |
|
6604
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
520 if self._value == "native-fts": |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
521 lang = options["INDEXER_LANGUAGE"]._value |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
522 if lang not in self.valid_langs: |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
523 import textwrap |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
524 languages = textwrap.fill(_("Expected languages: ") + |
| 6966 | 525 " ".join(self.valid_langs), 75, |
| 526 subsequent_indent=" ") | |
|
6604
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
527 raise OptionValueError(options["INDEXER_LANGUAGE"], |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
528 lang, languages) |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
529 |
| 6966 | 530 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
531 class MailAddressOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
532 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
533 """Email address |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
534 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
535 Email addresses may be either fully qualified or local. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
536 In the latter case MAIL_DOMAIN is automatically added. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
537 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
538 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
539 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
540 def get(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
541 _val = Option.get(self) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
542 if "@" not in _val: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
543 _val = "@".join((_val, self.config["MAIL_DOMAIN"])) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
544 return _val |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
545 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
546 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
547 class FilePathOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
548 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
549 """File or directory path name |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
550 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
551 Paths may be either absolute or relative to the HOME. |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
552 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
553 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
554 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
555 class_description = "The path may be either absolute or relative\n" \ |
|
5102
96dc9f07340a
issue2161722: oudated docs
John Rouillard <rouilj@ieee.org>
parents:
5098
diff
changeset
|
556 "to the directory containing this config file." |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
557 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
558 def get(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
559 _val = Option.get(self) |
|
2619
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
560 if _val and not os.path.isabs(_val): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
561 _val = os.path.join(self.config["HOME"], _val) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
562 return _val |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
563 |
| 6966 | 564 |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
565 class SpaceSeparatedListOption(Option): |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
566 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
567 """List of space seperated elements. |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
568 """ |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
569 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
570 class_description = "A list of space separated elements." |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
571 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
572 def get(self): |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
573 _val = Option.get(self) |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
574 pathlist = list(_val.split()) |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
575 if pathlist: |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
576 return pathlist |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
577 else: |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
578 return None |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
579 |
| 6966 | 580 |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
581 class LoggingFormatOption(Option): |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
582 """Escape/unescape logging format string '%(' <-> '%%(' |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
583 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
584 Config file parsing allows variable interpolation using |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
585 %(keyname)s. However this is exactly the format that we need |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
586 for creating a logging format string. So we tell the user to |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
587 quote the string using %%(...). Then we turn %%( -> %( when |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
588 retrieved and turn %( into %%( when saving the file. |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
589 """ |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
590 |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
591 class_description = ("Allowed value: Python LogRecord attribute named " |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
592 "formats with % *sign doubled*.\n" |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
593 "Also you can include the following attributes:\n" |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
594 " %%(trace_id)s %%(trace_reason)s and %%(pct_char)s" |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
595 ) |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
596 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
597 def str2value(self, value): |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
598 """Validate and convert value of logging format string. |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
599 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
600 This does a dirty check to see if a token is missing a |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
601 specifier. So "%%(ascdate)s %%(level) " would fail because of |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
602 the 's' missing after 'level)'. But "%%(ascdate)s %%(level)s" |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
603 would pass. |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
604 |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
605 Note that '%(foo)s' (i.e. unescaped substitution) generates |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
606 a error from the ini parser with a less than wonderful message. |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
607 """ |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
608 unquoted_val = value.replace("%%(", "%(") |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
609 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
610 # regexp matches all current logging record object attribute names. |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
611 scanned_result = re.sub(r'%\([A-Za-z_]+\)\S', '', unquoted_val) |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
612 if scanned_result.find('%(') != -1: |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
613 raise OptionValueError( |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
614 self, unquoted_val, |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
615 "Check that all substitution tokens have a format " |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
616 "specifier after the ). Unrecognized use of %%(...) in: " |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
617 "%s" % scanned_result) |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
618 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
619 return str(unquoted_val) |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
620 |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
621 def _value2str(self, value): |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
622 """Replace %( with %%( to quote the format substitution param. |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
623 """ |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
624 return value.replace("%(", "%%(") |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
625 |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
626 |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
627 class OriginHeadersListOption(Option): |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
628 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
629 """List of space seperated origin header values. |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
630 """ |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
631 |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
632 class_description = "A list of space separated case sensitive\norigin headers 'scheme://host'." |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
633 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
634 def set(self, _val): |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
635 pathlist = list(_val.split()) |
|
7155
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
636 if '*' in pathlist and pathlist[0] != '*': |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
637 raise OptionValueError( |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
638 self, _val, |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
639 "If using '*' it must be the first element.") |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
640 self._value = pathlist |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
641 |
|
6682
0b8d34b64930
issue2551205 bugfix missing _value2str
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
642 def _value2str(self, value): |
|
0b8d34b64930
issue2551205 bugfix missing _value2str
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
643 return ','.join(value) |
|
0b8d34b64930
issue2551205 bugfix missing _value2str
John Rouillard <rouilj@ieee.org>
parents:
6681
diff
changeset
|
644 |
| 6966 | 645 |
|
5231
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
646 class MultiFilePathOption(Option): |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
647 |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
648 """List of space seperated File or directory path name |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
649 |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
650 Paths may be either absolute or relative to the HOME. None |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
651 is returned if there are no elements. |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
652 |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
653 """ |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
654 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
655 class_description = "The space separated paths may be either absolute\n" \ |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
656 "or relative to the directory containing this config file." |
|
5231
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
657 |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
658 def get(self): |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
659 pathlist = [] |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
660 _val = Option.get(self) |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
661 for elem in _val.split(): |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
662 if elem and not os.path.isabs(elem): |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
663 pathlist.append(os.path.join(self.config["HOME"], elem)) |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
664 else: |
|
7915
82093eb944d6
test - normalize path for MultiFilePathOptions
John Rouillard <rouilj@ieee.org>
parents:
7860
diff
changeset
|
665 pathlist.append(os.path.normpath(elem)) |
|
5231
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
666 if pathlist: |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
667 return pathlist |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
668 else: |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
669 return None |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
670 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
671 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
672 class FloatNumberOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
673 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
674 """Floating point numbers""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
675 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
676 def str2value(self, value): |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
677 try: |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
678 return float(value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
679 except ValueError: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
680 raise OptionValueError(self, value, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
681 "Floating point number required") |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
682 |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
683 def _value2str(self, value): |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
684 _val = str(value) |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
685 # strip fraction part from integer numbers |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
686 if _val.endswith(".0"): |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
687 _val = _val[:-2] |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
688 return _val |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
689 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
690 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
691 class IntegerNumberOption(Option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
692 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
693 """Integer numbers""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
694 |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
695 def str2value(self, value): |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
696 try: |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
697 return int(value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
698 except ValueError: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
699 raise OptionValueError(self, value, "Integer number required") |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
700 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
701 |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
702 class IntegerNumberGeqZeroOption(Option): |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
703 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
704 """Integer numbers greater than or equal to zero.""" |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
705 |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
706 def str2value(self, value): |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
707 try: |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
708 v = int(value) |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
709 if v < 0: |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
710 raise OptionValueError(self, value, |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
711 "Integer number greater than or equal to zero required") |
|
5773
1151a2b31f1d
Yeah, let's actually return the option value.....
John Rouillard <rouilj@ieee.org>
parents:
5772
diff
changeset
|
712 return v |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
713 except OptionValueError: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
714 raise # pass through subclass |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
715 except ValueError: |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
716 raise OptionValueError(self, value, "Integer number required") |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
717 |
|
7567
5e118944ef75
flake8: add extra blank lines
John Rouillard <rouilj@ieee.org>
parents:
7556
diff
changeset
|
718 |
|
7556
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
719 class IntegerNumberGtZeroOption(Option): |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
720 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
721 """Integer numbers greater than zero.""" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
722 |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
723 def str2value(self, value): |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
724 try: |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
725 v = int(value) |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
726 if v < 1: |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
727 raise OptionValueError(self, value, |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
728 "Integer number greater than zero required") |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
729 return v |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
730 except OptionValueError: |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
731 raise # pass through subclass |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
732 except ValueError: |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
733 raise OptionValueError(self, value, "Integer number required") |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
734 |
|
7567
5e118944ef75
flake8: add extra blank lines
John Rouillard <rouilj@ieee.org>
parents:
7556
diff
changeset
|
735 |
|
3609
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
736 class OctalNumberOption(Option): |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
737 |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
738 """Octal Integer numbers""" |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
739 |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
740 def str2value(self, value): |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
741 try: |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
742 return int(value, 8) |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
743 except ValueError: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
744 raise OptionValueError(self, value, |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
745 "Octal Integer number required") |
|
3609
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
746 |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
747 def _value2str(self, value): |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
748 return oct(value) |
|
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
749 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
750 |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
751 class MandatoryOption(Option): |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
752 """Option must not be empty""" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
753 def str2value(self, value): |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
754 if not value: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
755 raise OptionValueError(self, value, "Value must not be empty.") |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
756 else: |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
757 return value |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
758 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
759 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
760 class SecretOption(Option): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
761 """A string not beginning with file:// or a file starting with file:// |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
762 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
763 Paths may be either absolute or relative to the HOME. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
764 Value for option is the first line in the file. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
765 It is mean to store secret information in the config file but |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
766 allow the config file to be stored in version control without |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
767 storing the secret there. |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
768 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
769 """ |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
770 |
| 6966 | 771 class_description = ( |
| 772 "A string that starts with 'file://' is interpreted\n" | |
| 773 "as a file path relative to the tracker home. Using\n" | |
| 774 "'file:///' defines an absolute path. The first\n" | |
| 775 "line of the file will be used as the value. Any\n" | |
| 776 "string that does not start with 'file://' is used\n" | |
| 777 "as is. It removes any whitespace at the end of the\n" | |
| 778 "line, so a newline can be put in the file.\n") | |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
779 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
780 def get(self): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
781 _val = Option.get(self) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
782 if isinstance(_val, str) and _val.startswith('file://'): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
783 filepath = _val[7:] |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
784 if filepath and not os.path.isabs(filepath): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
785 filepath = os.path.join(self.config["HOME"], filepath.strip()) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
786 try: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
787 with open(filepath) as f: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
788 _val = f.readline().rstrip() |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
789 # except FileNotFoundError: py2/py3 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
790 # compatible version |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
791 except EnvironmentError as e: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
792 if e.errno != errno.ENOENT: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
793 raise |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
794 else: |
| 6966 | 795 raise OptionValueError( |
| 796 self, _val, | |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
797 "Unable to read value for %s. Error opening " |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
798 "%s: %s." % (self.name, e.filename, e.args[1])) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
799 return self.str2value(_val) |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
800 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
801 def validate(self, options): |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
802 if self.name == 'MAIL_PASSWORD': |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
803 if options['MAIL_USERNAME']._value: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
804 # MAIL_PASSWORD is an exception. It is mandatory only |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
805 # if MAIL_USERNAME is set. So check only if username |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
806 # is set. |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
807 try: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
808 self.get() |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
809 except OptionUnsetError: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
810 # provide error message with link to MAIL_USERNAME |
| 6966 | 811 raise OptionValueError( |
| 812 options["MAIL_PASSWORD"], | |
| 813 "not defined", | |
| 814 "Mail username is set, so this must be defined.") | |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
815 else: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
816 self.get() |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
817 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
818 |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
819 class WebUrlOption(Option): |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
820 """URL MUST start with http/https scheme and end with '/'""" |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
821 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
822 def str2value(self, value): |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
823 if not value: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
824 raise OptionValueError(self, value, "Value must not be empty.") |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
825 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
826 error_msg = '' |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
827 if not value.startswith(('http://', 'https://')): |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
828 error_msg = "Value must start with http:// or https://.\n" |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
829 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
830 if not value.endswith('/'): |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
831 error_msg += "Value must end with /." |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
832 |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
833 if error_msg: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
834 raise OptionValueError(self, value, error_msg) |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
835 else: |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
836 return value |
|
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
837 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
838 |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
839 class NullableOption(Option): |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
840 |
|
4074
e039f3cbbb96
Make RDBMS cache-size configurable.
Stefan Seefeld <stefan@seefeld.name>
parents:
4013
diff
changeset
|
841 """Option that is set to None if its string value is one of NULL strings |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
842 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
843 Default nullable strings list contains empty string only. |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
844 There is constructor parameter allowing to specify different nullables. |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
845 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
846 Conversion to external representation returns the first of the NULL |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
847 strings list when the value is None. |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
848 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
849 """ |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
850 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
851 NULL_STRINGS = ("",) |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
852 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
853 def __init__(self, config, section, setting, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
854 default=NODEFAULT, description=None, aliases=None, |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
855 null_strings=NULL_STRINGS): |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
856 self.null_strings = list(null_strings) |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
857 Option.__init__(self, config, section, setting, default, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
858 description, aliases) |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
859 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
860 def str2value(self, value): |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
861 if value in self.null_strings: |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
862 return None |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
863 else: |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
864 return value |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
865 |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
866 def _value2str(self, value): |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
867 if value is None: |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
868 return self.null_strings[0] |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
869 else: |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
870 return value |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
871 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
872 |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
873 class NullableFilePathOption(NullableOption, FilePathOption): |
|
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
874 |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
875 # .get() and class_description are from FilePathOption, |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
876 get = FilePathOption.get |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
877 class_description = FilePathOption.class_description |
|
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
878 # everything else taken from NullableOption (inheritance order) |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
879 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
880 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
881 class SecretMandatoryOption(MandatoryOption, SecretOption): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
882 # use get from SecretOption and rest from MandatoryOption |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
883 get = SecretOption.get |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
884 class_description = SecretOption.class_description |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
885 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
886 |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
887 class SecretNullableOption(NullableOption, SecretOption): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
888 # use get from SecretOption and rest from NullableOption |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
889 get = SecretOption.get |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
890 class_description = SecretOption.class_description |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
891 |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
892 |
|
7809
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
893 class ListSecretOption(SecretOption): |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
894 # use get from SecretOption |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
895 def get(self): |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
896 value = SecretOption.get(self) |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
897 return [x.lstrip() for x in value.split(',')] |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
898 |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
899 class_description = SecretOption.class_description |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
900 |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
901 def validate(self, options): # noqa: ARG002 -- options unused |
|
7809
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
902 if self.name == "WEB_JWT_SECRET": |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
903 secrets = self.get() |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
904 invalid_secrets = [x for x in secrets[1:] if len(x) < 32] |
|
7809
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
905 if invalid_secrets: |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
906 raise OptionValueError( |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
907 self, ", ".join(secrets), |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
908 "One or more secrets less then 32 characters in length\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
909 "found: %s" % ', '.join(invalid_secrets)) |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
910 else: |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
911 self.get() |
| 6966 | 912 |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
913 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
914 class RedisUrlOption(SecretNullableOption): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
915 """Do required check to make sure known bad parameters are not |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
916 put in the url. |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
917 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
918 Should I do more URL validation? Validate schema: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
919 redis, rediss, unix? How many cycles to invest |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
920 to keep users from their own mistakes? |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
921 """ |
| 6966 | 922 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
923 class_description = SecretNullableOption.class_description |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
924 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
925 def str2value(self, value): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
926 if value and value.find("decode_responses") != -1: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
927 raise OptionValueError(self, value, "URL must not include " |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
928 "decode_responses. Please remove " |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
929 "the option.") |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
930 return value |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
931 |
| 6966 | 932 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
933 class SessiondbBackendOption(Option): |
| 7219 | 934 """Make sure that sessiondb is compatible with the primary db. |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
935 Fail with error and suggestions if they are incompatible. |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
936 """ |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
937 |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
938 compatibility_matrix = ( |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
939 ('anydbm', 'anydbm'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
940 ('anydbm', 'redis'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
941 ('sqlite', 'anydbm'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
942 ('sqlite', 'sqlite'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
943 ('sqlite', 'redis'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
944 ('mysql', 'mysql'), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
945 ('postgresql', 'postgresql'), |
|
7845
0c71ac9cdcd0
chore(lint): change class props from mutable lists to tuples
John Rouillard <rouilj@ieee.org>
parents:
7844
diff
changeset
|
946 ) |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
947 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
948 def validate(self, options): |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
949 ''' make sure session db is compatible with primary db. |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
950 also if redis is specified make sure it's available. |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
951 suggest valid session db backends include redis if |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
952 available. |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
953 ''' |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
954 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
955 if self.name == 'SESSIONDB_BACKEND': |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
956 rdbms_backend = options['RDBMS_BACKEND']._value |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
957 sessiondb_backend = self._value |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
958 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
959 if not sessiondb_backend: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
960 # unset will choose default |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
961 return |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
962 |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
963 redis_available = False |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
964 try: |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
965 import redis # noqa: F401 |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
966 redis_available = True |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
967 except ImportError: |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
968 if sessiondb_backend == 'redis': |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
969 valid_session_backends = ', '.join(sorted( |
| 6966 | 970 [x[1] for x in self.compatibility_matrix |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
971 if x[0] == rdbms_backend and x[1] != 'redis'])) |
| 6966 | 972 raise OptionValueError( |
| 973 self, sessiondb_backend, | |
| 974 "Unable to load redis module. Please install " | |
| 975 "a redis library or choose\n an alternate " | |
| 976 "session db: %(valid_session_backends)s" % locals()) | |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
977 |
| 6966 | 978 if ((rdbms_backend, sessiondb_backend) not in |
| 979 self.compatibility_matrix): | |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
980 valid_session_backends = ', '.join(sorted( |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
981 {x[1] for x in self.compatibility_matrix |
| 6966 | 982 if x[0] == rdbms_backend and |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
983 (redis_available or x[1] != 'redis')})) |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
984 |
| 6966 | 985 raise OptionValueError( |
| 986 self, sessiondb_backend, | |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
987 "You can not use session db type: %(sessiondb_backend)s " |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
988 "with %(rdbms_backend)s.\n Valid session db types: " |
| 6966 | 989 "%(valid_session_backends)s." % locals()) |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
990 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
991 |
|
3620
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
992 class TimezoneOption(Option): |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
993 |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
994 class_description = \ |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
995 "If pytz module is installed, value may be any valid\n" \ |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
996 "timezone specification (e.g. EET or Europe/Warsaw).\n" \ |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
997 "If pytz is not installed, value must be integer number\n" \ |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
998 "giving local timezone offset from UTC in hours." |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
999 |
|
5754
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1000 # fix issue2551030, default value for timezone |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1001 # Must be 0 if no pytz can be UTC if pytz. |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1002 try: |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1003 import pytz |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1004 defaulttz = "UTC" |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1005 except ImportError: |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1006 defaulttz = "0" |
|
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1007 |
|
3620
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1008 def str2value(self, value): |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1009 try: |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1010 roundup.date.get_timezone(value) |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1011 except KeyError: |
| 6966 | 1012 raise OptionValueError( |
| 1013 self, value, | |
| 1014 "Timezone name or numeric hour offset required") | |
|
3620
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1015 return value |
|
17124caa2491
added timezone option (based on patch [SF#1465296])
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3609
diff
changeset
|
1016 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1017 |
|
6514
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1018 class HttpVersionOption(Option): |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1019 """Used by roundup-server to verify http version is set to valid |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1020 string.""" |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1021 |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1022 def str2value(self, value): |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1023 if value not in ["HTTP/1.0", "HTTP/1.1"]: |
| 6966 | 1024 raise OptionValueError( |
| 1025 self, value, | |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1026 "Valid vaues for -V or --http_version are: HTTP/1.0, HTTP/1.1") |
|
6514
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1027 return value |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1028 |
|
a036712c96f4
Enable HTTP/1.1 support for roundup-server
John Rouillard <rouilj@ieee.org>
parents:
6458
diff
changeset
|
1029 |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1030 class RegExpOption(Option): |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1031 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1032 """Regular Expression option (value is Regular Expression Object)""" |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1033 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1034 class_description = "Value is Python Regular Expression (UTF8-encoded)." |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1035 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1036 RE_TYPE = type(re.compile("")) |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1037 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1038 def __init__(self, config, section, setting, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1039 default=NODEFAULT, description=None, aliases=None, |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1040 flags=0): |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1041 self.flags = flags |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1042 Option.__init__(self, config, section, setting, default, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1043 description, aliases) |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1044 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1045 def _value2str(self, value): |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1046 assert isinstance(value, self.RE_TYPE) # noqa: S101 -- assert is ok |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1047 return value.pattern |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1048 |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1049 def str2value(self, value): |
|
5416
56c9bcdea47f
Python 3 preparation: unicode.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5395
diff
changeset
|
1050 if not isinstance(value, type(u'')): |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1051 value = str(value) |
|
5416
56c9bcdea47f
Python 3 preparation: unicode.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5395
diff
changeset
|
1052 if not isinstance(value, type(u'')): |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1053 # if it is 7-bit ascii, use it as string, |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1054 # otherwise convert to unicode. |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1055 try: |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1056 value.decode("ascii") |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1057 except UnicodeError: |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1058 value = value.decode("utf-8") |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1059 return re.compile(value, self.flags) |
|
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1060 |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
1061 |
|
7726
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1062 class LogLevelOption(Option): |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1063 """A log level, one of none, debug, info, warning, error, critical""" |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1064 |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
1065 values = "none debug info warning error critical".split() |
|
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
1066 class_description = "Allowed values: %s" % (', '.join(values)) |
|
7726
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1067 |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1068 def str2value(self, value): |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1069 _val = value.lower() |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1070 if _val in self.values: |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1071 return _val |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1072 else: |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1073 raise OptionValueError(self, value, self.class_description) |
| 6966 | 1074 |
|
7844
b95474b23440
chore(lint): whitespace fixes, double space between class stanzas
John Rouillard <rouilj@ieee.org>
parents:
7812
diff
changeset
|
1075 |
|
6730
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1076 try: |
|
7810
890097bc4cd0
chore(ruff): sort imports
John Rouillard <rouilj@ieee.org>
parents:
7809
diff
changeset
|
1077 import jinja2 # noqa: F401 |
| 6966 | 1078 jinja2_avail = "Available found" |
|
6730
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1079 except ImportError: |
| 6966 | 1080 jinja2_avail = "Unavailable needs" |
|
6730
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1081 |
| 6966 | 1082 # Main configuration layout. |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1083 # Config is described as a sequence of sections, |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1084 # where each section name is followed by a sequence |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1085 # of Option definitions. Each Option definition |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1086 # is a sequence containing class name and constructor |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1087 # parameters, starting from the setting name: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1088 # setting, default, [description, [aliases]] |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1089 # Note: aliases should only exist in historical options for backwards |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1090 # compatibility - new options should *not* have aliases! |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1091 |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1092 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1093 SETTINGS = ( |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1094 ("main", ( |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1095 (FilePathOption, "database", "db", "Database directory path."), |
|
4587
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4570
diff
changeset
|
1096 (Option, "template_engine", "zopetal", |
|
a2eb4fb3e6d8
New Chameleon templating engine, engine is now configurable.
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4570
diff
changeset
|
1097 "Templating engine to use.\n" |
|
6730
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1098 "Possible values are:\n" |
|
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1099 " 'zopetal' for the old TAL engine ported from Zope,\n" |
|
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1100 " 'chameleon' for Chameleon,\n" |
|
031996eb9bb5
document jinja2 as valid setting for template_engine in config.ini
John Rouillard <rouilj@ieee.org>
parents:
6688
diff
changeset
|
1101 " 'jinja2' for jinja2 templating.\n" |
| 6966 | 1102 " %s jinja2 module." % jinja2_avail), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1103 (FilePathOption, "templates", "html", |
|
2863
ae2907da636d
added STATIC_FILES option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2850
diff
changeset
|
1104 "Path to the HTML templates directory."), |
|
5231
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
1105 (MultiFilePathOption, "static_files", "", |
|
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
1106 "A list of space separated directory paths (or a single\n" |
|
7094
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1107 "directory). These directories hold additional public\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1108 "static files available via Web UI. These directories\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1109 "may contain sitewide images, CSS stylesheets etc. If a\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1110 "'-' is included, the list processing ends and the\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1111 "TEMPLATES directory is not searched after the specified\n" |
|
5231
8743b7226dc7
Fix issue with retreiving raw template files using the @@file mechanism.
John Rouillard <rouilj@ieee.org>
parents:
5214
diff
changeset
|
1112 "directories. If this option is not set, all static\n" |
|
7094
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1113 "files are taken from the TEMPLATES directory. Access to\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1114 "these files is public, it is not checked against\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1115 "registered users. So do not put any sensitive data in\n" |
|
570abc4c6548
Improve documention on access to templates and static_files.
John Rouillard <rouilj@ieee.org>
parents:
6966
diff
changeset
|
1116 "the files in these directories."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1117 (MailAddressOption, "admin_email", "roundup-admin", |
|
4013
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1118 "Email address that roundup will complain to if it runs\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1119 "into trouble.\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1120 "If no domain is specified then the config item\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1121 "mail -> domain is added."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1122 (MailAddressOption, "dispatcher_email", "roundup-admin", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1123 "The 'dispatcher' is a role that can get notified\n" |
|
7658
d30e534b078a
clarify doc on dispatcher_email config setting.
John Rouillard <rouilj@ieee.org>
parents:
7567
diff
changeset
|
1124 "when errors occur while sending email to a user.\n" |
|
4013
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1125 "It is used by the ERROR_MESSAGES_TO config setting.\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1126 "If no domain is specified then the config item\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1127 "mail -> domain is added."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1128 (Option, "email_from_tag", "", |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1129 'Additional text to include in the "name" part\n' |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1130 "of the From: address used in nosy messages.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1131 'If the sending user is "Foo Bar", the From: line\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1132 'is usually: "Foo Bar" <issue_tracker@tracker.example>\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1133 'the EMAIL_FROM_TAG goes inside the "Foo Bar" quotes like so:\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1134 '"Foo Bar EMAIL_FROM_TAG" <issue_tracker@tracker.example>'), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1135 (Option, "new_web_user_roles", "User", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1136 "Roles that a user gets when they register\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1137 "with Web User Interface.\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1138 "This is a comma-separated string of role names\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1139 " (e.g. 'Admin,User')."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1140 (Option, "new_email_user_roles", "User", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1141 "Roles that a user gets when they register\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1142 "with Email Gateway.\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1143 "This is a comma-separated string of role names\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1144 " (e.g. 'Admin,User')."), |
|
5315
5a014410f254
Fix issue2550954: History display breaks
Ralf Schlatterbeck <rsc@runtux.com>
parents:
5305
diff
changeset
|
1145 (Option, "obsolete_history_roles", "Admin", |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1146 "On schema changes, properties or classes in the history may\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1147 "become obsolete. Since normal access permissions do not apply\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1148 "(we don't know if a user should see such a property or class)\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1149 "a list of roles is specified here that are allowed to see\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1150 "these obsolete properties in the history. By default only the\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1151 "admin role may see these history entries, you can make them\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1152 "visible to all users by adding, e.g., the 'User' role here."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1153 (Option, "error_messages_to", "user", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1154 'Send error message emails to the "dispatcher", "user", \n' |
|
6355
ac5a6ffa377b
Description update. Description was a question not a statement.
John Rouillard <rouilj@ieee.org>
parents:
6354
diff
changeset
|
1155 'or "both" (these are the three allowed values).\n' |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1156 'The dispatcher is configured using the DISPATCHER_EMAIL\n' |
|
6211
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1157 ' setting.'), |
|
7964
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
1158 (HtmlVersionOption, "html_version", "html4", |
|
7452
bed28b64c581
Add xhtml deprecation notice.
John Rouillard <rouilj@ieee.org>
parents:
7371
diff
changeset
|
1159 "This setting should be left at the default value of html4.\n" |
|
7964
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
1160 "Support for xhtml has been disabled.\n" |
|
791b61ed11c9
issue2551323 - Remove XHTML support
John Rouillard <rouilj@ieee.org>
parents:
7920
diff
changeset
|
1161 "HTML version to generate. The templates are html4 by default."), |
|
5754
178ca608ddb9
Fix Issue2551030: Roundup fails to start if pytz to access Olson
John Rouillard <rouilj@ieee.org>
parents:
5748
diff
changeset
|
1162 (TimezoneOption, "timezone", TimezoneOption.defaulttz, |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1163 "Default timezone offset,\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1164 "applied when user's timezone is not set.", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1165 ["DEFAULT_TIMEZONE"]), |
|
2649
1df7d4a41da4
Buncha stuff (sorry about the large checkin):
Richard Jones <richard@users.sourceforge.net>
parents:
2646
diff
changeset
|
1166 (BooleanOption, "instant_registration", "no", |
|
1df7d4a41da4
Buncha stuff (sorry about the large checkin):
Richard Jones <richard@users.sourceforge.net>
parents:
2646
diff
changeset
|
1167 "Register new users instantly, or require confirmation via\n" |
|
1df7d4a41da4
Buncha stuff (sorry about the large checkin):
Richard Jones <richard@users.sourceforge.net>
parents:
2646
diff
changeset
|
1168 "email?"), |
|
3469
d3b02352484f
enable registration confirmation by web only [SF#1381675]
Richard Jones <richard@users.sourceforge.net>
parents:
3452
diff
changeset
|
1169 (BooleanOption, "email_registration_confirmation", "yes", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1170 "Offer registration confirmation by email or only\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1171 "through the web?"), |
| 6358 | 1172 (IndexerOption, "indexer", "", |
|
5096
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5045
diff
changeset
|
1173 "Force Roundup to use a particular text indexer.\n" |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5045
diff
changeset
|
1174 "If no indexer is supplied, the first available indexer\n" |
|
e74c3611b138
- issue2550636, issue2550909: Added support for Whoosh indexer.
John Rouillard <rouilj@ieee.org>
parents:
5045
diff
changeset
|
1175 "will be used in the following order:\n" |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
1176 "Possible values: xapian, whoosh, native (internal), " |
|
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
1177 "native-fts.\nNote 'native-fts' will only be used if set."), |
|
6353
9d209d2b34ae
Add indexer_language to change stemmer for xapian FTS indexer
John Rouillard <rouilj@ieee.org>
parents:
6333
diff
changeset
|
1178 (Option, "indexer_language", "english", |
|
9d209d2b34ae
Add indexer_language to change stemmer for xapian FTS indexer
John Rouillard <rouilj@ieee.org>
parents:
6333
diff
changeset
|
1179 "Used to determine what language should be used by the\n" |
|
6604
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
1180 "indexer above. Applies to Xapian and PostgreSQL native-fts\n" |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
1181 "indexer. It sets the language for the stemmer, and PostgreSQL\n" |
|
0d99ae7c8de6
Allow Roundup to use PostgreSQL database native full text search
John Rouillard <rouilj@ieee.org>
parents:
6588
diff
changeset
|
1182 "native-fts stopwords and other dictionaries.\n" |
|
6353
9d209d2b34ae
Add indexer_language to change stemmer for xapian FTS indexer
John Rouillard <rouilj@ieee.org>
parents:
6333
diff
changeset
|
1183 "Possible values: must be a valid language for the indexer,\n" |
|
9d209d2b34ae
Add indexer_language to change stemmer for xapian FTS indexer
John Rouillard <rouilj@ieee.org>
parents:
6333
diff
changeset
|
1184 "see indexer documentation for details."), |
|
3544
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
1185 (WordListOption, "indexer_stopwords", "", |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
1186 "Additional stop-words for the full-text indexer specific to\n" |
|
5cd1c83dea50
Features and fixes.
Richard Jones <richard@users.sourceforge.net>
parents:
3469
diff
changeset
|
1187 "your tracker. See the indexer source for the default list of\n" |
|
6588
91ab3e0ffcd0
Summary: Add test cases for sqlite fts
John Rouillard <rouilj@ieee.org>
parents:
6584
diff
changeset
|
1188 "stop-words (eg. A,AND,ARE,AS,AT,BE,BUT,BY, ...). This is\n" |
|
6915
9ff091537f43
postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
1189 "not used by the postgres native-fts indexer. But is used to\n" |
|
9ff091537f43
postgresql native-fts; more indexer tests
John Rouillard <rouilj@ieee.org>
parents:
6814
diff
changeset
|
1190 "filter search terms with the sqlite native-fts indexer."), |
|
5736
1b5bcc5d745f
Change umask default to python 3 (put python2 compatible) format with
John Rouillard <rouilj@ieee.org>
parents:
5732
diff
changeset
|
1191 (OctalNumberOption, "umask", "0o002", |
|
3609
f2fda3e6fc8b
umask is now configurable (with the same 0002 default)
Richard Jones <richard@users.sourceforge.net>
parents:
3548
diff
changeset
|
1192 "Defines the file creation mode mask."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1193 (IntegerNumberGeqZeroOption, 'csv_field_size', '131072', |
|
4255
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1194 "Maximum size of a csv-field during import. Roundups export\n" |
|
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1195 "format is a csv (comma separated values) variant. The csv\n" |
|
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1196 "reader has a limit on the size of individual fields\n" |
|
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1197 "starting with python 2.5. Set this to a higher value if you\n" |
|
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1198 "get the error 'Error: field larger than field limit' during\n" |
|
88af08f8666f
New config option csv_field_size:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4088
diff
changeset
|
1199 "import."), |
|
7161
be7849588372
issue2551252 - increase PBKFD2 default rounds to 2,000,000.
John Rouillard <rouilj@ieee.org>
parents:
7155
diff
changeset
|
1200 (IntegerNumberGeqZeroOption, 'password_pbkdf2_default_rounds', |
|
8239
6bd11a73f2ed
issue2551253. default hash is PBKDF2-SHA512.
John Rouillard <rouilj@ieee.org>
parents:
8136
diff
changeset
|
1201 '250000', |
|
4486
693c75d56ebe
Add new config-option 'password_pbkdf2_default_rounds'...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4484
diff
changeset
|
1202 "Sets the default number of rounds used when encoding passwords\n" |
|
8239
6bd11a73f2ed
issue2551253. default hash is PBKDF2-SHA512.
John Rouillard <rouilj@ieee.org>
parents:
8136
diff
changeset
|
1203 "using any PBKDF2 scheme. Set this to a higher value on faster\n" |
|
6bd11a73f2ed
issue2551253. default hash is PBKDF2-SHA512.
John Rouillard <rouilj@ieee.org>
parents:
8136
diff
changeset
|
1204 "systems which want more security. Use a minimum of 250000\n" |
|
6bd11a73f2ed
issue2551253. default hash is PBKDF2-SHA512.
John Rouillard <rouilj@ieee.org>
parents:
8136
diff
changeset
|
1205 "for PBKDF2-SHA512 which is the default hash in Roundup 2.5.\n" |
|
4488
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1206 "PBKDF2 (Password-Based Key Derivation Function) is a\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1207 "password hashing mechanism that derives hash from the\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1208 "password and a random salt. For authentication this process\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1209 "is repeated with the same salt as in the stored hash.\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1210 "If both hashes match, the authentication succeeds.\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1211 "PBKDF2 supports a variable 'rounds' parameter which varies\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1212 "the time-cost of calculating the hash - doubling the number\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1213 "of rounds doubles the cpu time required to calculate it. The\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1214 "purpose of this is to periodically adjust the rounds as CPUs\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1215 "become faster. The currently enforced minimum number of\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1216 "rounds is 1000.\n" |
|
d483a40e2f82
more verbose description of password hashing, thanks to Eli Collins
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4486
diff
changeset
|
1217 "See: http://en.wikipedia.org/wiki/PBKDF2 and RFC2898"), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1218 )), |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1219 ("tracker", ( |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1220 (Option, "name", "Roundup issue tracker", |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1221 "A descriptive name for your roundup instance."), |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
1222 (WebUrlOption, "web", NODEFAULT, |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1223 "The web address that the tracker is viewable at.\n" |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1224 "This will be included in information\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1225 "sent to users of the tracker.\n" |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1226 "The URL MUST include the cgi-bin part or anything else\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1227 "that is required to get to the home page of the tracker.\n" |
|
5770
f91da208f26b
Validate that TRACKER_WEB url starts with https:// or http:// and ends
John Rouillard <rouilj@ieee.org>
parents:
5754
diff
changeset
|
1228 "URL MUST start with http/https scheme and end with '/'"), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1229 (MailAddressOption, "email", "issue_tracker", |
|
4013
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1230 "Email address that mail to roundup should go to.\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1231 "If no domain is specified then mail_domain is added."), |
|
5098
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1232 (Option, "replyto_address", "", |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1233 "Controls the reply-to header address used when sending\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1234 "nosy messages.\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1235 "If the value is unset (default) the roundup tracker's\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1236 "email address (above) is used.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1237 'If set to "AUTHOR" then the primary email address of the\n' |
|
5098
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1238 "author of the change will be used as the reply-to\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1239 "address. This allows email exchanges to occur outside of\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1240 "the view of roundup and exposes the address of the person\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1241 "who updated the issue, but it could be useful in some\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1242 "unusual circumstances.\n" |
|
99e289359798
issue2550803: Replying to NOSY mail goes to the tracker through
John Rouillard <rouilj@ieee.org>
parents:
5096
diff
changeset
|
1243 "If set to some other value, the value is used as the reply-to\n" |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1244 "address. It must be a valid RFC2822 address or people will not\n" |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1245 "be able to reply."), |
|
2922
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1246 (NullableOption, "language", "", |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1247 "Default locale name for this tracker.\n" |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1248 "If this option is not set, the language is determined\n" |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1249 "by OS environment variable LANGUAGE, LC_ALL, LC_MESSAGES,\n" |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1250 "or LANG, in that order of preference."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1251 )), |
|
3356
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1252 ("web", ( |
|
4088
34434785f308
Plug a number of security holes:
Richard Jones <richard@users.sourceforge.net>
parents:
4074
diff
changeset
|
1253 (BooleanOption, "allow_html_file", "no", |
|
34434785f308
Plug a number of security holes:
Richard Jones <richard@users.sourceforge.net>
parents:
4074
diff
changeset
|
1254 "Setting this option enables Roundup to serve uploaded HTML\n" |
|
34434785f308
Plug a number of security holes:
Richard Jones <richard@users.sourceforge.net>
parents:
4074
diff
changeset
|
1255 "file content *as HTML*. This is a potential security risk\n" |
|
34434785f308
Plug a number of security holes:
Richard Jones <richard@users.sourceforge.net>
parents:
4074
diff
changeset
|
1256 "and is therefore disabled by default. Set to 'yes' if you\n" |
|
34434785f308
Plug a number of security holes:
Richard Jones <richard@users.sourceforge.net>
parents:
4074
diff
changeset
|
1257 "trust *all* users uploading content to your tracker."), |
|
3452
be505af06586
web_http_auth is boolean value
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3431
diff
changeset
|
1258 (BooleanOption, 'http_auth', "yes", |
|
3356
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1259 "Whether to use HTTP Basic Authentication, if present.\n" |
|
6436
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1260 "Roundup will use either the REMOTE_USER (the value set \n" |
|
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1261 "by http_auth_header) or HTTP_AUTHORIZATION\n" |
|
3356
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1262 "variables supplied by your web server (in that order).\n" |
|
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1263 "Set this option to 'no' if you do not wish to use HTTP Basic\n" |
|
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1264 "Authentication in your web interface."), |
|
6436
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1265 (Option, "http_auth_header", "", |
|
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1266 "The HTTP header that holds the user authentication information.\n" |
|
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1267 "If empty (default) the REMOTE_USER header is used.\n" |
|
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1268 "This is used when the upstream HTTP server authenticates\n" |
|
1f2f7c0b8968
issue2550837 - New option for web auth (also http header passing)
John Rouillard <rouilj@ieee.org>
parents:
6363
diff
changeset
|
1269 "the user and passes the username using this HTTP header."), |
|
6458
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1270 (BooleanOption, "dynamic_compression", "yes", |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1271 "Setting this option makes roundup look at the Accept-Encoding\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1272 "header supplied by the client. It will compress the response\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1273 "on the fly using a common encoding. Disable it if your\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1274 "upstream server does compression of dynamic data."), |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1275 (BooleanOption, "use_precompressed_files", "no", |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1276 "Setting this option enables Roundup to serve precompressed\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1277 "static files. The admin must create the compressed files with\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1278 "proper extension (.gzip, .br, .zstd) in the same directory as\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1279 "the uncompressed file. If a precompressed file doesn't\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1280 "exist, the uncompressed file will be served possibly with\n" |
|
8f1b91756457
issue2551147 - Enable compression of http responses in roundup.
John Rouillard <rouilj@ieee.org>
parents:
6436
diff
changeset
|
1281 "dynamic compression."), |
|
6053
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1282 (BooleanOption, 'http_auth_convert_realm_to_lowercase', "no", |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1283 "If usernames consist of a name and a domain/realm part of\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1284 "the form user@realm and we're using REMOTE_USER for\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1285 "authentication (e.g. via Kerberos), convert the realm part\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1286 "of the incoming REMOTE_USER to lowercase before matching\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1287 "against the roundup username. This allows roundup usernames\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1288 "to be lowercase (including the realm) and still follow the\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1289 "Kerberos convention of using an uppercase realm. In\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1290 "addition this is compatible with Active Directory which\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1291 "stores the username with realm as UserPrincipalName in\n" |
|
380dec305c28
Add config option 'http_auth_convert_realm_to_lowercase'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6004
diff
changeset
|
1292 "lowercase."), |
|
6211
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1293 (BooleanOption, 'cookie_takes_precedence', "no", |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1294 "If the http_auth option is in effect (see above)\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1295 "we're accepting a REMOTE_USER variable resulting from\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1296 "an authentication mechanism implemented in the web-server,\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1297 "e.g., Kerberos login or similar. To override the mechanism\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1298 "provided by the web-server (e.g. for enabling sub-login as\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1299 "another user) we tell roundup that the cookie takes\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1300 "precedence over a REMOTE_USER or HTTP_AUTHORIZATION\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1301 "variable. So if both, a cookie and a REMOTE_USER is\n" |
|
50960479f627
New config-option 'cookie_takes_precedence'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6152
diff
changeset
|
1302 "present, the cookie wins.\n"), |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
1303 (IntegerNumberGeqZeroOption, 'login_attempts_min', "3", |
|
5717
cad18de2b988
issue2550949: Rate limit password guesses/login attempts.
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1304 "Limit login attempts per user per minute to this number.\n" |
|
cad18de2b988
issue2550949: Rate limit password guesses/login attempts.
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1305 "By default the 4th login attempt in a minute will notify\n" |
|
cad18de2b988
issue2550949: Rate limit password guesses/login attempts.
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1306 "the user that they need to wait 20 seconds before trying to\n" |
|
cad18de2b988
issue2550949: Rate limit password guesses/login attempts.
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1307 "log in again. This limits password guessing attacks and\n" |
|
5772
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
1308 "shouldn't need to be changed. Rate limiting on login can\n" |
|
8dbe307bdb57
Finish up login rate limit code. Set config item to 0 disables, make
John Rouillard <rouilj@ieee.org>
parents:
5770
diff
changeset
|
1309 "be disabled by setting the value to 0."), |
|
5974
98a8509ce45c
issue2550919 - Anti-bot signup using 4 second delay
John Rouillard <rouilj@ieee.org>
parents:
5956
diff
changeset
|
1310 (IntegerNumberGeqZeroOption, 'registration_delay', "4", |
|
98a8509ce45c
issue2550919 - Anti-bot signup using 4 second delay
John Rouillard <rouilj@ieee.org>
parents:
5956
diff
changeset
|
1311 "The number of seconds needed to complete the new user\n" |
|
98a8509ce45c
issue2550919 - Anti-bot signup using 4 second delay
John Rouillard <rouilj@ieee.org>
parents:
5956
diff
changeset
|
1312 "registration form. This limits the rate at which bots\n" |
|
98a8509ce45c
issue2550919 - Anti-bot signup using 4 second delay
John Rouillard <rouilj@ieee.org>
parents:
5956
diff
changeset
|
1313 "can attempt to sign up. Limit can be disabled by setting\n" |
|
98a8509ce45c
issue2550919 - Anti-bot signup using 4 second delay
John Rouillard <rouilj@ieee.org>
parents:
5956
diff
changeset
|
1314 "the value to 0."), |
|
5976
71c68961d9f4
- issue2550920 - Optionally detect duplicate username at registration.
John Rouillard <rouilj@ieee.org>
parents:
5974
diff
changeset
|
1315 (BooleanOption, 'registration_prevalidate_username', "no", |
|
71c68961d9f4
- issue2550920 - Optionally detect duplicate username at registration.
John Rouillard <rouilj@ieee.org>
parents:
5974
diff
changeset
|
1316 "When registering a user, check that the username\n" |
|
71c68961d9f4
- issue2550920 - Optionally detect duplicate username at registration.
John Rouillard <rouilj@ieee.org>
parents:
5974
diff
changeset
|
1317 "is available before sending confirmation email.\n" |
|
71c68961d9f4
- issue2550920 - Optionally detect duplicate username at registration.
John Rouillard <rouilj@ieee.org>
parents:
5974
diff
changeset
|
1318 "Usually a username conflict is detected when\n" |
|
71c68961d9f4
- issue2550920 - Optionally detect duplicate username at registration.
John Rouillard <rouilj@ieee.org>
parents:
5974
diff
changeset
|
1319 "confirming the registration. Disabled by default as\n" |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1320 "it can be used for guessing existing usernames.\n"), |
|
5212
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1321 (SameSiteSettingOption, 'samesite_cookie_setting', "Lax", |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1322 """Set the mode of the SameSite cookie option for |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1323 the session cookie. Choices are 'Lax' or |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1324 'Strict'. 'None' can be used to suppress the |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1325 option. Strict mode provides additional security |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1326 against CSRF attacks, but may confuse users who |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1327 are logged into roundup and open a roundup link |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1328 from a source other than roundup (e.g. link in |
|
d4cc71beb102
Added support for SameSite cookie option for CSRF prevention
John Rouillard <rouilj@ieee.org>
parents:
5201
diff
changeset
|
1329 email)."""), |
|
5603
79da1ca2f94b
Make xmlrpc and rest APIs configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
5517
diff
changeset
|
1330 (BooleanOption, 'enable_xmlrpc', "yes", |
|
79da1ca2f94b
Make xmlrpc and rest APIs configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
5517
diff
changeset
|
1331 """Whether to enable the XMLRPC API in the roundup web |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1332 interface. By default the XMLRPC endpoint is the string |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1333 'xmlrpc' after the roundup web url configured in the |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1334 'tracker' section. If this variable is set to 'no', the |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1335 xmlrpc path has no special meaning and will yield an |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1336 error message."""), |
|
6658
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6604
diff
changeset
|
1337 (BooleanOption, 'translate_xmlrpc', 'no', |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6604
diff
changeset
|
1338 """Whether to enable i18n for the xmlrpc endpoint. Enable it if |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1339 you want to enable translation based on browsers lang |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1340 (if enabled), trackers lang (if set) or environment."""), |
|
5603
79da1ca2f94b
Make xmlrpc and rest APIs configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
5517
diff
changeset
|
1341 (BooleanOption, 'enable_rest', "yes", |
|
79da1ca2f94b
Make xmlrpc and rest APIs configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
5517
diff
changeset
|
1342 """Whether to enable the REST API in the roundup web |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1343 interface. By default the REST endpoint is the string |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1344 'rest' plus any additional REST-API parameters after the |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1345 roundup web url configured in the tracker section. If this |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1346 variable is set to 'no', the rest path has no special meaning |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1347 and will yield an error message."""), |
|
6658
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6604
diff
changeset
|
1348 (BooleanOption, 'translate_rest', 'no', |
|
408fd477761f
Add i18n object to roundupdb.Database
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6604
diff
changeset
|
1349 """Whether to enable i18n for the rest endpoint. Enable it if |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1350 you want to enable translation based on browsers lang |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1351 (if enabled), trackers lang (if set) or environment."""), |
|
7726
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1352 (LogLevelOption, 'rest_logging', 'none', |
|
6f66d74d37f3
Add configurable logging for REST
Ralf Schlatterbeck <rsc@runtux.com>
parents:
7719
diff
changeset
|
1353 "Log-Level for REST errors."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1354 (IntegerNumberGeqZeroOption, 'api_calls_per_interval', "0", |
|
5732
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1355 "Limit API calls per api_interval_in_sec seconds to\n" |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1356 "this number.\n" |
|
5732
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1357 "Determines the burst rate and the rate that new api\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1358 "calls will be made available. If set to 360 and\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1359 "api_intervals_in_sec is set to 3600, the 361st call in\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1360 "10 seconds results in a 429 error to the caller. It\n" |
|
7556
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1361 "tells them to wait 10 seconds (3600/360) before making\n" |
|
5732
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1362 "another api request. A value of 0 turns off rate\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1363 "limiting in the API. Tune this as needed. See rest\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1364 "documentation for more info.\n"), |
|
7556
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1365 (IntegerNumberGtZeroOption, 'api_interval_in_sec', "3600", |
|
5732
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1366 "Defines the interval in seconds over which an api client can\n" |
|
0e6ed3d72f92
Rest rate limiting code first commit. It is a bit rough and turned off
John Rouillard <rouilj@ieee.org>
parents:
5726
diff
changeset
|
1367 "make api_calls_per_interval api calls. Tune this as needed.\n"), |
|
7556
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1368 (IntegerNumberGeqZeroOption, 'api_failed_login_limit', "4", |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1369 "Limit login failure to the API per api_failed_login_interval_in_sec\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1370 "seconds.\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1371 "A value of 0 turns off failed login rate\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1372 "limiting in the API. You should not disable this. See rest\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1373 "documentation for more info.\n"), |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1374 (IntegerNumberGtZeroOption, 'api_failed_login_interval_in_sec', "600", |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1375 "Defines the interval in seconds over which api login failures\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1376 "are recorded. It allows api_failed_login_limit login failures\n" |
|
273c8c2b5042
fix(api): - issue2551063 - Rest/Xmlrpc interfaces needs failed login protection.
John Rouillard <rouilj@ieee.org>
parents:
7452
diff
changeset
|
1377 "in this time interval. Tune this as needed.\n"), |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1378 (CsrfSettingOption, 'csrf_enforce_token', "yes", |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1379 """How do we deal with @csrf fields in posted forms. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1380 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1381 the user if the field is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1382 Set this to 'yes' to block the post and notify the user |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1383 if the token is invalid, but accept the form if |
|
5214
4c48180555fb
Fix text formatting, typos and, English grammar of the descriptive text.
John Rouillard <rouilj@ieee.org>
parents:
5212
diff
changeset
|
1384 the field is missing. |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1385 Set this to 'logfailure' to log a notice to the roundup |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1386 log if the field is invalid or missing, but accept |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1387 the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1388 Set this to 'no' to ignore the field and accept the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1389 """), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1390 (IntegerNumberGeqZeroOption, 'csrf_token_lifetime', "20160", |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1391 """csrf_tokens have a limited lifetime. If they are not |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1392 used they are purged from the database after this |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1393 number of minutes. Default (20160) is 2 weeks."""), |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1394 (CsrfSettingOption, 'csrf_enforce_header_X-REQUESTED-WITH', "yes", |
|
5698
c7dd1cae3416
Update rest.txt example to include headers required for CSRF
John Rouillard <rouilj@ieee.org>
parents:
5603
diff
changeset
|
1395 """This is only used for xmlrpc and rest requests. This test is |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1396 done after Origin and Referer headers are checked. It only |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1397 verifies that the X-Requested-With header exists. The value |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1398 is ignored. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1399 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1400 the user if the header is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1401 Set this to 'yes' is the same as required. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1402 Set this to 'logfailure' is the same as 'no'. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1403 Set this to 'no' to ignore the header and accept the post."""), |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1404 (CsrfSettingOption, 'csrf_enforce_header_referer', "yes", |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1405 """Verify that the Referer http header matches the |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1406 tracker.web setting in config.ini. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1407 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1408 the user if the header is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1409 Set this to 'yes' to block the post and notify the user |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1410 if the header is invalid, but accept the form if |
|
8043
69629a4f7262
doc: in description, replace field with header for csrf_* settings
John Rouillard <rouilj@ieee.org>
parents:
8042
diff
changeset
|
1411 the header is missing. |
|
5214
4c48180555fb
Fix text formatting, typos and, English grammar of the descriptive text.
John Rouillard <rouilj@ieee.org>
parents:
5212
diff
changeset
|
1412 Set this to 'logfailure' to log a notice to the roundup |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1413 log if the header is invalid or missing, but accept |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1414 the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1415 Set this to 'no' to ignore the header and accept the post."""), |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1416 (CsrfSettingOption, 'csrf_enforce_header_origin', "yes", |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1417 """Verify that the Origin http header matches the |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1418 tracker.web setting in config.ini. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1419 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1420 the user if the header is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1421 Set this to 'yes' to block the post and notify the user |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1422 if the header is invalid, but accept the form if |
|
8043
69629a4f7262
doc: in description, replace field with header for csrf_* settings
John Rouillard <rouilj@ieee.org>
parents:
8042
diff
changeset
|
1423 the header is missing. |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1424 Set this to 'logfailure' to log a notice to the roundup |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1425 log if the header is invalid or missing, but accept |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1426 the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1427 Set this to 'no' to ignore the header and accept the post."""), |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1428 (OriginHeadersListOption, 'allowed_api_origins', "", |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1429 """A comma separated list of additonal valid Origin header |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1430 values used when enforcing the header origin. They are used |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1431 only for the api URL's (/rest and /xmlrpc). They are not |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1432 used for the usual html URL's. These strings must match the |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1433 value of the Origin header exactly. So 'https://bar.edu' and |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1434 'https://Bar.edu' are two different Origin values. Note that |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1435 the origin value is scheme://host. There is no path |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1436 component. So 'https://bar.edu/' would never be valid. |
|
7155
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
1437 The value '*' can be used to match any origin. It must be |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
1438 first in the list if used. Note that this value allows |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
1439 any web page on the internet to make anonymous requests |
|
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
1440 against your Roundup tracker. |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1441 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1442 You need to set these if you have a web application on a |
|
7155
89a59e46b3af
improve REST interface security
John Rouillard <rouilj@ieee.org>
parents:
7141
diff
changeset
|
1443 different origin accessing your Roundup instance. |
|
6681
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1444 |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1445 (The origin from the tracker.web setting in config.ini is |
|
ab2ed11c021e
issue2551205: Add support for specifying valid origins for api: xmlrpc/rest
John Rouillard <rouilj@ieee.org>
parents:
6658
diff
changeset
|
1446 always valid and does not need to be specified.)"""), |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1447 (CsrfSettingOption, 'csrf_enforce_header_x-forwarded-host', "yes", |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1448 """Verify that the X-Forwarded-Host http header matches |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1449 the host part of the tracker.web setting in config.ini. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1450 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1451 the user if the header is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1452 Set this to 'yes' to block the post and notify the user |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1453 if the header is invalid, but accept the form if |
|
8043
69629a4f7262
doc: in description, replace field with header for csrf_* settings
John Rouillard <rouilj@ieee.org>
parents:
8042
diff
changeset
|
1454 the header is missing. |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1455 Set this to 'logfailure' to log a notice to the roundup |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1456 log if the header is invalid or missing, but accept |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1457 the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1458 Set this to 'no' to ignore the header and accept the post."""), |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1459 (CsrfSettingOption, 'csrf_enforce_header_host', "yes", |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1460 """"If there is no X-Forward-Host header, verify that |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1461 the Host http header matches the host part of the |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1462 tracker.web setting in config.ini. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1463 Set this to 'required' to block the post and notify |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1464 the user if the header is missing or invalid. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1465 Set this to 'yes' to block the post and notify the user |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1466 if the header is invalid, but accept the form if |
|
8043
69629a4f7262
doc: in description, replace field with header for csrf_* settings
John Rouillard <rouilj@ieee.org>
parents:
8042
diff
changeset
|
1467 the header is missing. |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1468 Set this to 'logfailure' to log a notice to the roundup |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1469 log if the header is invalid or missing, but accept |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1470 the post. |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1471 Set this to 'no' to ignore the header and accept the post."""), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1472 (IntegerNumberGeqZeroOption, 'csrf_header_min_count', "1", |
|
5201
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1473 """Minimum number of header checks that must pass |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1474 to accept the request. Set to 0 to accept post |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1475 even if no header checks pass. Usually the Host header check |
|
a9ace22e0a2f
issue 2550690 - Adding anti-csrf measures to roundup following
John Rouillard <rouilj@ieee.org>
parents:
5189
diff
changeset
|
1476 always passes, so setting it less than 1 is not recommended."""), |
|
3425
2b27c92d64dc
add web/use_browser_language option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3417
diff
changeset
|
1477 (BooleanOption, 'use_browser_language', "yes", |
|
2b27c92d64dc
add web/use_browser_language option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3417
diff
changeset
|
1478 "Whether to use HTTP Accept-Language, if present.\n" |
|
2b27c92d64dc
add web/use_browser_language option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3417
diff
changeset
|
1479 "Browsers send a language-region preference list.\n" |
|
3548
61d48244e7a8
login may now be for a single session
Richard Jones <richard@users.sourceforge.net>
parents:
3544
diff
changeset
|
1480 "It's usually set in the client's browser or in their\n" |
|
3425
2b27c92d64dc
add web/use_browser_language option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3417
diff
changeset
|
1481 "Operating System.\n" |
|
2b27c92d64dc
add web/use_browser_language option
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3417
diff
changeset
|
1482 "Set this option to 'no' if you want to ignore it."), |
|
3548
61d48244e7a8
login may now be for a single session
Richard Jones <richard@users.sourceforge.net>
parents:
3544
diff
changeset
|
1483 (BooleanOption, "debug", "no", |
|
61d48244e7a8
login may now be for a single session
Richard Jones <richard@users.sourceforge.net>
parents:
3544
diff
changeset
|
1484 "Setting this option makes Roundup display error tracebacks\n" |
|
61d48244e7a8
login may now be for a single session
Richard Jones <richard@users.sourceforge.net>
parents:
3544
diff
changeset
|
1485 "in the user's browser rather than emailing them to the\n" |
|
61d48244e7a8
login may now be for a single session
Richard Jones <richard@users.sourceforge.net>
parents:
3544
diff
changeset
|
1486 "tracker admin."), |
|
6684
9ca5cbffa0c4
Switch off using blank passwords for login
John Rouillard <rouilj@ieee.org>
parents:
6682
diff
changeset
|
1487 (BooleanOption, "login_empty_passwords", "no", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1488 "Setting this option to yes/true allows users with\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1489 "an empty/blank password to login to the\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1490 "web/http interfaces."), |
|
4484
52e13bf0bb40
Add new config-option 'migrate_passwords' in section 'web'...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4474
diff
changeset
|
1491 (BooleanOption, "migrate_passwords", "yes", |
|
52e13bf0bb40
Add new config-option 'migrate_passwords' in section 'web'...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4474
diff
changeset
|
1492 "Setting this option makes Roundup migrate passwords with\n" |
|
52e13bf0bb40
Add new config-option 'migrate_passwords' in section 'web'...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4474
diff
changeset
|
1493 "an insecure password-scheme to a more secure scheme\n" |
|
52e13bf0bb40
Add new config-option 'migrate_passwords' in section 'web'...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4474
diff
changeset
|
1494 "when the user logs in via the web-interface."), |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1495 (SecretMandatoryOption, "secret_key", create_token(), |
|
5726
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1496 "A per tracker secret used in etag calculations for\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1497 "an object. It must not be empty.\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1498 "It prevents reverse engineering hidden data in an object\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1499 "by calculating the etag for a sample object. Then modifying\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1500 "hidden properties until the sample object's etag matches\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1501 "the one returned by roundup.\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1502 "Changing this changes the etag and invalidates updates by\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1503 "clients. It must be persistent across application restarts.\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1504 "(Note the default value changes every time\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1505 " roundup-admin updateconfig\n" |
|
e199d0ae4a25
issue2551033: prevent reverse engineering hidden data by using etags
John Rouillard <rouilj@ieee.org>
parents:
5717
diff
changeset
|
1506 "is run, so it must be explicitly set to a non-empty string.\n"), |
|
7809
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1507 (ListSecretOption, "jwt_secret", "disabled", |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1508 "This is used to sign/validate json web tokens\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1509 "(JWT). Even if you don't use JWTs it must not be\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1510 "empty. You can use multiple secrets separated by a\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1511 "comma ','. This allows for secret rotation. The newest\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1512 "secret should be placed first and used for signing. The\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1513 "rest of the secrets are used for validating an old JWT.\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1514 "If the first secret is less than 256 bits (32\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1515 "characters) in length JWTs are disabled. If other secrets\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1516 "are less than 32 chars, the application will exit. Removing\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1517 "a secret from this list invalidates all JWTs signed with\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1518 "the secret. JWT support is experimental and disabled by\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1519 "default. The secrets must be persistent across\n" |
|
be6cb2e0d471
feat: add support for rotating jwt keys
John Rouillard <rouilj@ieee.org>
parents:
7726
diff
changeset
|
1520 "application restarts.\n"), |
|
8300
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1521 (BooleanOption, "use_browser_date_input", "no", |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1522 "HTML input elements for Date properties: This determines\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1523 "if we use the input type 'datetime-local' (or 'date') for\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1524 "date input fields. If the option is turned off (the default),\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1525 "the type is set to 'text'. Since the widgets generated by\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1526 "browsers determine the date format from the language\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1527 "setting (it is currently not possible to force the\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1528 "international date format server-side) and some browsers\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1529 "ignore the date format set by the operating system, the\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1530 "default is 'no'."), |
|
8314
7ff47307b4b1
issue2551398 - Browser number input
John Rouillard <rouilj@ieee.org>
parents:
8300
diff
changeset
|
1531 (BooleanOption, "use_browser_number_input", "no", |
|
8300
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1532 "HTML input elements for Number properties: This determines\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1533 "if we use the input type 'number' for Number (and Integer)\n" |
|
b99e76e76496
Make native date and number elements configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8239
diff
changeset
|
1534 "properties. If set to 'no' we use input type 'text'."), |
|
3356
2913b42c0810
enabled disabling of REMOTE_USER for when it's not a valid username
Richard Jones <richard@users.sourceforge.net>
parents:
3155
diff
changeset
|
1535 )), |
|
2634
f47ca4541770
Both RDBMS backends now use the same config.ini section, [rdbms].
Richard Jones <richard@users.sourceforge.net>
parents:
2630
diff
changeset
|
1536 ("rdbms", ( |
|
5748
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
1537 (DatabaseBackend, 'backend', NODEFAULT, |
|
943e61bc26d5
Fix issue2551029 (Jinja2 template install error) by deleting
John Rouillard <rouilj@ieee.org>
parents:
5736
diff
changeset
|
1538 "Database backend."), |
|
8136
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1539 (BooleanOption, "debug_filter", "no", |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1540 "Filter debugging: Permissions can define additional filter\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1541 "functions that are used when checking permissions on results\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1542 "returned by the database. This is done to improve\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1543 "performance since the filtering is done in the database\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1544 "backend, not in python (at least for the SQL backends). The\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1545 "user is responsible for making the filter return the same\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1546 "set of results as the check function for a permission. So it\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1547 "makes sense to aid in debugging (and performance\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1548 "measurements) to allow turning off the usage of filter\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1549 "functions using only the check functions."), |
|
2634
f47ca4541770
Both RDBMS backends now use the same config.ini section, [rdbms].
Richard Jones <richard@users.sourceforge.net>
parents:
2630
diff
changeset
|
1550 (Option, 'name', 'roundup', |
|
7719
3071db43bfb6
feat: issue2550852 - support using a specified PostgreSQL db schema
John Rouillard <rouilj@ieee.org>
parents:
7696
diff
changeset
|
1551 "Name of the database to use. For Postgresql, this can\n" |
|
3071db43bfb6
feat: issue2550852 - support using a specified PostgreSQL db schema
John Rouillard <rouilj@ieee.org>
parents:
7696
diff
changeset
|
1552 "be database.schema to use a specific schema within\n" |
|
3071db43bfb6
feat: issue2550852 - support using a specified PostgreSQL db schema
John Rouillard <rouilj@ieee.org>
parents:
7696
diff
changeset
|
1553 "a Postgres database.", |
|
2636
943f9d4592b8
Backwards-compatibility aliases for mysql config.
Richard Jones <richard@users.sourceforge.net>
parents:
2634
diff
changeset
|
1554 ['MYSQL_DBNAME']), |
|
2637
11811b313459
The demo.py script works again using the new configuration system.
Richard Jones <richard@users.sourceforge.net>
parents:
2636
diff
changeset
|
1555 (NullableOption, 'host', 'localhost', |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1556 "Database server host.", |
|
2636
943f9d4592b8
Backwards-compatibility aliases for mysql config.
Richard Jones <richard@users.sourceforge.net>
parents:
2634
diff
changeset
|
1557 ['MYSQL_DBHOST']), |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1558 (NullableOption, 'port', '', |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1559 "TCP port number of the database server.\n" |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1560 "Postgresql usually resides on port 5432 (if any),\n" |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1561 "for MySQL default port number is 3306.\n" |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1562 "Leave this option empty to use backend default"), |
|
2637
11811b313459
The demo.py script works again using the new configuration system.
Richard Jones <richard@users.sourceforge.net>
parents:
2636
diff
changeset
|
1563 (NullableOption, 'user', 'roundup', |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1564 "Database user name that Roundup should use.", |
|
2636
943f9d4592b8
Backwards-compatibility aliases for mysql config.
Richard Jones <richard@users.sourceforge.net>
parents:
2634
diff
changeset
|
1565 ['MYSQL_DBUSER']), |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1566 (SecretNullableOption, 'password', 'roundup', |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1567 "Database user password.", |
|
2636
943f9d4592b8
Backwards-compatibility aliases for mysql config.
Richard Jones <richard@users.sourceforge.net>
parents:
2634
diff
changeset
|
1568 ['MYSQL_DBPASSWORD']), |
|
7696
4af0d235b570
feat(db): support using postgresql service connection file
John Rouillard <rouilj@ieee.org>
parents:
7658
diff
changeset
|
1569 (NullableOption, 'service', '', |
|
4af0d235b570
feat(db): support using postgresql service connection file
John Rouillard <rouilj@ieee.org>
parents:
7658
diff
changeset
|
1570 "Name of the PostgreSQL connection service for this Roundup\n" |
|
4af0d235b570
feat(db): support using postgresql service connection file
John Rouillard <rouilj@ieee.org>
parents:
7658
diff
changeset
|
1571 "instance. Only used in Postgresql connections. You need to set\n" |
|
4af0d235b570
feat(db): support using postgresql service connection file
John Rouillard <rouilj@ieee.org>
parents:
7658
diff
changeset
|
1572 "up a pg_service.conf file usable by psql use this option."), |
|
3099
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1573 (NullableOption, 'read_default_file', '~/.my.cnf', |
|
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1574 "Name of the MySQL defaults file.\n" |
|
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1575 "Only used in MySQL connections."), |
|
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1576 (NullableOption, 'read_default_group', 'roundup', |
|
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1577 "Name of the group to use in the MySQL defaults file (.my.cnf).\n" |
|
519b92df37dc
handle ~/.my.cnf files for MySQL defaults [SF#1096031]
Richard Jones <richard@users.sourceforge.net>
parents:
2922
diff
changeset
|
1578 "Only used in MySQL connections."), |
|
6333
bd84f43e1d13
Fixes to mysql 2.0 conversion doc issue2551115 Werner Hunger
John Rouillard <rouilj@ieee.org>
parents:
6332
diff
changeset
|
1579 (Option, 'mysql_charset', 'utf8mb4', |
|
7860
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1580 "Charset to use for mysql connection and databases.\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1581 "If set to 'default', no charset option is used when\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1582 "creating the db connection and utf8mb4 is used for the\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1583 "database charset.\n" |
|
6152
546763f4ce44
Make the charset configurable for mysql
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6126
diff
changeset
|
1584 "Otherwise any permissible mysql charset is allowed here.\n" |
|
546763f4ce44
Make the charset configurable for mysql
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6126
diff
changeset
|
1585 "Only used in MySQL connections."), |
|
7860
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1586 (Option, 'mysql_collation', 'utf8mb4_unicode_ci', |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1587 "Comparison/order to use for mysql database/table collations.\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1588 "When upgrading, you can use 'utf8' to match the\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1589 "depricated 'utf8mb3'. This must be compatible with the\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1590 "mysql_charset setting above. Only used by MySQL."), |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1591 (Option, 'mysql_binary_collation', 'utf8mb4_0900_bin', |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1592 "Comparison/order to use for mysql database/table collations\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1593 "when matching case. When upgrading, you can use 'utf8_bin'\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1594 "to match the depricated 'utf8mb3_bin' collation. This must\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1595 "be compatible with the mysql_collation above. Only used\n" |
|
8b31893f5930
issue2551115/issue2551282 - utf8mb4 support in roundup
John Rouillard <rouilj@ieee.org>
parents:
7845
diff
changeset
|
1596 "by MySQL."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1597 (IntegerNumberGeqZeroOption, 'sqlite_timeout', '30', |
|
4415
3e35233ea93c
new rdbms config item sqlite_timeout...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4411
diff
changeset
|
1598 "Number of seconds to wait when the SQLite database is locked\n" |
|
3e35233ea93c
new rdbms config item sqlite_timeout...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4411
diff
changeset
|
1599 "Default: use a 30 second timeout (extraordinarily generous)\n" |
|
3e35233ea93c
new rdbms config item sqlite_timeout...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4411
diff
changeset
|
1600 "Only used in SQLite connections."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1601 (IntegerNumberGeqZeroOption, 'cache_size', '100', |
|
7920
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1602 "Size of the node cache (in elements). Used to keep the\n" |
|
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1603 "most recently used data in memory."), |
|
4474
9b4cf6c96ee2
Add flags to allow to restrict DB modifications.
Stefan Seefeld <stefan@seefeld.name>
parents:
4471
diff
changeset
|
1604 (BooleanOption, "allow_create", "yes", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1605 "Setting this option to 'no' protects the database against\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1606 "table creations."), |
|
4474
9b4cf6c96ee2
Add flags to allow to restrict DB modifications.
Stefan Seefeld <stefan@seefeld.name>
parents:
4471
diff
changeset
|
1607 (BooleanOption, "allow_alter", "yes", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1608 "Setting this option to 'no' protects the database against\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1609 "table alterations."), |
|
4474
9b4cf6c96ee2
Add flags to allow to restrict DB modifications.
Stefan Seefeld <stefan@seefeld.name>
parents:
4471
diff
changeset
|
1610 (BooleanOption, "allow_drop", "yes", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1611 "Setting this option to 'no' protects the database against\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1612 "table drops."), |
|
4471
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1613 (NullableOption, 'template', '', |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1614 "Name of the PostgreSQL template for database creation.\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1615 "For database creation the template used has to match\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1616 "the character encoding used (UTF8), there are different\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1617 "PostgreSQL installations using different templates with\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1618 "different encodings. If you get an error:\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1619 " new encoding (UTF8) is incompatible with the encoding of\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1620 " the template database (SQL_ASCII)\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1621 " HINT: Use the same encoding as in the template database,\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1622 " or use template0 as template.\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1623 "then set this option to the template name given in the\n" |
|
4f353d71d716
Configuration issue:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4424
diff
changeset
|
1624 "error message."), |
|
4887
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
1625 (IsolationOption, 'isolation_level', 'read committed', |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
1626 "Database isolation level, currently supported for\n" |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
1627 "PostgreSQL and mysql. See, e.g.,\n" |
|
05c857e5dbed
New rdbms configuration option 'isolation_level'
Ralf Schlatterbeck <rsc@runtux.com>
parents:
4786
diff
changeset
|
1628 "http://www.postgresql.org/docs/9.1/static/transaction-iso.html"), |
|
6332
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6300
diff
changeset
|
1629 (BooleanOption, "serverside_cursor", "yes", |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6300
diff
changeset
|
1630 "Set the database cursor for filter queries to serverside\n" |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6300
diff
changeset
|
1631 "cursor, this avoids caching large amounts of data in the\n" |
|
6a6b4651be1f
Use server-side cursor for postgres in some cases
Ralf Schlatterbeck <rsc@runtux.com>
parents:
6300
diff
changeset
|
1632 "client. This option only applies for the postgresql backend."), |
|
8136
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1633 ), "Most settings in this section (except for backend and debug_filter)\n" |
|
5a2b9435a04d
Make permission filter functions configurable
Ralf Schlatterbeck <rsc@runtux.com>
parents:
8043
diff
changeset
|
1634 "are used by RDBMS backends only.", |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1635 ), |
|
6814
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1636 ("sessiondb", ( |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1637 (SessiondbBackendOption, "backend", "", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1638 "Set backend for storing one time key (otk) and session data.\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1639 "Values have to be compatible with main backend.\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1640 "main\\/ session>| anydbm | sqlite | redis | mysql | postgresql |\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1641 " anydbm | D | | X | | |\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1642 " sqlite | X | D | X | | |\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1643 " mysql | | | | D | |\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1644 " postgresql | | | | | D |\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1645 " -------------------------------------------------------------+\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1646 " D - default if unset, X - compatible choice"), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1647 (RedisUrlOption, "redis_url", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1648 "redis://localhost:6379/0?health_check_interval=2", |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1649 "URL used to connect to redis. Default uses unauthenticated\n" |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1650 "redis database 0 running on localhost with default port.\n"), |
|
3f60a71b0812
Summary: Support selecion session/otk data store. Add redis as data store.
John Rouillard <rouilj@ieee.org>
parents:
6730
diff
changeset
|
1651 ), "Choose configuration for session and one time key storage."), |
|
2619
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1652 ("logging", ( |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1653 (FilePathOption, "config", "", |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1654 "Path to configuration file for standard Python logging module.\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1655 "If this option is set, logging configuration is loaded\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1656 "from specified file; options 'filename' and 'level'\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1657 "in this section are ignored."), |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1658 (FilePathOption, "filename", "", |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1659 "Log file name for minimal logging facility built into Roundup.\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1660 "If no file name specified, log messages are written on stderr.\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1661 "If above 'config' option is set, this option has no effect."), |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1662 (Option, "level", "ERROR", |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1663 "Minimal severity level of messages written to log file.\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1664 "If above 'config' option is set, this option has no effect.\n" |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1665 "Allowed values: DEBUG, INFO, WARNING, ERROR"), |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
1666 (LoggingFormatOption, "format", |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
1667 "%(asctime)s %(trace_id)s %(levelname)s %(message)s", |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
1668 "Format of the logging messages with all '%' signs\n" |
|
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
1669 "doubled so they are not interpreted by the config file."), |
|
5939
94c415c7cd36
Make gunicorn --access-logfile work with custom logging config
John Rouillard <rouilj@ieee.org>
parents:
5878
diff
changeset
|
1670 (BooleanOption, "disable_loggers", "no", |
|
94c415c7cd36
Make gunicorn --access-logfile work with custom logging config
John Rouillard <rouilj@ieee.org>
parents:
5878
diff
changeset
|
1671 "If set to yes, only the loggers configured in this section will\n" |
| 5956 | 1672 "be used. Yes will disable gunicorn's --access-logfile.\n"), |
|
2619
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
1673 )), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1674 ("mail", ( |
|
4013
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1675 (Option, "domain", NODEFAULT, |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1676 "The email domain that admin_email, issue_tracker and\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1677 "dispatcher_email belong to.\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1678 "This domain is added to those config items if they don't\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1679 "explicitly include a domain.\n" |
|
a5b68d46bce8
Try to clarify mail_domain config setting
Richard Jones <richard@users.sourceforge.net>
parents:
3945
diff
changeset
|
1680 "Do not include the '@' symbol."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1681 (Option, "host", NODEFAULT, |
|
2844
5dddfc64816d
mailgw backward-compatibility: "MAILHOST" alias for "MAIL_HOST"
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2839
diff
changeset
|
1682 "SMTP mail host that roundup will use to send mail", |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1683 ["MAILHOST"]), |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1684 (Option, "username", "", "SMTP login name.\n" |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
1685 "Set this if your mail host requires authenticated access.\n" |
|
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
1686 "If username is not empty, password (below) MUST be set!"), |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1687 (SecretMandatoryOption, "password", NODEFAULT, "SMTP login password.\n" |
|
2623
4e1030d49cea
fix: Option defaults were applied as strings...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2622
diff
changeset
|
1688 "Set this if your mail host requires authenticated access."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1689 (IntegerNumberGeqZeroOption, "port", smtplib.SMTP_PORT, |
|
3878
6d14a3b4e295
allow admin to specify port and local hostname for SMTP connections
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3877
diff
changeset
|
1690 "Default port to send SMTP on.\n" |
|
6d14a3b4e295
allow admin to specify port and local hostname for SMTP connections
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3877
diff
changeset
|
1691 "Set this if your mail server runs on a different port."), |
|
6d14a3b4e295
allow admin to specify port and local hostname for SMTP connections
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3877
diff
changeset
|
1692 (NullableOption, "local_hostname", '', |
|
7920
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1693 "The (fully qualified) host/ domain name (FQDN) to use during\n" |
|
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1694 "SMTP sessions. If left blank, the underlying SMTP library will\n" |
|
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1695 "attempt to detect your FQDN. Set this if your mail server\n" |
|
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1696 "requires something specific.\n"), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1697 (BooleanOption, "tls", "no", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1698 "If your SMTP mail host provides or requires TLS\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1699 "(Transport Layer Security) then set this option to 'yes'."), |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
1700 (NullableFilePathOption, "tls_keyfile", "", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1701 "If TLS is used, you may set this option to the name\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1702 "of a PEM formatted file that contains your private key."), |
|
2624
f40d5f0f1086
added NullableOption, NullableFilePathOption;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2623
diff
changeset
|
1703 (NullableFilePathOption, "tls_certfile", "", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1704 "If TLS is used, you may set this option to the name\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1705 "of a PEM formatted certificate chain file."), |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1706 (Option, "charset", "utf-8", |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1707 "Character set to encode email headers with.\n" |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1708 "We use utf-8 by default, as it's the most flexible.\n" |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1709 "Some mail readers (eg. Eudora) can't cope with that,\n" |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1710 "so you might need to specify a more limited character set\n" |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1711 "(eg. iso-8859-1).", |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1712 ["EMAIL_CHARSET"]), |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1713 (FilePathOption, "debug", "", |
|
5214
4c48180555fb
Fix text formatting, typos and, English grammar of the descriptive text.
John Rouillard <rouilj@ieee.org>
parents:
5212
diff
changeset
|
1714 "Setting this option makes Roundup write all outgoing email\n" |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1715 "messages to this file *instead* of sending them.\n" |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1716 "This option has the same effect as the environment variable\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1717 "SENDMAILDEBUG.\nEnvironment variable takes precedence."), |
|
3877
83748b2de465
Make addition of line about new submission/comment at top of each message...
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3854
diff
changeset
|
1718 (BooleanOption, "add_authorinfo", "yes", |
|
83748b2de465
Make addition of line about new submission/comment at top of each message...
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3854
diff
changeset
|
1719 "Add a line with author information at top of all messages\n" |
|
83748b2de465
Make addition of line about new submission/comment at top of each message...
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3854
diff
changeset
|
1720 "sent by roundup"), |
|
83748b2de465
Make addition of line about new submission/comment at top of each message...
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3854
diff
changeset
|
1721 (BooleanOption, "add_authoremail", "yes", |
|
7371
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1722 "Add the mail address of the author to the author information\n" |
|
a210f4437b49
Incomplete work to generate config doc from config.ini
John Rouillard <rouilj@ieee.org>
parents:
7251
diff
changeset
|
1723 "at the top of all messages.\n" |
|
3879
454ee9411e85
Fix truncated comment for add_authoremail option.
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3878
diff
changeset
|
1724 "If this is false but add_authorinfo is true, only the name\n" |
|
454ee9411e85
Fix truncated comment for add_authoremail option.
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3878
diff
changeset
|
1725 "of the actor is added which protects the mail address of the\n" |
|
454ee9411e85
Fix truncated comment for add_authoremail option.
Erik Forsberg <forsberg@users.sourceforge.net>
parents:
3878
diff
changeset
|
1726 "actor from being exposed at mail archives, etc."), |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1727 ), "Outgoing email options.\n" |
|
7920
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1728 "Used for nosy messages, password reset and registration approval\n" |
|
6aa0525187cd
doc: use generated config.ini in reference.txt
John Rouillard <rouilj@ieee.org>
parents:
7915
diff
changeset
|
1729 "requests."), |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1730 ("mailgw", ( |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
1731 (EmailBodyOption, "keep_quoted_text", "yes", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1732 "Keep email citations when accepting messages.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1733 'Setting this to "no" strips out "quoted" text\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1734 'from the message. Setting this to "new" keeps quoted\n' |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
1735 "text only if a new issue is being created.\n" |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1736 "Signatures are also stripped.", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1737 ["EMAIL_KEEP_QUOTED_TEXT"]), |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
1738 (EmailBodyOption, "leave_body_unchanged", "no", |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1739 'Setting this to "yes" preserves the email body\n' |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
1740 "as is - that is, keep the citations _and_ signatures.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1741 'Setting this to "new" keeps the body only if we are\n' |
|
5117
14abd0a67207
Fix issue934009: Have New Issues Submitted By Email *Not* Change Body!
John Rouillard <rouilj@ieee.org>
parents:
5102
diff
changeset
|
1742 "creating a new issue.", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1743 ["EMAIL_LEAVE_BODY_UNCHANGED"]), |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1744 (Option, "default_class", "issue", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1745 "Default class to use in the mailgw\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1746 "if one isn't supplied in email subjects.\n" |
|
2627
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1747 "To disable, leave the value blank.", |
|
ce6a965a86f4
Move around some option groupings as I see them.
Richard Jones <richard@users.sourceforge.net>
parents:
2625
diff
changeset
|
1748 ["MAIL_DEFAULT_CLASS"]), |
|
2922
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1749 (NullableOption, "language", "", |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1750 "Default locale name for the tracker mail gateway.\n" |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1751 "If this option is not set, mail gateway will use\n" |
|
9d2c5d7c6f85
added CoreConfig options TRACKER_LANGUAGE and MAILGW_LANGUAGE
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2906
diff
changeset
|
1752 "the language of the tracker instance."), |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1753 (Option, "subject_prefix_parsing", "strict", |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1754 "Controls the parsing of the [prefix] on subject\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1755 'lines in incoming emails. "strict" will return an\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1756 "error to the sender if the [prefix] is not recognised.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1757 '"loose" will attempt to parse the [prefix] but just\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1758 "pass it through as part of the issue title if not\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1759 'recognised. "none" will always pass any [prefix]\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1760 "through as part of the issue title."), |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1761 (Option, "subject_suffix_parsing", "strict", |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1762 "Controls the parsing of the [suffix] on subject\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1763 'lines in incoming emails. "strict" will return an\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1764 "error to the sender if the [suffix] is not recognised.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1765 '"loose" will attempt to parse the [suffix] but just\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1766 "pass it through as part of the issue title if not\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1767 'recognised. "none" will always pass any [suffix]\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1768 "through as part of the issue title."), |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1769 (Option, "subject_suffix_delimiters", "[]", |
|
3725
65badf6ab7ad
fix config documentation
Richard Jones <richard@users.sourceforge.net>
parents:
3620
diff
changeset
|
1770 "Defines the brackets used for delimiting the prefix and \n" |
|
65badf6ab7ad
fix config documentation
Richard Jones <richard@users.sourceforge.net>
parents:
3620
diff
changeset
|
1771 'suffix in a subject line. The presence of "suffix" in\n' |
|
65badf6ab7ad
fix config documentation
Richard Jones <richard@users.sourceforge.net>
parents:
3620
diff
changeset
|
1772 "the config option name is a historical artifact and may\n" |
|
65badf6ab7ad
fix config documentation
Richard Jones <richard@users.sourceforge.net>
parents:
3620
diff
changeset
|
1773 "be ignored."), |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1774 (Option, "subject_content_match", "always", |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1775 "Controls matching of the incoming email subject line\n" |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1776 "against issue titles in the case where there is no\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1777 'designator [prefix]. "never" turns off matching.\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1778 '"creation + interval" or "activity + interval"\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1779 "will match an issue for the interval after the issue's\n" |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1780 "creation or last activity. The interval is a standard\n" |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1781 "Roundup interval."), |
|
4405
863ec554525c
new mailgw config option subject_updates_title...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4342
diff
changeset
|
1782 (BooleanOption, "subject_updates_title", "yes", |
|
863ec554525c
new mailgw config option subject_updates_title...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4342
diff
changeset
|
1783 "Update issue title if incoming subject of email is different.\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1784 'Setting this to "no" will ignore the title part of' |
|
4405
863ec554525c
new mailgw config option subject_updates_title...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4342
diff
changeset
|
1785 " the subject\nof incoming email messages.\n"), |
| 5809 | 1786 (RegExpOption, "refwd_re", r"(\s*\W?\s*(fw|fwd|re|aw|sv|ang)\W)+", |
|
3831
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1787 "Regular expression matching a single reply or forward\n" |
|
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1788 "prefix prepended by the mailer. This is explicitly\n" |
|
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1789 "stripped from the subject during parsing."), |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1790 (RegExpOption, "origmsg_re", |
| 5809 | 1791 r"^[>|\s]*-----\s?Original Message\s?-----$", |
|
3831
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1792 "Regular expression matching start of an original message\n" |
|
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1793 "if quoted the in body."), |
| 5809 | 1794 (RegExpOption, "sign_re", r"^[>|\s]*-- ?$", |
|
3831
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1795 "Regular expression matching the start of a signature\n" |
|
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1796 "in the message body."), |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1797 (RegExpOption, "eol_re", r"[\r\n]+", |
|
3831
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1798 "Regular expression matching end of line."), |
|
3835
b66615f3007b
added RegExpOption
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3831
diff
changeset
|
1799 (RegExpOption, "blankline_re", r"[\r\n]+\s*[\r\n]+", |
|
3831
14ec78618bd5
Allow customisation of regular expressions used in email parsing...
Richard Jones <richard@users.sourceforge.net>
parents:
3820
diff
changeset
|
1800 "Regular expression matching a blank line."), |
|
4424
f1affb6b7a08
Mail gateway fixes and improvements.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4415
diff
changeset
|
1801 (BooleanOption, "unpack_rfc822", "no", |
|
f1affb6b7a08
Mail gateway fixes and improvements.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4415
diff
changeset
|
1802 "Unpack attached messages (encoded as message/rfc822 in MIME)\n" |
|
f1affb6b7a08
Mail gateway fixes and improvements.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4415
diff
changeset
|
1803 "as multiple parts attached as files to the issue, if not\n" |
|
f1affb6b7a08
Mail gateway fixes and improvements.
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4415
diff
changeset
|
1804 "set we handle message/rfc822 attachments as a single file."), |
|
3945
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1805 (BooleanOption, "ignore_alternatives", "no", |
|
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1806 "When parsing incoming mails, roundup uses the first\n" |
|
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1807 "text/plain part it finds. If this part is inside a\n" |
|
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1808 "multipart/alternative, and this option is set, all other\n" |
|
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1809 "parts of the multipart/alternative are ignored. The default\n" |
|
1dd64778bc45
Mail improvements:
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
3922
diff
changeset
|
1810 "is to keep all parts and attach them to the issue."), |
|
5305
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1811 (HtmlToTextOption, "convert_htmltotext", "none", |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1812 "If an email has only text/html parts, use this module\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1813 "to convert the html to text. Choose from beautifulsoup 4,\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1814 "dehtml - (internal code), or none to disable conversion.\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1815 "If 'none' is selected, email without a text/plain part\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1816 "will be returned to the user with a message. If\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1817 "beautifulsoup is selected but not installed dehtml will\n" |
|
e20f472fde7d
issue2550799: provide basic support for handling html only emails
John Rouillard <rouilj@ieee.org>
parents:
5264
diff
changeset
|
1818 "be used instead."), |
|
5045
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1819 (BooleanOption, "keep_real_from", "no", |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1820 "When handling emails ignore the Resent-From:-header\n" |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1821 "and use the original senders From:-header instead.\n" |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1822 "(This might be desirable in some situations where a moderator\n" |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1823 "reads incoming messages first before bouncing them to Roundup)", |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1824 ["EMAIL_KEEP_REAL_FROM"]), |
|
a46d5d0fd5f8
Fix issue1615201: Added a new configuration option EMAIL_KEEP_REAL_FROM
Peter Funk <pf@artcom-gmbh.de>
parents:
5041
diff
changeset
|
1825 ), "Roundup Mail Gateway options"), |
|
3915
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1826 ("pgp", ( |
|
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1827 (BooleanOption, "enable", "no", |
|
5494
b7fa56ced601
use gpg module instead of pyme module for PGP encryption
Christof Meerwald <cmeerw@cmeerw.org>
parents:
5424
diff
changeset
|
1828 "Enable PGP processing. Requires gpg. If you're planning\n" |
|
4541
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1829 "to send encrypted PGP mail to the tracker, you should also\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1830 "enable the encrypt-option below, otherwise mail received\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1831 "encrypted might be sent unencrypted to another user."), |
|
3922
586679a314f7
role checking for PGP mail and docs
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3915
diff
changeset
|
1832 (NullableOption, "roles", "", |
|
586679a314f7
role checking for PGP mail and docs
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3915
diff
changeset
|
1833 "If specified, a comma-separated list of roles to perform\n" |
|
586679a314f7
role checking for PGP mail and docs
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3915
diff
changeset
|
1834 "PGP processing on. If not specified, it happens for all\n" |
|
4541
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1835 "users. Note that received PGP messages (signed and/or\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1836 "encrypted) will be processed with PGP even if the user\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1837 "doesn't have one of the PGP roles, you can use this to make\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1838 "PGP processing completely optional by defining a role here\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1839 "and not assigning any users to that role."), |
|
3915
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1840 (NullableOption, "homedir", "", |
|
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1841 "Location of PGP directory. Defaults to $HOME/.gnupg if\n" |
|
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1842 "not specified."), |
|
4541
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1843 (BooleanOption, "encrypt", "no", |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1844 "Enable PGP encryption. All outgoing mails are encrypted.\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1845 "This requires that keys for all users (with one of the gpg\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1846 "roles above or all users if empty) are available. Note that\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1847 "it makes sense to educate users to also send mails encrypted\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1848 "to the tracker, to enforce this, set 'require_incoming'\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1849 "option below (but see the note)."), |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1850 (Option, "require_incoming", "signed", |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1851 "Require that pgp messages received by roundup are either\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1852 "'signed', 'encrypted' or 'both'. If encryption is required\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1853 "we do not return the message (in clear) to the user but just\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1854 "send an informational message that the message was rejected.\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1855 "Note that this still presents known-plaintext to an attacker\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1856 "when the users sends the mail a second time with encryption\n" |
|
62239a524beb
PGP support is again working (pyme API has changed significantly)...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4488
diff
changeset
|
1857 "turned on."), |
|
3915
6b3919328381
support for receiving OpenPGP MIME messages (signed or encrypted)
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3882
diff
changeset
|
1858 ), "OpenPGP mail processing options"), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1859 ("nosy", ( |
|
4547
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1860 (Option, "messages_to_author", "no", |
|
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1861 "Send nosy messages to the author of the message.\n" |
|
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1862 "Allowed values: yes, no, new, nosy -- if yes, messages\n" |
|
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1863 "are sent to the author even if not on the nosy list, same\n" |
|
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1864 "for new (but only for new messages). When set to nosy,\n" |
|
d9d7319afffa
Add config-option "nosy" to messages_to_author setting in [nosy] section...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4541
diff
changeset
|
1865 "the nosy list controls sending messages to the author.", |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1866 ["MESSAGES_TO_AUTHOR"]), |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1867 (Option, "signature_position", "bottom", |
|
2630
a65bae7af6d1
NOSY_MESSAGES_TO_AUTHOR is RunDetectorOption (values: yes, no, new)...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2629
diff
changeset
|
1868 "Where to place the email signature.\n" |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1869 "Allowed values: top, bottom, none", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1870 ["EMAIL_SIGNATURE_POSITION"]), |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1871 (RunDetectorOption, "add_author", "new", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1872 "Does the author of a message get placed on the nosy list\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1873 "automatically? If 'new' is used, then the author will\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1874 "only be added when a message creates a new issue.\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1875 "If 'yes', then the author will be added on followups too.\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1876 "If 'no', they're never added to the nosy.\n", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1877 ["ADD_AUTHOR_TO_NOSY"]), |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1878 (RunDetectorOption, "add_recipients", "new", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1879 "Do the recipients (To:, Cc:) of a message get placed on the\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1880 "nosy list? If 'new' is used, then the recipients will\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1881 "only be added when a message creates a new issue.\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1882 "If 'yes', then the recipients will be added on followups too.\n" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1883 "If 'no', they're never added to the nosy.\n", |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1884 ["ADD_RECIPIENTS_TO_NOSY"]), |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1885 (Option, "email_sending", "single", |
|
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1886 "Controls the email sending from the nosy reactor. If\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1887 '"multiple" then a separate email is sent to each\n' |
|
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1888 'recipient. If "single" then a single email is sent with\n' |
|
3417
07c696890f55
mailgw subject parsing has configurable levels of strictness
Richard Jones <richard@users.sourceforge.net>
parents:
3356
diff
changeset
|
1889 "each recipient as a CC address."), |
|
5774
765f8c0e99ef
Sanity checking improvements. All IntegerNumberOption really have to
John Rouillard <rouilj@ieee.org>
parents:
5773
diff
changeset
|
1890 (IntegerNumberGeqZeroOption, "max_attachment_size", sys.maxsize, |
|
3882
46ef2a6fd79d
config option to limit nosy attachments based on size
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3879
diff
changeset
|
1891 "Attachments larger than the given number of bytes\n" |
|
46ef2a6fd79d
config option to limit nosy attachments based on size
Justus Pendleton <jpend@users.sourceforge.net>
parents:
3879
diff
changeset
|
1892 "won't be attached to nosy mails. They will be replaced by\n" |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1893 "a link to the tracker's download page for the file."), |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
1894 ), "Nosy messages sending"), |
|
6277
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1895 ("markdown", ( |
|
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1896 (BooleanOption, "break_on_newline", "no", |
|
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1897 "If yes/true, render single new line characters in markdown\n" |
|
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1898 "text with <br>. Set true if you want GitHub Flavored Markdown\n" |
|
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1899 "(GFM) handling of embedded newlines."), |
|
957a0fc20021
issue2551094 - markdown mismatch - new config for embedded newine
John Rouillard <rouilj@ieee.org>
parents:
6211
diff
changeset
|
1900 ), "Markdown rendering options."), |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1901 ) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1902 |
| 6966 | 1903 # Configuration classes |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1904 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
1905 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1906 class Config: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1907 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1908 """Base class for configuration objects. |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1909 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1910 Configuration options may be accessed as attributes or items |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1911 of instances of this class. All option names are uppercased. |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1912 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1913 """ |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1914 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1915 # Config file name |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1916 INI_FILE = "config.ini" |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1917 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1918 # Object attributes that should not be taken as common configuration |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1919 # options in __setattr__ (most of them are initialized in constructor): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1920 # builtin pseudo-option - package home directory |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1921 HOME = "." |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1922 # names of .ini file sections, in order |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1923 sections = None |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1924 # section comments |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1925 section_descriptions = None |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1926 # lists of option names for each section, in order |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1927 section_options = None |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1928 # mapping from option names and aliases to Option instances |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1929 options = None |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1930 # actual name of the config file. set on load. |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1931 filepath = os.path.join(HOME, INI_FILE) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1932 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
1933 # List of option names that need additional validation after |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
1934 # all options are loaded. |
|
7251
ab0ea9f03866
fix initialization of option_validator
John Rouillard <rouilj@ieee.org>
parents:
7219
diff
changeset
|
1935 option_validators = None |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
1936 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1937 def __init__(self, config_path=None, layout=None, settings=None): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1938 """Initialize confing instance |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1939 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1940 Parameters: |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1941 config_path: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1942 optional directory or file name of the config file. |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1943 If passed, load the config after processing layout (if any). |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1944 If config_path is a directory name, use default base name |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1945 of the config file. |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1946 layout: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1947 optional configuration layout, a sequence of |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1948 section definitions suitable for .add_section() |
|
3431
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
1949 settings: |
|
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
1950 optional setting overrides (dictionary). |
|
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
1951 The overrides are applied after loading config file. |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1952 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1953 """ |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1954 if settings is None: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
1955 settings = {} |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1956 # initialize option containers: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1957 self.sections = [] |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1958 self.section_descriptions = {} |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1959 self.section_options = {} |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1960 self.options = {} |
|
7251
ab0ea9f03866
fix initialization of option_validator
John Rouillard <rouilj@ieee.org>
parents:
7219
diff
changeset
|
1961 self.option_validators = [] |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1962 # add options from the layout structure |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1963 if layout: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1964 for section in layout: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1965 self.add_section(*section) |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1966 if config_path is not None: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
1967 self.load(config_path) |
|
3431
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
1968 for (name, value) in settings.items(): |
|
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
1969 self[name.upper()] = value |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1970 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1971 def add_section(self, section, options, description=None): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1972 """Define new config section |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1973 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1974 Parameters: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1975 section - name of the config.ini section |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1976 options - a sequence of Option definitions. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1977 Each Option definition is a sequence |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1978 containing class object and constructor |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1979 parameters, starting from the setting name: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1980 setting, default, [description, [aliases]] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1981 description - optional section comment |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1982 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1983 Note: aliases should only exist in historical options |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1984 for backwards compatibility - new options should |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1985 *not* have aliases! |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1986 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1987 """ |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
1988 if description or (section not in self.section_descriptions): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1989 self.section_descriptions[section] = description |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1990 for option_def in options: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1991 klass = option_def[0] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1992 args = option_def[1:] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1993 option = klass(self, section, *args) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
1994 self.add_option(option) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1995 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1996 def add_option(self, option): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1997 """Adopt a new Option object""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1998 _section = option.section |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
1999 _name = option.setting |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2000 if _section not in self.sections: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2001 self.sections.append(_section) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2002 _options = self._get_section_options(_section) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2003 if _name not in _options: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2004 _options.append(_name) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2005 # (section, name) key is used for writing .ini file |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2006 self.options[(_section, _name)] = option |
|
4074
e039f3cbbb96
Make RDBMS cache-size configurable.
Stefan Seefeld <stefan@seefeld.name>
parents:
4013
diff
changeset
|
2007 # make the option known under all of its A.K.A.s |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2008 for _name in option.aliases: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2009 self.options[_name] = option |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2010 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2011 if hasattr(option, 'validate'): |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2012 self.option_validators.append(option.name) |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2013 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2014 def update_option(self, name, klass, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2015 default=NODEFAULT, description=None): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2016 """Override behaviour of early created option. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2017 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2018 Parameters: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2019 name: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2020 option name |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2021 klass: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2022 one of the Option classes |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2023 default: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2024 optional default value for the option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2025 description: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2026 optional new description for the option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2027 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2028 Conversion from current option value to new class value |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2029 is done via string representation. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2030 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2031 This method may be used to attach some brains |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2032 to options autocreated by UserConfig. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2033 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2034 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2035 # fetch current option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2036 option = self._get_option(name) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2037 # compute constructor parameters |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2038 if default is NODEFAULT: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2039 default = option.default |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2040 if description is None: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2041 description = option.description |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2042 value = option.value2str(current=1) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2043 # resurrect the option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2044 option = klass(self, option.section, option.setting, |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2045 default=default, description=description) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2046 # apply the value |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2047 option.set(value) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2048 # incorporate new option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2049 del self[name] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2050 self.add_option(option) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2051 |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2052 def reset(self): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2053 """Set all options to their default values""" |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2054 for _option in self.items(): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2055 _option.reset() |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2056 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2057 # Meant for commandline tools. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2058 # Allows automatic creation of configuration files like this: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2059 # roundup-server -p 8017 -u roundup --save-config |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2060 def getopt(self, args, short_options="", long_options=(), |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2061 config_load_options=("C", "config"), **options): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2062 """Apply options specified in command line arguments. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2063 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2064 Parameters: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2065 args: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2066 command line to parse (sys.argv[1:]) |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2067 short_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2068 optional string of letters for command line options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2069 that are not config options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2070 long_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2071 optional list of names for long options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2072 that are not config options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2073 config_load_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2074 two-element sequence (letter, long_option) defining |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2075 the options for config file. If unset, don't load |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2076 config file; otherwise config file is read prior |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2077 to applying other options. Short option letter |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2078 must not have a colon and long_option name must |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2079 not have an equal sign or '--' prefix. |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2080 options: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2081 mapping from option names to command line option specs. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2082 e.g. server_port="p:", server_user="u:" |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2083 Names are forced to lower case for commandline parsing |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2084 (long options) and to upper case to find config options. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2085 Command line options accepting no value are assumed |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2086 to be binary and receive value 'yes'. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2087 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2088 Return value: same as for python standard getopt(), except that |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2089 processed options are removed from returned option list. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2090 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2091 """ |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2092 # take a copy of long_options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2093 long_options = list(long_options) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2094 # build option lists |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2095 cfg_names = {} |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2096 booleans = [] |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2097 for (name, letter) in options.items(): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2098 cfg_name = name.upper() |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2099 short_opt = "-" + letter[0] |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
2100 name = name.lower().replace("_", "-") # noqa: PLW2901 change name |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2101 cfg_names.update({short_opt: cfg_name, "--" + name: cfg_name}) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2102 |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2103 short_options += letter |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2104 if letter[-1] == ":": |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2105 long_options.append(name + "=") |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2106 else: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2107 booleans.append(short_opt) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2108 long_options.append(name) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2109 |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2110 if config_load_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2111 short_options += config_load_options[0] + ":" |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2112 long_options.append(config_load_options[1] + "=") |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2113 # compute names that will be searched in getopt return value |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2114 config_load_options = ( |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2115 "-" + config_load_options[0], |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2116 "--" + config_load_options[1], |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2117 ) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2118 # parse command line arguments |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2119 optlist, args = getopt.getopt(args, short_options, long_options) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2120 # load config file if requested |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2121 if config_load_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2122 for option in optlist: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2123 if option[0] in config_load_options: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2124 self.load_ini(option[1]) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2125 optlist.remove(option) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2126 break |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2127 # apply options |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2128 extra_options = [] |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2129 for (opt, arg) in optlist: |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2130 if (opt in booleans): # and not arg |
|
7812
ecc34b7917e2
chore(refactor): multiple changes/cleanups
John Rouillard <rouilj@ieee.org>
parents:
7811
diff
changeset
|
2131 arg = "yes" # noqa: PLW2901 -- change arg |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2132 try: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2133 name = cfg_names[opt] |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2134 except KeyError: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2135 extra_options.append((opt, arg)) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2136 else: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2137 self[name] = arg |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2138 return (extra_options, args) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2139 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2140 # option and section locators (used in option access methods) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2141 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2142 def _get_option(self, name): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2143 try: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2144 return self.options[name] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2145 except KeyError: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2146 raise InvalidOptionError(name) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2147 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2148 def _get_section_options(self, name): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2149 return self.section_options.setdefault(name, []) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2150 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2151 def _get_unset_options(self): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2152 """Return options that need manual adjustments |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2153 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2154 Return value is a dictionary where keys are section |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2155 names and values are lists of option names as they |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2156 appear in the config file. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2157 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2158 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2159 need_set = {} |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2160 for option in self.items(): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2161 if not option.isset(): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2162 need_set.setdefault(option.section, []).append(option.setting) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2163 return need_set |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2164 |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2165 def _adjust_options(self, config): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2166 """Load ad-hoc option definitions from ConfigParser instance.""" |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2167 pass |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2168 |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2169 def _get_name(self): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2170 """Return the service name for config file heading""" |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2171 return "" |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2172 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2173 # file operations |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2174 |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2175 def load_ini(self, config_path, defaults=None): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2176 """Set options from config.ini file in given home_dir |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2177 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2178 Parameters: |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2179 config_path: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2180 directory or file name of the config file. |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2181 If config_path is a directory name, use default |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2182 base name of the config file |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2183 defaults: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2184 optional dictionary of defaults for ConfigParser |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2185 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2186 Note: if home_dir does not contain config.ini file, |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2187 no error is raised. Config will be reset to defaults. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2188 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2189 """ |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2190 if os.path.isdir(config_path): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2191 home_dir = config_path |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2192 config_path = os.path.join(config_path, self.INI_FILE) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2193 else: |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2194 home_dir = os.path.dirname(config_path) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2195 # parse the file |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2196 config_defaults = {"HOME": home_dir} |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2197 if defaults: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2198 config_defaults.update(defaults) |
|
5246
c5dd7b151ec2
Make an import work with either Python 2 or 3.
Eric S. Raymond <esr@thyrsus.com>
parents:
5231
diff
changeset
|
2199 config = configparser.ConfigParser(config_defaults) |
|
2839
f965de0c1e75
fix load_ini: configuration file name was ignored after all
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2770
diff
changeset
|
2200 config.read([config_path]) |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2201 # .ini file loaded ok. |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2202 self.HOME = home_dir |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2203 self.filepath = config_path |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2204 self._adjust_options(config) |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2205 # set the options, starting from HOME |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2206 self.reset() |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2207 for option in self.items(): |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2208 option.load_ini(config) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2209 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2210 def load(self, home_dir): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2211 """Load configuration settings from home_dir""" |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2212 self.load_ini(home_dir) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2213 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2214 def save(self, ini_file=None): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2215 """Write current configuration to .ini file |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2216 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2217 'ini_file' argument, if passed, must be valid full path |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2218 to the file to write. If omitted, default file in current |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2219 HOME is created. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2220 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2221 If the file to write already exists, it is saved with '.bak' |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2222 extension. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2223 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2224 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2225 if ini_file is None: |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2226 ini_file = self.filepath |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2227 _tmp_file = os.path.splitext(ini_file)[0] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2228 _bak_file = _tmp_file + ".bak" |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2229 _tmp_file = _tmp_file + ".tmp" |
|
7811
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2230 with open(_tmp_file, "wt") as _fp: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2231 _fp.write("# %s configuration file\n" % self._get_name()) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2232 _fp.write("# Autogenerated at %s\n" % time.asctime()) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2233 need_set = self._get_unset_options() |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2234 if need_set: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2235 _fp.write("\n# WARNING! Following options need adjustments:\n") |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2236 for section, options in need_set.items(): |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2237 _fp.write("# [%s]: %s\n" % (section, ", ".join(options))) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2238 for section in self.sections: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2239 comment = self.section_descriptions.get(section, None) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2240 if comment: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2241 _fp.write("\n# ".join([""] + comment.split("\n")) + "\n") |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2242 else: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2243 # no section comment - just leave a blank line between sections |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2244 _fp.write("\n") |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2245 _fp.write("[%s]\n" % section) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2246 for option in self._get_section_options(section): |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2247 _fp.write("\n" + self.options[(section, option)].format()) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2248 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2249 if os.access(ini_file, os.F_OK): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2250 if os.access(_bak_file, os.F_OK): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2251 os.remove(_bak_file) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2252 os.rename(ini_file, _bak_file) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2253 os.rename(_tmp_file, ini_file) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2254 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2255 # container emulation |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2256 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2257 def __len__(self): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2258 return len(self.items()) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2259 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2260 def __getitem__(self, name): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2261 if name == "HOME": |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2262 return self.HOME |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2263 else: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2264 return self._get_option(name).get() |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2265 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2266 def __setitem__(self, name, value): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2267 if name == "HOME": |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2268 self.HOME = value |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2269 else: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2270 self._get_option(name).set(value) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2271 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2272 def __delitem__(self, name): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2273 _option = self._get_option(name) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2274 _section = _option.section |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2275 _name = _option.setting |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2276 self._get_section_options(_section).remove(_name) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2277 del self.options[(_section, _name)] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2278 for _alias in _option.aliases: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2279 del self.options[_alias] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2280 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2281 def items(self): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2282 """Return the list of Option objects, in .ini file order |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2283 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2284 Note that HOME is not included in this list |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2285 because it is builtin pseudo-option, not a real Option |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2286 object loaded from or saved to .ini file. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2287 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2288 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2289 return [self.options[(_section, _name)] |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2290 for _section in self.sections |
|
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2291 for _name in self._get_section_options(_section)] |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2292 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2293 def keys(self): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2294 """Return the list of "canonical" names of the options |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2295 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2296 Unlike .items(), this list also includes HOME |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2297 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2298 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2299 return ["HOME"] + [_option.name for _option in self.items()] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2300 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2301 # .values() is not implemented because i am not sure what should be |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2302 # the values returned from this method: Option instances or config values? |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2303 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2304 # attribute emulation |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2305 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2306 def __setattr__(self, name, value): |
|
5128
4058fc1ec746
replacing depricated has_key references by in to support python 3. Errors reported by python -3 roundup_server. Unit tests test_config test_security pass although test_config is a bit weak in coverage.
John Rouillard <rouilj@ieee.org>
parents:
5117
diff
changeset
|
2307 if (name in self.__dict__) or hasattr(self.__class__, name): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2308 self.__dict__[name] = value |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2309 else: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2310 self._get_option(name).set(value) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2311 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2312 # Note: __getattr__ is not symmetric to __setattr__: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2313 # self.__dict__ lookup is done before calling this method |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2314 def __getattr__(self, name): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2315 return self[name] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2316 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2317 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2318 class UserConfig(Config): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2319 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2320 """Configuration for user extensions. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2321 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2322 Instances of this class have no predefined configuration layout. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2323 Options are created on the fly for each setting present in the |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2324 config file. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2325 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2326 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2327 |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2328 def _adjust_options(self, config): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2329 # config defaults appear in all sections. |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2330 # we'll need to filter them out. |
|
5395
23b8e6067f7c
Python 3 preparation: update calls to dict methods.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5386
diff
changeset
|
2331 defaults = list(config.defaults().keys()) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2332 # see what options are already defined and add missing ones |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2333 preset = [(option.section, option.setting) for option in self.items()] |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2334 for section in config.sections(): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2335 for name in config.options(section): |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2336 if ((section, name) not in preset) \ |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2337 and (name not in defaults): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2338 self.add_option(Option(self, section, name)) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2339 |
|
6004
55f5060e0508
flake8 formatting fixes; use isinstance rather than type equality.
John Rouillard <rouilj@ieee.org>
parents:
5976
diff
changeset
|
2340 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2341 class CoreConfig(Config): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2342 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2343 """Roundup instance configuration. |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2344 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2345 Core config has a predefined layout (see the SETTINGS structure), |
|
6354
b61de764c8cc
Remove left over python style config remnant, doc update.
John Rouillard <rouilj@ieee.org>
parents:
6353
diff
changeset
|
2346 two additional attributes: |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2347 detectors: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2348 user-defined configuration for detectors |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2349 ext: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2350 user-defined configuration for extensions |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2351 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2352 """ |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2353 |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2354 # user configs |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2355 ext = None |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2356 detectors = None |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2357 |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
2358 def __init__(self, home_dir=None, settings=None): |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
2359 if settings is None: |
|
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
2360 settings = {} |
|
3431
26dc6b92ac26
Config, CoreConfig: accept setting overrides in constructor
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3425
diff
changeset
|
2361 Config.__init__(self, home_dir, layout=SETTINGS, settings=settings) |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2362 # load the config if home_dir given |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2363 if home_dir is None: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2364 self.init_logging() |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2365 |
|
4342
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2366 def copy(self): |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2367 new = CoreConfig() |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2368 new.sections = list(self.sections) |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2369 new.section_descriptions = dict(self.section_descriptions) |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2370 new.section_options = dict(self.section_options) |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2371 new.options = dict(self.options) |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2372 return new |
|
94c992852f12
add in-memory hyperdb implementation to speed up testing
Richard Jones <richard@users.sourceforge.net>
parents:
4337
diff
changeset
|
2373 |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2374 def _get_unset_options(self): |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2375 need_set = Config._get_unset_options(self) |
|
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2376 # remove MAIL_PASSWORD if MAIL_USER is empty |
|
7811
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2377 if "password" in need_set.get("mail", []) and \ |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2378 not self["MAIL_USERNAME"]: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2379 settings = need_set["mail"] |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2380 settings.remove("password") |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2381 if not settings: |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2382 del need_set["mail"] |
|
2654
eccb8e15a83f
implemented section comments;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2649
diff
changeset
|
2383 return need_set |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2384 |
|
2770
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2385 def _get_name(self): |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2386 return self["TRACKER_NAME"] |
|
cdf6787ffeda
implement getopt().
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2654
diff
changeset
|
2387 |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2388 @gen_trace_id() |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2389 def _logging_test(self, sinfo, msg="test %(a)s\n%(sinfo)s", args=None): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2390 """Test method for logging formatting. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2391 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2392 Not used in production. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2393 """ |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2394 logger = logging.getLogger('roundup') |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2395 if args: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2396 logger.info(msg, *args) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2397 else: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2398 logger.info(msg, extra={"a": "a_var", "sinfo": sinfo}) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2399 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2400 def reset(self): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2401 Config.reset(self) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2402 if self.ext: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2403 self.ext.reset() |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2404 if self.detectors: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2405 self.detectors.reset() |
|
2619
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
2406 self.init_logging() |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
2407 |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2408 def gather_callstack(self, keep_full_stack=False): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2409 # Locate logging call in stack |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2410 stack = traceback.extract_stack() |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2411 if keep_full_stack: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2412 last_frame_index = len(stack) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2413 else: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2414 for last_frame_index, frame in enumerate(stack): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2415 # Walk from the top of stack looking for |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2416 # "logging" in filename (really |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2417 # filepath). Can't use /logging/ as |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2418 # windows uses \logging\. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2419 # |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2420 # Filtering by looking for "logging" in |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2421 # the filename isn't great. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2422 if "logging" in frame.filename: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2423 break |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2424 if not keep_full_stack: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2425 stack = stack[0:last_frame_index] |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2426 return (stack, last_frame_index) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2427 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2428 def context_filter(self, record): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2429 """Add context to record, expand context references in record.msg |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2430 Define pct_char as '%' |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2431 """ |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2432 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2433 # This method can be called multiple times on different handlers. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2434 # However it modifies the record on the first call and the changes |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2435 # persist in the record. So we only want to be called once per |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2436 # record. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2437 if hasattr(record, "ROUNDUP_CONTEXT_FILTER_CALLED"): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2438 return True |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2439 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2440 for name, value in get_context_info(): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2441 if not hasattr(record, name): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2442 setattr(record, name, value) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2443 record.pct_char = "%" |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2444 record.ROUNDUP_CONTEXT_FILTER_CALLED = True |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2445 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2446 if hasattr(record, "sinfo"): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2447 # sinfo has to be set via extras argument to logging commands |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2448 # to activate this. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2449 # |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2450 # sinfo value can be: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2451 # non-integer: "", None etc. Print 5 elements of |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2452 # stack before logging call |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2453 # integer N > 0: print N elements of stack before |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2454 # logging call |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2455 # 0: print whole stack before logging call |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2456 # integer N < 0: undocumented print stack starting at |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2457 # extract_stack() below. I.E. do not set bottom of |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2458 # stack to the logging call. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2459 # if |N| is greater than stack height, print whole stack. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2460 stack_height = record.sinfo |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2461 keep_full_stack = False |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2462 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2463 if isinstance(stack_height, int): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2464 if stack_height < 0: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2465 keep_full_stack = True |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2466 stack_height = abs(stack_height) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2467 if stack_height == 0: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2468 # None will set value to actual stack height. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2469 stack_height = None |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2470 else: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2471 stack_height = 5 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2472 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2473 stack, last_frame_index = self.gather_callstack(keep_full_stack) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2474 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2475 if stack_height is None: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2476 stack_height = last_frame_index |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2477 elif stack_height > last_frame_index: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2478 stack_height = last_frame_index # start at frame 0 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2479 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2480 # report the stack info |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2481 record.sinfo = "".join( |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2482 traceback.format_list( |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2483 stack[last_frame_index - stack_height:last_frame_index] |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2484 ) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2485 ) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2486 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2487 # if args are present, just return. Logging will |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2488 # expand the arguments. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2489 if record.args: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2490 return True |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2491 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2492 # Since args not present, try formatting msg using |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2493 # named arguments. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2494 try: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2495 record.msg = record.msg % record.__dict__ |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2496 except (ValueError, TypeError): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2497 # ValueError: means there is a % sign in the msg |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2498 # somewhere that is not meant to be a format token. So |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2499 # just leave msg unexpanded. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2500 # |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2501 # TypeError - a positional format string is being |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2502 # handled without setting record.args. E.G. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2503 # .info("result is %f") |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2504 # Leave message unexpanded. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2505 pass |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2506 return True |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2507 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2508 def add_logging_context_filter(self): |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2509 """Update log record with contextvar values and expand msg |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2510 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2511 The contextvar values are stored as attributes on the log |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2512 record object in record.__dict__. They should not exist |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2513 when this is called. Do not overwrite them if they do exist |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2514 as they can be set in a logger call using:: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2515 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2516 logging.warning("a message", extra = {"trace_id": foo}) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2517 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2518 the extra argument/parameter. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2519 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2520 Attempt to expand msg using the variables in |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2521 record.__dict__. This makes:: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2522 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2523 logging.warning("the URL was: %(trace_reason)s") |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2524 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2525 work and replaces the ``%(trace_reason)s`` token with the value. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2526 Note that you can't use positional params and named params |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2527 together. For example:: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2528 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2529 logging.warning("user = %s and URL was: %(trace_reason)s", user) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2530 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2531 will result in an exception in logging when it formats the |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2532 message. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2533 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2534 Also ``%(pct_char)`` is defined to allow the addition of % |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2535 characters in the format string as bare % chars can't make |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2536 it past the configparser and %% encoded ones run into issue |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2537 with the format verifier. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2538 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2539 Calling a logger (.warning() etc.) with the argument:: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2540 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2541 extra={"sinfo": an_int} |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2542 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2543 will result in a stack trace starting at the logger call |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2544 and going up the stack for `an_int` frames. Using "True" |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2545 in place of `an_int` will print only the call to the logger. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2546 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2547 Note that logging untrusted strings in the msg set by user |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2548 (untrusted) may be an issue. So don't do something like: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2549 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2550 .info("%s" % web_url) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2551 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2552 as web_url could include '%(trace_id)s'. Instead use: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2553 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2554 .info("%(url)s", extra=("url": web_url)) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2555 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2556 Even in the problem case, I think the damage is contained since: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2557 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2558 * data doesn't leak as the log string is not exposed to the |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2559 user. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2560 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2561 * the log string isn't executed or used internally. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2562 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2563 * log formating can raise an exception. But this won't |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2564 affect the application as the exception is swallowed in |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2565 the logging package. The raw message would be printed by |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2566 the fallback logging handler. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2567 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2568 but if it is a concern, make sure user data is added using |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2569 the extra dict when calling one of the logging functions. |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2570 """ |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2571 loggers = [logging.getLogger(name) for name in |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2572 logging.root.manager.loggerDict] |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2573 # append the root logger as it is not listed in loggerDict |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2574 loggers.append(logging.getLogger()) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2575 for logger in loggers: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2576 for hdlr in logger.handlers: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2577 hdlr.addFilter(self.context_filter) |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2578 |
|
8423
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2579 def load_config_dict_from_json_file(self, filename): |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2580 import json |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2581 comment_re = re.compile( |
|
8433
de1dac9abcb6
feat: change comment in dictConfig json file to // from #
John Rouillard <rouilj@ieee.org>
parents:
8423
diff
changeset
|
2582 r"""^\s*//#.* # comment at beginning of line possibly indented. |
|
8423
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2583 | # or |
|
8433
de1dac9abcb6
feat: change comment in dictConfig json file to // from #
John Rouillard <rouilj@ieee.org>
parents:
8423
diff
changeset
|
2584 ^(.*)\s\s\s\//.* # comment char preceeded by at least three spaces. |
|
8423
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2585 """, re.VERBOSE) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2586 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2587 config_list = [] |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2588 with open(filename) as config_file: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2589 for line in config_file: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2590 match = comment_re.search(line) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2591 if match: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2592 if match.lastindex: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2593 config_list.append(match.group(1) + "\n") |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2594 else: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2595 # insert blank line for comment line to |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2596 # keep line numbers in sync. |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2597 config_list.append("\n") |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2598 continue |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2599 config_list.append(line) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2600 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2601 try: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2602 config_dict = json.loads("".join(config_list)) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2603 except json.decoder.JSONDecodeError as e: |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2604 error_at_doc_line = e.lineno |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2605 # subtract 1 - zero index on config_list |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2606 # remove '\n' for display |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2607 line = config_list[error_at_doc_line - 1][:-1] |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2608 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2609 hint = "" |
|
8433
de1dac9abcb6
feat: change comment in dictConfig json file to // from #
John Rouillard <rouilj@ieee.org>
parents:
8423
diff
changeset
|
2610 if line.find('//') != -1: |
|
de1dac9abcb6
feat: change comment in dictConfig json file to // from #
John Rouillard <rouilj@ieee.org>
parents:
8423
diff
changeset
|
2611 hint = "\nMaybe bad inline comment, 3 spaces needed before //." |
|
8423
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2612 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2613 raise LoggingConfigError( |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2614 'Error parsing json logging dict (%(file)s) ' |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2615 'near \n\n %(line)s\n\n' |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2616 '%(msg)s: line %(lineno)s column %(colno)s.%(hint)s' % |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2617 {"file": filename, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2618 "line": line, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2619 "msg": e.msg, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2620 "lineno": error_at_doc_line, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2621 "colno": e.colno, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2622 "hint": hint}, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2623 config_file=self.filepath, |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2624 source="json.loads" |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2625 ) |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2626 |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2627 return config_dict |
|
94eed885e958
feat: add support for using dictConfig to configure logging.
John Rouillard <rouilj@ieee.org>
parents:
8314
diff
changeset
|
2628 |
|
2619
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
2629 def init_logging(self): |
|
4b4ca3bd086b
added logging support;
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2618
diff
changeset
|
2630 _file = self["LOGGING_CONFIG"] |
|
8434
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2631 if _file and os.path.isfile(_file): |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2632 if _file.endswith(".ini"): |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2633 logging.config.fileConfig( |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2634 _file, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2635 disable_existing_loggers=self["LOGGING_DISABLE_LOGGERS"]) |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2636 elif _file.endswith(".json"): |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2637 config_dict = self.load_config_dict_from_json_file(_file) |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2638 try: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2639 logging.config.dictConfig(config_dict) |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2640 except ValueError as e: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2641 # docs say these exceptions: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2642 # ValueError, TypeError, AttributeError, ImportError |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2643 # could be raised, but |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2644 # looking through the code, it looks like |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2645 # configure() maps all exceptions (including |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2646 # ImportError, TypeError) raised by functions to |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2647 # ValueError. |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2648 context = "No additional information available." |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2649 if hasattr(e, '__context__') and e.__context__: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2650 # get additional error info. E.G. if INFO |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2651 # is replaced by MANGO, context is: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2652 # ValueError("Unknown level: 'MANGO'") |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2653 # while str(e) is "Unable to configure handler 'access'" |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2654 context = e.__context__ |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2655 |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2656 raise LoggingConfigError( |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2657 'Error loading logging dict from %(file)s.\n' |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2658 '%(msg)s\n%(context)s\n' % { |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2659 "file": _file, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2660 "msg": type(e).__name__ + ": " + str(e), |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2661 "context": context |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2662 }, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2663 config_file=self.filepath, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2664 source="dictConfig" |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2665 ) |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2666 else: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2667 raise OptionValueError( |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2668 self.options['LOGGING_CONFIG'], |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2669 _file, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2670 "Unable to load logging config file. " |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2671 "File extension must be '.ini' or '.json'.\n" |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2672 ) |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2673 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2674 self.add_logging_context_filter() |
|
3155
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2675 return |
|
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2676 |
|
8434
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2677 if _file: |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2678 raise OptionValueError(self.options['LOGGING_CONFIG'], |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2679 _file, |
|
66284037142e
refactor: also error on missing file or invalid extension
John Rouillard <rouilj@ieee.org>
parents:
8433
diff
changeset
|
2680 "Unable to find logging config file.") |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2681 |
|
3155
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2682 _file = self["LOGGING_FILENAME"] |
|
4411
39660ba47b7c
- No longer use the root logger, use a logger with prefix "roundup"...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4405
diff
changeset
|
2683 # set file & level on the roundup logger |
|
39660ba47b7c
- No longer use the root logger, use a logger with prefix "roundup"...
Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
parents:
4405
diff
changeset
|
2684 logger = logging.getLogger('roundup') |
|
7811
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2685 hdlr = logging.FileHandler(_file) if _file else \ |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2686 logging.StreamHandler(sys.stdout) |
|
a4b71f16c264
chore(refactor): use 'with open'; if ternarys; unnested if statements
John Rouillard <rouilj@ieee.org>
parents:
7810
diff
changeset
|
2687 |
|
8443
39a6825d10ca
feat: allow admin to set logging format from config.ini
John Rouillard <rouilj@ieee.org>
parents:
8434
diff
changeset
|
2688 formatter = logging.Formatter(self["LOGGING_FORMAT"]) |
|
3155
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2689 hdlr.setFormatter(formatter) |
|
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2690 # no logging API to remove all existing handlers!?! |
|
4337
9225a37fbeae
Fix file handle leak in some web interfaces with logging turned on
Richard Jones <richard@users.sourceforge.net>
parents:
4255
diff
changeset
|
2691 for h in logger.handlers: |
|
9225a37fbeae
Fix file handle leak in some web interfaces with logging turned on
Richard Jones <richard@users.sourceforge.net>
parents:
4255
diff
changeset
|
2692 h.close() |
|
9225a37fbeae
Fix file handle leak in some web interfaces with logging turned on
Richard Jones <richard@users.sourceforge.net>
parents:
4255
diff
changeset
|
2693 logger.removeHandler(hdlr) |
|
3155
57b60bda9473
Python 2.3 minimum version - bye bye roundup.rlog, you had a short life.
Richard Jones <richard@users.sourceforge.net>
parents:
3099
diff
changeset
|
2694 logger.handlers = [hdlr] |
|
5424
fd0481aa17b8
Python 3 preparation: avoid logging._levelNames.
Joseph Myers <jsm@polyomino.org.uk>
parents:
5416
diff
changeset
|
2695 logger.setLevel(self["LOGGING_LEVEL"] or "ERROR") |
|
8446
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2696 if 'pytest' not in sys.modules: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2697 # logger.propatgate is True by default. This is |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2698 # needed so that pytest caplog code will work. In |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2699 # production leaving it set to True relogs everything |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2700 # using the root logger with logging BASIC_FORMAT: |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2701 # "%(level)s:%(name)s:%(message)s |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2702 logger.propagate = False |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2703 |
|
14c7c07b32d8
feature: add thread local trace_id and trace_reason to logging.
John Rouillard <rouilj@ieee.org>
parents:
8443
diff
changeset
|
2704 self.add_logging_context_filter() |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2705 |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2706 def validator(self, options): |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2707 """ Validate options once all options are loaded. |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2708 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2709 Used to validate settings when options are dependent |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2710 on each other. E.G. indexer_language can only be |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2711 validated if xapian indexer is used. |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2712 """ |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2713 |
|
6584
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2714 for option in self.option_validators: |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2715 # validate() should throw an exception if there is an issue. |
|
770503bd211e
Validate SecretOption and support validate method
John Rouillard <rouilj@ieee.org>
parents:
6578
diff
changeset
|
2716 options[option].validate(options) |
|
6578
b1f1539c6a31
issue2551182 - ... allow loading values from external file. flake8 cleanups
John Rouillard <rouilj@ieee.org>
parents:
6562
diff
changeset
|
2717 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2718 def load(self, home_dir): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2719 """Load configuration from path designated by home_dir argument""" |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2720 if os.path.isfile(os.path.join(home_dir, self.INI_FILE)): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2721 self.load_ini(home_dir) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2722 else: |
|
6300
778a9f455067
Remove old code import imp, old style trackers db/backend_name
John Rouillard <rouilj@ieee.org>
parents:
6277
diff
changeset
|
2723 raise NoConfigError(home_dir) |
|
6356
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2724 |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2725 # validator does inter-setting validation checks. |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2726 # when there are dependencies between options. |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2727 self.validator(self.options) |
|
c26b9ce33ae3
issue2551123 - validate indexer_language in configuration.py
John Rouillard <rouilj@ieee.org>
parents:
6355
diff
changeset
|
2728 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2729 self.init_logging() |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2730 self.ext = UserConfig(os.path.join(home_dir, "extensions")) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2731 self.detectors = UserConfig(os.path.join(home_dir, "detectors")) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2732 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2733 def load_ini(self, home_dir, defaults=None): |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2734 """Set options from config.ini file in given home_dir directory""" |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2735 config_defaults = {"TRACKER_HOME": home_dir} |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2736 if defaults: |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2737 config_defaults.update(defaults) |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2738 Config.load_ini(self, home_dir, config_defaults) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2739 |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2740 # in this config, HOME is also known as TRACKER_HOME |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2741 def __getitem__(self, name): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2742 if name == "TRACKER_HOME": |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2743 return self.HOME |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2744 else: |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2745 return Config.__getitem__(self, name) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2746 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2747 def __setitem__(self, name, value): |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2748 if name == "TRACKER_HOME": |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2749 self.HOME = value |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2750 else: |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2751 self._get_option(name).set(value) |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2752 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2753 def __setattr__(self, name, value): |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2754 if name == "TRACKER_HOME": |
|
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2755 self.__dict__["HOME"] = value |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2756 else: |
|
2646
fd7b2fc1eb28
Config is now base class for all configurations...
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
2637
diff
changeset
|
2757 Config.__setattr__(self, name, value) |
|
2618
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2758 |
|
8b08558e30a0
Roundup Issue Tracker configuration support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
diff
changeset
|
2759 # vim: set et sts=4 sw=4 : |
