Show More
@@ -72,7 +72,7 b' class SettingsMaker(object):' | |||
|
72 | 72 | os.makedirs(input_val, mode=mode, exist_ok=True) |
|
73 | 73 | |
|
74 | 74 | if not os.path.isdir(input_val): |
|
75 |
raise Exception('Dir at {} does not exist' |
|
|
75 | raise Exception(f'Dir at {input_val} does not exist') | |
|
76 | 76 | return input_val |
|
77 | 77 | |
|
78 | 78 | @classmethod |
@@ -212,7 +212,7 b' def lfs_objects_verify(request):' | |||
|
212 | 212 | |
|
213 | 213 | store_size = store.size_oid() |
|
214 | 214 | if store_size != size: |
|
215 |
msg = 'requested file size mismatch store size: |
|
|
215 | msg = 'requested file size mismatch store size:{} requested:{}'.format( | |
|
216 | 216 | store_size, size) |
|
217 | 217 | return write_response_error( |
|
218 | 218 | HTTPUnprocessableEntity, msg) |
@@ -51,7 +51,7 b' class OidHandler(object):' | |||
|
51 | 51 | |
|
52 | 52 | if not store.has_oid(): |
|
53 | 53 | # error reply back to client that something is wrong with dl |
|
54 |
err_msg = 'object: { |
|
|
54 | err_msg = f'object: {store.oid} does not exist in store' | |
|
55 | 55 | has_errors = OrderedDict( |
|
56 | 56 | error=OrderedDict( |
|
57 | 57 | code=404, |
@@ -75,7 +75,7 b' def install_git_hooks(repo_path, bare, e' | |||
|
75 | 75 | template = template.replace(b'_PATH_', safe_bytes(path)) |
|
76 | 76 | f.write(template) |
|
77 | 77 | os.chmod(_hook_file, 0o755) |
|
78 |
except |
|
|
78 | except OSError: | |
|
79 | 79 | log.exception('error writing hook file %s', _hook_file) |
|
80 | 80 | else: |
|
81 | 81 | log.debug('skipping writing hook file') |
@@ -129,7 +129,7 b' def install_svn_hooks(repo_path, executa' | |||
|
129 | 129 | |
|
130 | 130 | f.write(template) |
|
131 | 131 | os.chmod(_hook_file, 0o755) |
|
132 |
except |
|
|
132 | except OSError: | |
|
133 | 133 | log.exception('error writing hook file %s', _hook_file) |
|
134 | 134 | else: |
|
135 | 135 | log.debug('skipping writing hook file') |
@@ -84,7 +84,7 b' class JsonEncoder(json.JSONEncoder):' | |||
|
84 | 84 | return str(obj) |
|
85 | 85 | |
|
86 | 86 | try: |
|
87 |
return super( |
|
|
87 | return super().default(obj) | |
|
88 | 88 | |
|
89 | 89 | except TypeError: |
|
90 | 90 | try: |
@@ -200,7 +200,7 b' class JsonFormatter(ExceptionAwareFormat' | |||
|
200 | 200 | |
|
201 | 201 | def serialize_log_record(self, log_record): |
|
202 | 202 | """Returns the final representation of the log record.""" |
|
203 |
return " |
|
|
203 | return "{}{}".format(self.prefix, self.jsonify_log_record(log_record)) | |
|
204 | 204 | |
|
205 | 205 | def format(self, record): |
|
206 | 206 | """Formats a log record and serializes to json""" |
@@ -219,7 +219,7 b' class Lock(object):' | |||
|
219 | 219 | |
|
220 | 220 | if self._held: |
|
221 | 221 | owner_id = self.get_owner_id() |
|
222 |
raise AlreadyAcquired("Already acquired from this Lock instance. Lock id: {}" |
|
|
222 | raise AlreadyAcquired(f"Already acquired from this Lock instance. Lock id: {owner_id}") | |
|
223 | 223 | |
|
224 | 224 | if not blocking and timeout is not None: |
|
225 | 225 | raise TimeoutNotUsable("Timeout cannot be used if blocking=False") |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | |
|
5 | 3 | from .stream import TCPStatsClient, UnixSocketStatsClient # noqa |
@@ -1,5 +1,3 b'' | |||
|
1 | ||
|
2 | ||
|
3 | 1 |
|
|
4 | 2 | |
|
5 | 3 | from .base import StatsClientBase, PipelineBase |
@@ -8,7 +6,7 b' from .base import StatsClientBase, Pipel' | |||
|
8 | 6 | class Pipeline(PipelineBase): |
|
9 | 7 | |
|
10 | 8 | def __init__(self, client): |
|
11 |
super( |
|
|
9 | super().__init__(client) | |
|
12 | 10 | self._maxudpsize = client._maxudpsize |
|
13 | 11 | |
|
14 | 12 | def _send(self): |
@@ -43,7 +43,7 b' class ColorFormatter(logging.Formatter):' | |||
|
43 | 43 | """ |
|
44 | 44 | Change record's levelname to use with COLORS enum |
|
45 | 45 | """ |
|
46 |
def_record = super( |
|
|
46 | def_record = super().format(record) | |
|
47 | 47 | |
|
48 | 48 | levelname = record.levelname |
|
49 | 49 | start = COLOR_SEQ % (COLORS[levelname]) |
@@ -51,11 +51,11 b' class LRUDictDebug(LRUDict):' | |||
|
51 | 51 | Wrapper to provide some debug options |
|
52 | 52 | """ |
|
53 | 53 | def _report_keys(self): |
|
54 |
elems_cnt = '{ |
|
|
54 | elems_cnt = f'{len(list(self.keys()))}/{self.size}' | |
|
55 | 55 | # trick for pformat print it more nicely |
|
56 | 56 | fmt = '\n' |
|
57 | 57 | for cnt, elem in enumerate(self.keys()): |
|
58 |
fmt += '{ |
|
|
58 | fmt += f'{cnt+1} - {safe_str(elem)}\n' | |
|
59 | 59 | log.debug('current LRU keys (%s):%s', elems_cnt, fmt) |
|
60 | 60 | |
|
61 | 61 | def __getitem__(self, key): |
@@ -173,7 +173,7 b' def get_or_create_region(region_name, re' | |||
|
173 | 173 | region_obj = region_meta.dogpile_cache_regions.get(region_name) |
|
174 | 174 | if not region_obj: |
|
175 | 175 | reg_keys = list(region_meta.dogpile_cache_regions.keys()) |
|
176 |
raise |
|
|
176 | raise OSError(f'Region `{region_name}` not in configured: {reg_keys}.') | |
|
177 | 177 | |
|
178 | 178 | region_uid_name = f'{region_name}:{region_namespace}' |
|
179 | 179 |
@@ -483,7 +483,7 b' class GitRemote(RemoteBase):' | |||
|
483 | 483 | |
|
484 | 484 | q = {"service": 'git-upload-pack'} |
|
485 | 485 | qs = '?%s' % urllib.parse.urlencode(q) |
|
486 |
cu = "{}{}" |
|
|
486 | cu = f"{test_uri}{qs}" | |
|
487 | 487 | req = urllib.request.Request(cu, None, {}) |
|
488 | 488 | |
|
489 | 489 | try: |
@@ -494,7 +494,7 b' class GitRemote(RemoteBase):' | |||
|
494 | 494 | except Exception as e: |
|
495 | 495 | log.warning("URL cannot be opened: %s", obfuscated_uri, exc_info=True) |
|
496 | 496 | # means it cannot be cloned |
|
497 |
raise exceptions.URLError(e)("[{}] org_exc: {}" |
|
|
497 | raise exceptions.URLError(e)(f"[{obfuscated_uri}] org_exc: {e}") | |
|
498 | 498 | |
|
499 | 499 | # now detect if it's proper git repo |
|
500 | 500 | gitdata: bytes = resp.read() |
@@ -464,7 +464,7 b' class HgRemote(RemoteBase):' | |||
|
464 | 464 | q = {"cmd": 'between'} |
|
465 | 465 | q.update({'pairs': "{}-{}".format('0' * 40, '0' * 40)}) |
|
466 | 466 | qs = '?%s' % urllib.parse.urlencode(q) |
|
467 |
cu = "{}{}" |
|
|
467 | cu = f"{test_uri}{qs}" | |
|
468 | 468 | req = urllib.request.Request(cu, None, {}) |
|
469 | 469 | |
|
470 | 470 | try: |
@@ -475,7 +475,7 b' class HgRemote(RemoteBase):' | |||
|
475 | 475 | except Exception as e: |
|
476 | 476 | log.warning("URL cannot be opened: %s", obfuscated_uri, exc_info=True) |
|
477 | 477 | # means it cannot be cloned |
|
478 |
raise exceptions.URLError(e)("[{}] org_exc: {}" |
|
|
478 | raise exceptions.URLError(e)(f"[{obfuscated_uri}] org_exc: {e}") | |
|
479 | 479 | |
|
480 | 480 | # now check if it's a proper hg repo, but don't do it for svn |
|
481 | 481 | try: |
@@ -42,11 +42,11 b' class StreamFeeder(threading.Thread):' | |||
|
42 | 42 | """ |
|
43 | 43 | |
|
44 | 44 | def __init__(self, source): |
|
45 |
super( |
|
|
45 | super().__init__() | |
|
46 | 46 | self.daemon = True |
|
47 | 47 | filelike = False |
|
48 |
self.bytes = b |
|
|
49 |
if type(source) in ( |
|
|
48 | self.bytes = b'' | |
|
49 | if type(source) in (str, bytes, bytearray): # string-like | |
|
50 | 50 | self.bytes = bytes(source) |
|
51 | 51 | else: # can be either file pointer or file-like |
|
52 | 52 | if isinstance(source, int): # file pointer it is |
@@ -85,7 +85,7 b' class StreamFeeder(threading.Thread):' | |||
|
85 | 85 | class InputStreamChunker(threading.Thread): |
|
86 | 86 | def __init__(self, source, target, buffer_size, chunk_size): |
|
87 | 87 | |
|
88 |
super( |
|
|
88 | super().__init__() | |
|
89 | 89 | |
|
90 | 90 | self.daemon = True # die die die. |
|
91 | 91 | |
@@ -440,7 +440,7 b' class SubprocessIOChunker(object):' | |||
|
440 | 440 | elif err and fail_on_stderr: |
|
441 | 441 | text_err = err.decode() |
|
442 | 442 | raise OSError( |
|
443 |
"Subprocess exited due to an error:\n{}" |
|
|
443 | f"Subprocess exited due to an error:\n{text_err}") | |
|
444 | 444 | |
|
445 | 445 | if ret_code_fail and fail_on_return_code: |
|
446 | 446 | text_err = err.decode() |
@@ -449,7 +449,7 b' class SubprocessIOChunker(object):' | |||
|
449 | 449 | # in many cases git reports the errors on stdout too |
|
450 | 450 | text_err = out.decode() |
|
451 | 451 | raise OSError( |
|
452 |
"Subprocess exited with non 0 ret code:{}: stderr:{}" |
|
|
452 | f"Subprocess exited with non 0 ret code:{return_code}: stderr:{text_err}") | |
|
453 | 453 | |
|
454 | 454 | self.stdout = bg_out |
|
455 | 455 | self.stderr = bg_err |
@@ -482,7 +482,7 b' class SubprocessIOChunker(object):' | |||
|
482 | 482 | self.stop_streams() |
|
483 | 483 | err = self.get_stderr() |
|
484 | 484 | raise OSError( |
|
485 |
"Subprocess exited (exit_code:{}) due to an error during iteration:\n{}" |
|
|
485 | f"Subprocess exited (exit_code:{return_code}) due to an error during iteration:\n{err}") | |
|
486 | 486 | |
|
487 | 487 | if stop_iteration: |
|
488 | 488 | raise stop_iteration |
@@ -103,15 +103,15 b' class RequestWrapperTween(object):' | |||
|
103 | 103 | statsd.timing( |
|
104 | 104 | "vcsserver_req_timing.histogram", elapsed_time_ms, |
|
105 | 105 | tags=[ |
|
106 |
"view_name:{}" |
|
|
107 |
"code:{}" |
|
|
106 | f"view_name:{match_route}", | |
|
107 | f"code:{resp_code}" | |
|
108 | 108 | ], |
|
109 | 109 | use_decimals=False |
|
110 | 110 | ) |
|
111 | 111 | statsd.incr( |
|
112 | 112 | "vcsserver_req_total", tags=[ |
|
113 |
"view_name:{}" |
|
|
114 |
"code:{}" |
|
|
113 | f"view_name:{match_route}", | |
|
114 | f"code:{resp_code}" | |
|
115 | 115 | ]) |
|
116 | 116 | |
|
117 | 117 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now