##// END OF EJS Templates
ruff: code-cleanups
super-admin -
r1100:bb0b5a8e python3
parent child Browse files
Show More
@@ -164,7 +164,7 b' class SettingsMaker(object):'
164 164 'file does not exist.... specify path using logging.logging_conf_file= config setting. ', logging_conf)
165 165 return
166 166
167 with open(logging_conf, 'rb') as f:
167 with open(logging_conf, 'rt') as f:
168 168 ini_template = textwrap.dedent(f.read())
169 169 ini_template = string.Template(ini_template).safe_substitute(
170 170 RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or level,
@@ -75,6 +75,7 b' def _store_exception(exc_id, exc_info, p'
75 75 detailed_tb = getattr(exc_value, '_org_exc_tb', None)
76 76
77 77 if detailed_tb:
78 remote_tb = detailed_tb
78 79 if isinstance(detailed_tb, str):
79 80 remote_tb = [detailed_tb]
80 81
@@ -16,7 +16,9 b''
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 18 import logging
19
19 20 from dogpile.cache import register_backend
21
20 22 module_name = 'vcsserver'
21 23
22 24 register_backend(
@@ -40,8 +42,12 b' log = logging.getLogger(__name__)'
40 42
41 43 from . import region_meta
42 44 from .utils import (
43 get_default_cache_settings, backend_key_generator, get_or_create_region,
44 clear_cache_namespace, make_region)
45 backend_key_generator,
46 clear_cache_namespace,
47 get_default_cache_settings,
48 get_or_create_region,
49 make_region,
50 )
45 51
46 52
47 53 def configure_dogpile_cache(settings):
@@ -15,30 +15,29 b''
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 import errno
19 import fcntl
20 import functools
21 import logging
22 import pickle
18 23 import time
19 import errno
20 import logging
21 import functools
22 24
23 25 import msgpack
24 26 import redis
25 import pickle
26 import fcntl
27
27 28 flock_org = fcntl.flock
28 29 from typing import Union
29 30
31 from dogpile.cache.api import Deserializer, Serializer
32 from dogpile.cache.backends import file as file_backend
30 33 from dogpile.cache.backends import memory as memory_backend
31 from dogpile.cache.backends import file as file_backend
32 34 from dogpile.cache.backends import redis as redis_backend
33 35 from dogpile.cache.backends.file import FileLock
34 36 from dogpile.cache.util import memoized_property
35 from dogpile.cache.api import Serializer, Deserializer
36
37 37 from pyramid.settings import asbool
38 38
39 39 from vcsserver.lib.memory_lru_dict import LRUDict, LRUDictDebug
40 from vcsserver.str_utils import safe_str, safe_bytes
41
40 from vcsserver.str_utils import safe_bytes, safe_str
42 41
43 42 _default_max_size = 1024
44 43
@@ -15,17 +15,17 b''
15 15 # along with this program; if not, write to the Free Software Foundation,
16 16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 17
18 import functools
19 import logging
18 20 import os
19 21 import time
20 import logging
21 import functools
22
22 23 import decorator
23
24 24 from dogpile.cache import CacheRegion
25 25
26 from vcsserver.lib.rc_cache import region_meta
26 27 from vcsserver.str_utils import safe_bytes
27 28 from vcsserver.utils import sha1
28 from vcsserver.lib.rc_cache import region_meta
29 29
30 30 log = logging.getLogger(__name__)
31 31
@@ -41,7 +41,7 b' class RhodeCodeCacheRegion(CacheRegion):'
41 41 condition=True):
42 42 """
43 43 Custom conditional decorator, that will not touch any dogpile internals if
44 condition isn't meet. This works a bit different than should_cache_fn
44 condition isn't meet. This works a bit different from should_cache_fn
45 45 And it's faster in cases we don't ever want to compute cached values
46 46 """
47 47 expiration_time_is_callable = callable(expiration_time)
@@ -150,7 +150,7 b' def key_generator(backend, namespace, fn'
150 150 backend_prefix = getattr(backend, 'key_prefix', None) or 'backend_prefix'
151 151 namespace_pref = namespace or 'default_namespace'
152 152 arg_key = compute_key_from_params(*args)
153 final_key = "{}:{}:{}_{}".format(backend_prefix, namespace_pref, fname, arg_key)
153 final_key = f"{backend_prefix}:{namespace_pref}:{fname}_{arg_key}"
154 154
155 155 return final_key
156 156
@@ -1,3 +1,20 b''
1 # RhodeCode VCSServer provides access to different vcs backends via network.
2 # Copyright (C) 2014-2020 RhodeCode GmbH
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software Foundation,
16 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
1 18 from vcsserver.lib._vendor.statsd import client_from_config
2 19
3 20
@@ -70,7 +70,7 b' def reraise_safe_exceptions(func):'
70 70 exc = exceptions.VcsException(org_exc=e)
71 71 raise exc(safe_str(e))
72 72 except Exception as e:
73 # NOTE(marcink): becuase of how dulwich handles some exceptions
73 # NOTE(marcink): because of how dulwich handles some exceptions
74 74 # (KeyError on empty repos), we cannot track this and catch all
75 75 # exceptions, it's an exceptions from other handlers
76 76 #if not hasattr(e, '_vcs_kind'):
@@ -422,6 +422,7 b' class GitRemote(RemoteBase):'
422 422 def branch(self, wire, commit_id):
423 423 cache_on, context_uid, repo_id = self._cache_on(wire)
424 424 region = self._region(wire)
425
425 426 @region.conditional_cache_on_arguments(condition=cache_on)
426 427 def _branch(_context_uid, _repo_id, _commit_id):
427 428 regex = re.compile('^refs/heads')
@@ -438,6 +439,7 b' class GitRemote(RemoteBase):'
438 439 def commit_branches(self, wire, commit_id):
439 440 cache_on, context_uid, repo_id = self._cache_on(wire)
440 441 region = self._region(wire)
442
441 443 @region.conditional_cache_on_arguments(condition=cache_on)
442 444 def _commit_branches(_context_uid, _repo_id, _commit_id):
443 445 repo_init = self._factory.repo_libgit2(wire)
@@ -658,7 +660,7 b' class GitRemote(RemoteBase):'
658 660 repo[HEAD_MARKER] = remote_refs[refs[-1]]
659 661
660 662 if update_after:
661 # we want to checkout HEAD
663 # we want to check out HEAD
662 664 repo[HEAD_MARKER] = remote_refs[HEAD_MARKER]
663 665 index.build_index_from_tree(repo.path, repo.index_path(),
664 666 repo.object_store, repo[HEAD_MARKER].tree)
@@ -944,6 +946,7 b' class GitRemote(RemoteBase):'
944 946 def message(self, wire, commit_id):
945 947 cache_on, context_uid, repo_id = self._cache_on(wire)
946 948 region = self._region(wire)
949
947 950 @region.conditional_cache_on_arguments(condition=cache_on)
948 951 def _message(_repo_id, _commit_id):
949 952 repo_init = self._factory.repo_libgit2(wire)
@@ -1183,7 +1186,7 b' class GitRemote(RemoteBase):'
1183 1186
1184 1187 @reraise_safe_exceptions
1185 1188 def node_annotate_legacy(self, wire, commit_id, path):
1186 #note: replaced by pygit2 impelementation
1189 # note: replaced by pygit2 implementation
1187 1190 cmd = ['blame', '-l', '--root', '-r', commit_id, '--', path]
1188 1191 # -l ==> outputs long shas (and we need all 40 characters)
1189 1192 # --root ==> doesn't put '^' character for boundaries
@@ -28,12 +28,13 b' import urllib.parse'
28 28 import urllib.error
29 29 import traceback
30 30
31 import svn.client
32 import svn.core
33 import svn.delta
34 import svn.diff
35 import svn.fs
36 import svn.repos
31
32 import svn.client # noqa
33 import svn.core # noqa
34 import svn.delta # noqa
35 import svn.diff # noqa
36 import svn.fs # noqa
37 import svn.repos # noqa
37 38
38 39 from vcsserver import svn_diff, exceptions, subprocessio, settings
39 40 from vcsserver.base import RepoFactory, raise_from_original, ArchiveNode, archive_repo, BinaryEnvelope
@@ -274,6 +275,7 b' class SvnRemote(RemoteBase):'
274 275 def node_properties(self, wire, path, revision):
275 276 cache_on, context_uid, repo_id = self._cache_on(wire)
276 277 region = self._region(wire)
278
277 279 @region.conditional_cache_on_arguments(condition=cache_on)
278 280 def _node_properties(_repo_id, _path, _revision):
279 281 repo = self._factory.repo(wire)
@@ -313,6 +315,7 b' class SvnRemote(RemoteBase):'
313 315
314 316 cache_on, context_uid, repo_id = self._cache_on(wire)
315 317 region = self._region(wire)
318
316 319 @region.conditional_cache_on_arguments(condition=cache_on)
317 320 def _get_node_type(_repo_id, _path, _revision):
318 321 repo = self._factory.repo(wire)
General Comments 0
You need to be logged in to leave comments. Login now