Show More
@@ -184,17 +184,6 b'' | |||
|
184 | 184 | { |
|
185 | 185 | "license": [ |
|
186 | 186 | { |
|
187 | "fullName": "MIT License", | |
|
188 | "shortName": "mit", | |
|
189 | "spdxId": "MIT", | |
|
190 | "url": "http://spdx.org/licenses/MIT.html" | |
|
191 | } | |
|
192 | ], | |
|
193 | "name": "python2.7-pathlib2-2.3.5" | |
|
194 | }, | |
|
195 | { | |
|
196 | "license": [ | |
|
197 | { | |
|
198 | 187 | "fullName": "BSD 4-clause \"Original\" or \"Old\" License", |
|
199 | 188 | "shortName": "bsdOriginal", |
|
200 | 189 | "spdxId": "BSD-4-Clause", |
@@ -1868,17 +1857,6 b'' | |||
|
1868 | 1857 | "url": "http://spdx.org/licenses/BSD-4-Clause.html" |
|
1869 | 1858 | } |
|
1870 | 1859 | ], |
|
1871 | "name": "python2.7-configobj-5.0.6" | |
|
1872 | }, | |
|
1873 | { | |
|
1874 | "license": [ | |
|
1875 | { | |
|
1876 | "fullName": "BSD 4-clause \"Original\" or \"Old\" License", | |
|
1877 | "shortName": "bsdOriginal", | |
|
1878 | "spdxId": "BSD-4-Clause", | |
|
1879 | "url": "http://spdx.org/licenses/BSD-4-Clause.html" | |
|
1880 | } | |
|
1881 | ], | |
|
1882 | 1860 | "name": "python2.7-channelstream-0.6.14" |
|
1883 | 1861 | }, |
|
1884 | 1862 | { |
@@ -120,8 +120,7 b' def make_pyramid_app(global_config, **se' | |||
|
120 | 120 | meta.Session.remove() |
|
121 | 121 | |
|
122 | 122 | total_time = time.time() - start_time |
|
123 |
log.info('Pyramid app |
|
|
124 | getattr(pyramid_app, 'func_name', 'pyramid_app'), total_time) | |
|
123 | log.info('Pyramid app created and configured in %.2fs', total_time) | |
|
125 | 124 | return pyramid_app |
|
126 | 125 | |
|
127 | 126 | |
@@ -241,11 +240,20 b' def error_handler(exception, request):' | |||
|
241 | 240 | c.exception_id_url = request.route_url( |
|
242 | 241 | 'admin_settings_exception_tracker_show', exception_id=c.exception_id) |
|
243 | 242 | |
|
243 | debug_mode = rhodecode.ConfigGet().get_bool('debug') | |
|
244 | 244 | if c.show_exception_id: |
|
245 | 245 | store_exception(c.exception_id, exc_info) |
|
246 | c.exception_debug = str2bool(rhodecode.CONFIG.get('debug')) | |
|
246 | c.exception_debug = debug_mode | |
|
247 | 247 | c.exception_config_ini = rhodecode.CONFIG.get('__file__') |
|
248 | 248 | |
|
249 | if debug_mode: | |
|
250 | try: | |
|
251 | from rich.traceback import install | |
|
252 | install(show_locals=True) | |
|
253 | log.debug('Installing rich tracebacks...') | |
|
254 | except ImportError: | |
|
255 | pass | |
|
256 | ||
|
249 | 257 | response = render_to_response( |
|
250 | 258 | '/errors/error_document.mako', {'c': c, 'h': helpers}, request=request, |
|
251 | 259 | response=base_response) |
@@ -283,6 +291,17 b' def includeme_first(config):' | |||
|
283 | 291 | '_static/rhodecode', path='rhodecode:public', cache_max_age=3600 * 24) |
|
284 | 292 | |
|
285 | 293 | |
|
294 | ce_auth_resources = [ | |
|
295 | 'rhodecode.authentication.plugins.auth_crowd', | |
|
296 | 'rhodecode.authentication.plugins.auth_headers', | |
|
297 | 'rhodecode.authentication.plugins.auth_jasig_cas', | |
|
298 | 'rhodecode.authentication.plugins.auth_ldap', | |
|
299 | 'rhodecode.authentication.plugins.auth_pam', | |
|
300 | 'rhodecode.authentication.plugins.auth_rhodecode', | |
|
301 | 'rhodecode.authentication.plugins.auth_token', | |
|
302 | ] | |
|
303 | ||
|
304 | ||
|
286 | 305 | def includeme(config, auth_resources=None): |
|
287 | 306 | from rhodecode.lib.celerylib.loader import configure_celery |
|
288 | 307 | log.debug('Initializing main includeme from %s', os.path.basename(__file__)) |
@@ -306,21 +325,14 b' def includeme(config, auth_resources=Non' | |||
|
306 | 325 | config.include('pyramid_mako') |
|
307 | 326 | config.include('rhodecode.lib.rc_beaker') |
|
308 | 327 | config.include('rhodecode.lib.rc_cache') |
|
328 | config.include('rhodecode.lib.rc_cache.archive_cache') | |
|
329 | ||
|
309 | 330 | config.include('rhodecode.apps._base.navigation') |
|
310 | 331 | config.include('rhodecode.apps._base.subscribers') |
|
311 | 332 | config.include('rhodecode.tweens') |
|
312 | 333 | config.include('rhodecode.authentication') |
|
313 | 334 | |
|
314 | 335 | if load_all: |
|
315 | ce_auth_resources = [ | |
|
316 | 'rhodecode.authentication.plugins.auth_crowd', | |
|
317 | 'rhodecode.authentication.plugins.auth_headers', | |
|
318 | 'rhodecode.authentication.plugins.auth_jasig_cas', | |
|
319 | 'rhodecode.authentication.plugins.auth_ldap', | |
|
320 | 'rhodecode.authentication.plugins.auth_pam', | |
|
321 | 'rhodecode.authentication.plugins.auth_rhodecode', | |
|
322 | 'rhodecode.authentication.plugins.auth_token', | |
|
323 | ] | |
|
324 | 336 | |
|
325 | 337 | # load CE authentication plugins |
|
326 | 338 | |
@@ -384,9 +396,6 b' def includeme(config, auth_resources=Non' | |||
|
384 | 396 | config.add_subscriber(write_js_routes_if_enabled, |
|
385 | 397 | pyramid.events.ApplicationCreated) |
|
386 | 398 | |
|
387 | # Set the authorization policy. | |
|
388 | authz_policy = ACLAuthorizationPolicy() | |
|
389 | config.set_authorization_policy(authz_policy) | |
|
390 | 399 | |
|
391 | 400 | # Set the default renderer for HTML templates to mako. |
|
392 | 401 | config.add_mako_renderer('.html') |
@@ -448,7 +457,7 b' def wrap_app_in_wsgi_middlewares(pyramid' | |||
|
448 | 457 | # In a single threaded mode server, on non sqlite db we should have |
|
449 | 458 | # '0 Current Checked out connections' at the end of a request, |
|
450 | 459 | # if not, then something, somewhere is leaving a connection open |
|
451 |
pool = meta. |
|
|
460 | pool = meta.get_engine().pool | |
|
452 | 461 | log.debug('sa pool status: %s', pool.status()) |
|
453 | 462 | total = time.time() - start |
|
454 | 463 | log.debug('Request processing finalized: %.4fs', total) |
@@ -531,7 +540,7 b' def sanitize_settings_and_apply_defaults' | |||
|
531 | 540 | |
|
532 | 541 | settings_maker.make_setting('vcs.svn.compatible_version', '') |
|
533 | 542 | settings_maker.make_setting('vcs.hooks.protocol', 'http') |
|
534 |
settings_maker.make_setting('vcs.hooks.host', ' |
|
|
543 | settings_maker.make_setting('vcs.hooks.host', '*') | |
|
535 | 544 | settings_maker.make_setting('vcs.scm_app_implementation', 'http') |
|
536 | 545 | settings_maker.make_setting('vcs.server', '') |
|
537 | 546 | settings_maker.make_setting('vcs.server.protocol', 'http') |
@@ -586,17 +595,17 b' def sanitize_settings_and_apply_defaults' | |||
|
586 | 595 | # cache_perms |
|
587 | 596 | settings_maker.make_setting('rc_cache.cache_perms.backend', 'dogpile.cache.rc.file_namespace') |
|
588 | 597 | settings_maker.make_setting('rc_cache.cache_perms.expiration_time', 60 * 60, parser='int') |
|
589 |
settings_maker.make_setting('rc_cache.cache_perms.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_perms |
|
|
598 | settings_maker.make_setting('rc_cache.cache_perms.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_perms_db')) | |
|
590 | 599 | |
|
591 | 600 | # cache_repo |
|
592 | 601 | settings_maker.make_setting('rc_cache.cache_repo.backend', 'dogpile.cache.rc.file_namespace') |
|
593 | 602 | settings_maker.make_setting('rc_cache.cache_repo.expiration_time', 60 * 60 * 24 * 30, parser='int') |
|
594 |
settings_maker.make_setting('rc_cache.cache_repo.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_repo |
|
|
603 | settings_maker.make_setting('rc_cache.cache_repo.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_repo_db')) | |
|
595 | 604 | |
|
596 | 605 | # cache_license |
|
597 | 606 | settings_maker.make_setting('rc_cache.cache_license.backend', 'dogpile.cache.rc.file_namespace') |
|
598 | 607 | settings_maker.make_setting('rc_cache.cache_license.expiration_time', 60 * 5, parser='int') |
|
599 |
settings_maker.make_setting('rc_cache.cache_license.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_license |
|
|
608 | settings_maker.make_setting('rc_cache.cache_license.arguments.filename', os.path.join(default_cache_dir, 'rhodecode_cache_license_db')) | |
|
600 | 609 | |
|
601 | 610 | # cache_repo_longterm memory, 96H |
|
602 | 611 | settings_maker.make_setting('rc_cache.cache_repo_longterm.backend', 'dogpile.cache.rc.memory_lru') |
@@ -608,6 +617,11 b' def sanitize_settings_and_apply_defaults' | |||
|
608 | 617 | settings_maker.make_setting('rc_cache.sql_cache_short.expiration_time', 30, parser='int') |
|
609 | 618 | settings_maker.make_setting('rc_cache.sql_cache_short.max_size', 10000, parser='int') |
|
610 | 619 | |
|
620 | # archive_cache | |
|
621 | settings_maker.make_setting('archive_cache.store_dir', os.path.join(default_cache_dir, 'archive_cache'), default_when_empty=True,) | |
|
622 | settings_maker.make_setting('archive_cache.cache_size_gb', 10, parser='float') | |
|
623 | settings_maker.make_setting('archive_cache.cache_shards', 10, parser='int') | |
|
624 | ||
|
611 | 625 | settings_maker.env_expand() |
|
612 | 626 | |
|
613 | 627 | # configure instance id |
@@ -94,6 +94,7 b' def inspect_getargspec():' | |||
|
94 | 94 | args, varargs, varkw = inspect.getargs(func.func_code) |
|
95 | 95 | return inspect.ArgSpec(args, varargs, varkw, func.func_defaults) |
|
96 | 96 | |
|
97 | inspect.getargspec = custom_getargspec | |
|
97 | #TODO: fix it and test it on python3.11 | |
|
98 | inspect.getargspec = inspect.getfullargspec #custom_getargspec | |
|
98 | 99 | |
|
99 | 100 | return inspect |
@@ -32,7 +32,7 b' import json' | |||
|
32 | 32 | from rhodecode.lib import diffs |
|
33 | 33 | from rhodecode.lib.vcs.backends.hg.diff import MercurialDiff |
|
34 | 34 | from rhodecode.lib.vcs.backends.git.diff import GitDiff |
|
35 |
from |
|
|
35 | from rhodecode.lib.str_utils import safe_int | |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | def get_svn_files(repo, vcs_repo, refs): |
@@ -108,7 +108,7 b' def get_git_files(repo, vcs_repo, refs):' | |||
|
108 | 108 | stdout, stderr = vcs_repo.run_git_command(cmd, extra_env=git_env) |
|
109 | 109 | vcs_diff = GitDiff(stdout) |
|
110 | 110 | |
|
111 | diff_processor = diffs.DiffProcessor(vcs_diff, format='newdiff') | |
|
111 | diff_processor = diffs.DiffProcessor(vcs_diff, diff_format='newdiff') | |
|
112 | 112 | # this is list of dicts with diff information |
|
113 | 113 | # _parsed[0].keys() |
|
114 | 114 | # ['raw_diff', 'old_revision', 'stats', 'original_filename', |
@@ -21,7 +21,9 b' import os' | |||
|
21 | 21 | import string |
|
22 | 22 | import functools |
|
23 | 23 | import collections |
|
24 |
import urllib.request |
|
|
24 | import urllib.request | |
|
25 | import urllib.parse | |
|
26 | import urllib.error | |
|
25 | 27 | |
|
26 | 28 | log = logging.getLogger('rhodecode.' + __name__) |
|
27 | 29 | |
@@ -48,7 +50,7 b' class DotDict(dict):' | |||
|
48 | 50 | def __contains__(self, k): |
|
49 | 51 | try: |
|
50 | 52 | return dict.__contains__(self, k) or hasattr(self, k) |
|
51 | except: | |
|
53 | except Exception: | |
|
52 | 54 | return False |
|
53 | 55 | |
|
54 | 56 | # only called if k not found in normal places |
@@ -153,14 +155,13 b' def maybe_log_call(name, args, kwargs):' | |||
|
153 | 155 | calls[name].append((args, kwargs)) |
|
154 | 156 | |
|
155 | 157 | |
|
156 | def str2bool(_str): | |
|
158 | def str2bool(_str) -> bool: | |
|
157 | 159 | """ |
|
158 | 160 | returns True/False value from given string, it tries to translate the |
|
159 | 161 | string into boolean |
|
160 | 162 | |
|
161 | 163 | :param _str: string value to translate into boolean |
|
162 | :rtype: boolean | |
|
163 | :returns: boolean from given string | |
|
164 | :returns: bool from given string | |
|
164 | 165 | """ |
|
165 | 166 | if _str is None: |
|
166 | 167 | return False |
@@ -24,55 +24,17 b' import functools' | |||
|
24 | 24 | import logging |
|
25 | 25 | import tempfile |
|
26 | 26 | import logging.config |
|
27 | from rhodecode.lib.type_utils import str2bool, aslist | |
|
28 | ||
|
27 | 29 | log = logging.getLogger(__name__) |
|
28 | 30 | |
|
31 | ||
|
29 | 32 | # skip keys, that are set here, so we don't double process those |
|
30 | 33 | set_keys = { |
|
31 | 34 | '__file__': '' |
|
32 | 35 | } |
|
33 | 36 | |
|
34 | 37 | |
|
35 | def str2bool(_str): | |
|
36 | """ | |
|
37 | returns True/False value from given string, it tries to translate the | |
|
38 | string into boolean | |
|
39 | ||
|
40 | :param _str: string value to translate into boolean | |
|
41 | :rtype: boolean | |
|
42 | :returns: boolean from given string | |
|
43 | """ | |
|
44 | if _str is None: | |
|
45 | return False | |
|
46 | if _str in (True, False): | |
|
47 | return _str | |
|
48 | _str = str(_str).strip().lower() | |
|
49 | return _str in ('t', 'true', 'y', 'yes', 'on', '1') | |
|
50 | ||
|
51 | ||
|
52 | def aslist(obj, sep=None, strip=True): | |
|
53 | """ | |
|
54 | Returns given string separated by sep as list | |
|
55 | ||
|
56 | :param obj: | |
|
57 | :param sep: | |
|
58 | :param strip: | |
|
59 | """ | |
|
60 | if isinstance(obj, str): | |
|
61 | if obj in ['', ""]: | |
|
62 | return [] | |
|
63 | ||
|
64 | lst = obj.split(sep) | |
|
65 | if strip: | |
|
66 | lst = [v.strip() for v in lst] | |
|
67 | return lst | |
|
68 | elif isinstance(obj, (list, tuple)): | |
|
69 | return obj | |
|
70 | elif obj is None: | |
|
71 | return [] | |
|
72 | else: | |
|
73 | return [obj] | |
|
74 | ||
|
75 | ||
|
76 | 38 | class SettingsMaker(object): |
|
77 | 39 | |
|
78 | 40 | def __init__(self, app_settings): |
@@ -87,6 +49,10 b' class SettingsMaker(object):' | |||
|
87 | 49 | return int(input_val) |
|
88 | 50 | |
|
89 | 51 | @classmethod |
|
52 | def _float_func(cls, input_val): | |
|
53 | return float(input_val) | |
|
54 | ||
|
55 | @classmethod | |
|
90 | 56 | def _list_func(cls, input_val, sep=','): |
|
91 | 57 | return aslist(input_val, sep=sep) |
|
92 | 58 | |
@@ -97,10 +63,6 b' class SettingsMaker(object):' | |||
|
97 | 63 | return input_val |
|
98 | 64 | |
|
99 | 65 | @classmethod |
|
100 | def _float_func(cls, input_val): | |
|
101 | return float(input_val) | |
|
102 | ||
|
103 | @classmethod | |
|
104 | 66 | def _dir_func(cls, input_val, ensure_dir=False, mode=0o755): |
|
105 | 67 | |
|
106 | 68 | # ensure we have our dir created |
@@ -160,7 +122,7 b' class SettingsMaker(object):' | |||
|
160 | 122 | 'file does not exist.... specify path using logging.logging_conf_file= config setting. ', logging_conf) |
|
161 | 123 | return |
|
162 | 124 | |
|
163 |
with open(logging_conf, 'r |
|
|
125 | with open(logging_conf, 'rt') as f: | |
|
164 | 126 | ini_template = textwrap.dedent(f.read()) |
|
165 | 127 | ini_template = string.Template(ini_template).safe_substitute( |
|
166 | 128 | RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or level, |
@@ -184,6 +146,7 b' class SettingsMaker(object):' | |||
|
184 | 146 | parser_func = { |
|
185 | 147 | 'bool': self._bool_func, |
|
186 | 148 | 'int': self._int_func, |
|
149 | 'float': self._float_func, | |
|
187 | 150 | 'list': self._list_func, |
|
188 | 151 | 'list:newline': functools.partial(self._list_func, sep='/n'), |
|
189 | 152 | 'list:spacesep': functools.partial(self._list_func, sep=' '), |
@@ -95,9 +95,25 b' def set_instance_id(config):' | |||
|
95 | 95 | |
|
96 | 96 | |
|
97 | 97 | def get_default_user_id(): |
|
98 | from rhodecode.model.db import User, Session | |
|
99 | user_id = Session()\ | |
|
100 | .query(User.user_id)\ | |
|
101 | .filter(User.username == User.DEFAULT_USER)\ | |
|
102 | .scalar() | |
|
98 | DEFAULT_USER = 'default' | |
|
99 | from sqlalchemy import text | |
|
100 | from rhodecode.model import meta | |
|
101 | ||
|
102 | engine = meta.get_engine() | |
|
103 | with meta.SA_Session(engine) as session: | |
|
104 | result = session.execute(text("SELECT user_id from users where username = :uname"), {'uname': DEFAULT_USER}) | |
|
105 | user_id = result.first()[0] | |
|
106 | ||
|
103 | 107 | return user_id |
|
108 | ||
|
109 | ||
|
110 | def get_default_base_path(): | |
|
111 | from sqlalchemy import text | |
|
112 | from rhodecode.model import meta | |
|
113 | ||
|
114 | engine = meta.get_engine() | |
|
115 | with meta.SA_Session(engine) as session: | |
|
116 | result = session.execute(text("SELECT ui_value from rhodecode_ui where ui_key = '/'")) | |
|
117 | base_path = result.first()[0] | |
|
118 | ||
|
119 | return base_path |
General Comments 0
You need to be logged in to leave comments.
Login now