Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec9a615

Browse files
author
vshepard
committed
Safe group from re.search
1 parent665f5d3 commitec9a615

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

‎testgres/plugins/pg_probackup2/pg_probackup2/init_helpers.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,24 @@ def __init__(self):
148148
[self.probackup_path,"--version"],
149149
stderr=subprocess.STDOUT,
150150
).decode('utf-8')
151-
self.probackup_version=re.search(r"\d+\.\d+\.\d+",
152-
probackup_version_output
153-
).group(0)
154-
compressions=re.search(r"\(compressions: ([^)]*)\)",
155-
probackup_version_output).group(1)
156-
self.probackup_compressions= {s.strip()forsincompressions.split(',')}
151+
match=re.search(r"\d+\.\d+\.\d+",
152+
probackup_version_output)
153+
self.probackup_version=match.group(0)ifmatchelseNone
154+
match=re.search(r"\(compressions: ([^)]*)\)",probackup_version_output)
155+
compressions=match.group(1)ifmatchelseNone
156+
ifcompressions:
157+
self.probackup_compressions= {s.strip()forsincompressions.split(',')}
158+
else:
159+
self.probackup_compressions= []
157160

158161
ifself.probackup_old_path:
159162
old_probackup_version_output=subprocess.check_output(
160163
[self.probackup_old_path,"--version"],
161164
stderr=subprocess.STDOUT,
162165
).decode('utf-8')
163-
self.old_probackup_version=re.search(r"\d+\.\d+\.\d+",
164-
old_probackup_version_output
165-
).group(0)
166+
match=re.search(r"\d+\.\d+\.\d+",
167+
old_probackup_version_output)
168+
self.old_probackup_version=match.group(0)ifmatchelseNone
166169

167170
self.remote=test_env.get('PGPROBACKUP_SSH_REMOTE',None)=='ON'
168171
self.ptrack=test_env.get('PG_PROBACKUP_PTRACK',None)=='ON'andself.pg_config_version>=110000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp