##// END OF EJS Templates
code: flake8 fixes
super-admin -
r1063:5823ab6c python3
parent child Browse files
Show More
@@ -24,6 +24,7 b' class StatsdClientClass(Singleton):'
24 setup_run = False
24 setup_run = False
25 statsd_client = None
25 statsd_client = None
26 statsd = None
26 statsd = None
27 strict_mode_init = False
27
28
28 def __getattribute__(self, name):
29 def __getattribute__(self, name):
29
30
@@ -31,8 +32,9 b' class StatsdClientClass(Singleton):'
31 if self.setup_run:
32 if self.setup_run:
32 return super(StatsdClientClass, self).__getattribute__(name)
33 return super(StatsdClientClass, self).__getattribute__(name)
33 else:
34 else:
35 if self.strict_mode_init:
36 raise StatsdClientNotInitialised(f"requested key was {name}")
34 return None
37 return None
35 #raise StatsdClientNotInitialised("requested key was %s" % name)
36
38
37 return super(StatsdClientClass, self).__getattribute__(name)
39 return super(StatsdClientClass, self).__getattribute__(name)
38
40
@@ -40,6 +42,8 b' class StatsdClientClass(Singleton):'
40 """
42 """
41 Initialize the client
43 Initialize the client
42 """
44 """
45 strict_init_mode = settings.pop('statsd_strict_init', False)
46
43 statsd = client_from_config(settings)
47 statsd = client_from_config(settings)
44 self.statsd = statsd
48 self.statsd = statsd
45 self.statsd_client = statsd
49 self.statsd_client = statsd
@@ -40,7 +40,7 b' from dulwich.repo import Repo as Dulwich'
40 from dulwich.server import update_server_info
40 from dulwich.server import update_server_info
41
41
42 from vcsserver import exceptions, settings, subprocessio
42 from vcsserver import exceptions, settings, subprocessio
43 from vcsserver.str_utils import safe_str, safe_int
43 from vcsserver.str_utils import safe_str, safe_int, safe_bytes
44 from vcsserver.base import RepoFactory, obfuscate_qs, ArchiveNode, archive_repo
44 from vcsserver.base import RepoFactory, obfuscate_qs, ArchiveNode, archive_repo
45 from vcsserver.hgcompat import (
45 from vcsserver.hgcompat import (
46 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
46 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
@@ -824,12 +824,12 b' class GitRemote(RemoteBase):'
824
824
825 @reraise_safe_exceptions
825 @reraise_safe_exceptions
826 def init(self, wire):
826 def init(self, wire):
827 repo_path = str_to_dulwich(wire['path'])
827 repo_path = safe_str(wire['path'])
828 self.repo = Repo.init(repo_path)
828 self.repo = Repo.init(repo_path)
829
829
830 @reraise_safe_exceptions
830 @reraise_safe_exceptions
831 def init_bare(self, wire):
831 def init_bare(self, wire):
832 repo_path = str_to_dulwich(wire['path'])
832 repo_path = safe_str(wire['path'])
833 self.repo = Repo.init_bare(repo_path)
833 self.repo = Repo.init_bare(repo_path)
834
834
835 @reraise_safe_exceptions
835 @reraise_safe_exceptions
@@ -52,7 +52,7 b' class FileLikeObj(object): # pragma: no'
52 def environ():
52 def environ():
53 """Delete coverage variables, as they make the tests fail."""
53 """Delete coverage variables, as they make the tests fail."""
54 env = dict(os.environ)
54 env = dict(os.environ)
55 for key in env.keys():
55 for key in list(env.keys()):
56 if key.startswith('COV_CORE_'):
56 if key.startswith('COV_CORE_'):
57 del env[key]
57 del env[key]
58
58
@@ -29,7 +29,7 b' def demo_app(environ, start_response):'
29 input_data = safe_str(environ['wsgi.input'].read(1024))
29 input_data = safe_str(environ['wsgi.input'].read(1024))
30
30
31 data = [
31 data = [
32 f'Hello World!\n',
32 'Hello World!\n',
33 f'input_data={input_data}\n',
33 f'input_data={input_data}\n',
34 ]
34 ]
35 for key, value in sorted(environ.items()):
35 for key, value in sorted(environ.items()):
General Comments 0
You need to be logged in to leave comments. Login now