##// END OF EJS Templates
fix(usage): remove print as it leaks to various other outputs like git stdout
super-admin -
r5228:570229d4 default
parent child Browse files
Show More
@@ -1,87 +1,91 b''
1 # Copyright (C) 2010-2023 RhodeCode GmbH
1 # Copyright (C) 2010-2023 RhodeCode GmbH
2 #
2 #
3 # This program is free software: you can redistribute it and/or modify
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU Affero General Public License, version 3
4 # it under the terms of the GNU Affero General Public License, version 3
5 # (only), as published by the Free Software Foundation.
5 # (only), as published by the Free Software Foundation.
6 #
6 #
7 # This program is distributed in the hope that it will be useful,
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
10 # GNU General Public License for more details.
11 #
11 #
12 # You should have received a copy of the GNU Affero General Public License
12 # You should have received a copy of the GNU Affero General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 #
14 #
15 # This program is dual-licensed. If you wish to learn more about the
15 # This program is dual-licensed. If you wish to learn more about the
16 # RhodeCode Enterprise Edition, including its added features, Support services,
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18
18
19 import os
19 import os
20 import datetime
20 import datetime
21 import collections
21 import collections
22 import logging
23
22
24
23 now = datetime.datetime.now()
25 now = datetime.datetime.now()
24 now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}"
26 now = now.strftime("%Y-%m-%d %H:%M:%S") + '.' + f"{int(now.microsecond/1000):03d}"
25
27
26 print(f'{now} Starting RhodeCode imports...')
28 log = logging.getLogger(__name__)
29 log.debug(f'{now} Starting RhodeCode imports...')
30
27
31
28 VERSION = tuple(open(os.path.join(
32 VERSION = tuple(open(os.path.join(
29 os.path.dirname(__file__), 'VERSION')).read().split('.'))
33 os.path.dirname(__file__), 'VERSION')).read().split('.'))
30
34
31 BACKENDS = collections.OrderedDict()
35 BACKENDS = collections.OrderedDict()
32
36
33 BACKENDS['hg'] = 'Mercurial repository'
37 BACKENDS['hg'] = 'Mercurial repository'
34 BACKENDS['git'] = 'Git repository'
38 BACKENDS['git'] = 'Git repository'
35 BACKENDS['svn'] = 'Subversion repository'
39 BACKENDS['svn'] = 'Subversion repository'
36
40
37
41
38 CELERY_ENABLED = False
42 CELERY_ENABLED = False
39 CELERY_EAGER = False
43 CELERY_EAGER = False
40
44
41 # link to config for pyramid
45 # link to config for pyramid
42 CONFIG = {}
46 CONFIG = {}
43
47
44
48
45 class ConfigGet:
49 class ConfigGet:
46 NotGiven = object()
50 NotGiven = object()
47
51
48 def _get_val_or_missing(self, key, missing):
52 def _get_val_or_missing(self, key, missing):
49 if key not in CONFIG:
53 if key not in CONFIG:
50 if missing == self.NotGiven:
54 if missing == self.NotGiven:
51 return missing
55 return missing
52 # we don't get key, we don't get missing value, return nothing similar as config.get(key)
56 # we don't get key, we don't get missing value, return nothing similar as config.get(key)
53 return None
57 return None
54 else:
58 else:
55 val = CONFIG[key]
59 val = CONFIG[key]
56 return val
60 return val
57
61
58 def get_str(self, key, missing=NotGiven):
62 def get_str(self, key, missing=NotGiven):
59 from rhodecode.lib.str_utils import safe_str
63 from rhodecode.lib.str_utils import safe_str
60 val = self._get_val_or_missing(key, missing)
64 val = self._get_val_or_missing(key, missing)
61 return safe_str(val)
65 return safe_str(val)
62
66
63 def get_int(self, key, missing=NotGiven):
67 def get_int(self, key, missing=NotGiven):
64 from rhodecode.lib.str_utils import safe_int
68 from rhodecode.lib.str_utils import safe_int
65 val = self._get_val_or_missing(key, missing)
69 val = self._get_val_or_missing(key, missing)
66 return safe_int(val)
70 return safe_int(val)
67
71
68 def get_bool(self, key, missing=NotGiven):
72 def get_bool(self, key, missing=NotGiven):
69 from rhodecode.lib.type_utils import str2bool
73 from rhodecode.lib.type_utils import str2bool
70 val = self._get_val_or_missing(key, missing)
74 val = self._get_val_or_missing(key, missing)
71 return str2bool(val)
75 return str2bool(val)
72
76
73 # Populated with the settings dictionary from application init in
77 # Populated with the settings dictionary from application init in
74 # rhodecode.conf.environment.load_pyramid_environment
78 # rhodecode.conf.environment.load_pyramid_environment
75 PYRAMID_SETTINGS = {}
79 PYRAMID_SETTINGS = {}
76
80
77 # Linked module for extensions
81 # Linked module for extensions
78 EXTENSIONS = {}
82 EXTENSIONS = {}
79
83
80 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
84 __version__ = ('.'.join((str(each) for each in VERSION[:3])))
81 __dbversion__ = 114 # defines current db version for migrations
85 __dbversion__ = 114 # defines current db version for migrations
82 __license__ = 'AGPLv3, and Commercial License'
86 __license__ = 'AGPLv3, and Commercial License'
83 __author__ = 'RhodeCode GmbH'
87 __author__ = 'RhodeCode GmbH'
84 __url__ = 'https://code.rhodecode.com'
88 __url__ = 'https://code.rhodecode.com'
85
89
86 is_test = False
90 is_test = False
87 disable_error_handler = False
91 disable_error_handler = False
General Comments 0
You need to be logged in to leave comments. Login now