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

Commit089ab9b

Browse files
author
v.shepard
committed
PBCKP-588 fixes after review - remove f-strings
1 parent0528541 commit089ab9b

File tree

6 files changed

+37
-38
lines changed

6 files changed

+37
-38
lines changed

‎testgres/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def execute(self, query, *args):
111111

112112
returnres
113113
exceptExceptionase:
114-
print(f"Error executing query:{e}")
114+
print("Error executing query: {}".format(e))
115115
returnNone
116116

117117
defclose(self):

‎testgres/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ def safe_psql(self, query=None, expect_error=False, **kwargs):
10061006
else:
10071007
raiseQueryException(errorb'',query)
10081008
elifexpect_error:
1009-
assertFalse,f"Exception was expected, but query finished successfully: `{query}` "
1009+
assertFalse,"Exception was expected, but query finished successfully: `{}` ".format(query)
10101010

10111011
returnout
10121012

‎testgres/operations/local_ops.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False,
8484
ifexit_status!=0orfound_error:
8585
ifexit_status==0:
8686
exit_status=1
87-
raiseExecUtilException(message=f'Utility exited with non-zero code. Error `{error}`',
87+
raiseExecUtilException(message='Utility exited with non-zero code. Error `{}`'.format(error),
8888
command=cmd,
8989
exit_code=exit_status,
9090
out=result)
@@ -138,7 +138,7 @@ def pathsep(self):
138138
elifos_name=="nt":
139139
pathsep=";"
140140
else:
141-
raiseException(f"Unsupported operating system:{os_name}")
141+
raiseException("Unsupported operating system: {}".format(os_name))
142142
returnpathsep
143143

144144
defmkdtemp(self,prefix=None):
@@ -242,7 +242,7 @@ def remove_file(self, filename):
242242
# Processes control
243243
defkill(self,pid,signal):
244244
# Kill the process
245-
cmd=f"kill -{signal}{pid}"
245+
cmd="kill -{} {}".format(signal,pid)
246246
returnself.exec_command(cmd)
247247

248248
defget_pid(self):

‎testgres/operations/remote_ops.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def __init__(self, ssh, pid):
2626
self.pid=pid
2727

2828
defkill(self):
29-
command=f"kill{self.pid}"
29+
command="kill {}".format(self.pid)
3030
self.ssh.exec_command(command)
3131

3232
defcmdline(self):
33-
command=f"ps -p{self.pid} -o cmd --no-headers"
33+
command="ps -p {} -o cmd --no-headers".format(self.pid)
3434
stdin,stdout,stderr=self.ssh.exec_command(command)
3535
cmdline=stdout.read().decode('utf-8').strip()
3636
returncmdline.split()
@@ -84,9 +84,9 @@ def _read_ssh_key(self):
8484
key=paramiko.RSAKey.from_private_key_file(self.ssh_key)
8585
returnkey
8686
exceptFileNotFoundError:
87-
raiseExecUtilException(message=f"No such file or directory: '{self.ssh_key}'")
87+
raiseExecUtilException(message="No such file or directory: '{}'".format(self.ssh_key))
8888
exceptExceptionase:
89-
ExecUtilException(message=f"An error occurred while reading the ssh key:{e}")
89+
ExecUtilException(message="An error occurred while reading the ssh key: {}".format(e))
9090

9191
defexec_command(self,cmd:str,wait_exit=False,verbose=False,expect_error=False,
9292
encoding=None,shell=True,text=False,input=None,stdout=None,
@@ -131,7 +131,7 @@ def exec_command(self, cmd: str, wait_exit=False, verbose=False, expect_error=Fa
131131
iferror_found:
132132
ifexit_status==0:
133133
exit_status=1
134-
raiseExecUtilException(message=f"Utility exited with non-zero code. Error:{error.decode(encodingor'utf-8')}",
134+
raiseExecUtilException(message="Utility exited with non-zero code. Error: {}".format(error.decode(encodingor'utf-8')),
135135
command=cmd,
136136
exit_code=exit_status,
137137
out=result)
@@ -148,7 +148,7 @@ def environ(self, var_name: str) -> str:
148148
Args:
149149
- var_name (str): The name of the environment variable.
150150
"""
151-
cmd=f"echo ${var_name}"
151+
cmd="echo ${}".format(var_name)
152152
returnself.exec_command(cmd,encoding='utf-8').strip()
153153

154154
deffind_executable(self,executable):
@@ -166,7 +166,7 @@ def find_executable(self, executable):
166166

167167
defis_executable(self,file):
168168
# Check if the file is executable
169-
is_exec=self.exec_command(f"test -x{file} && echo OK")
169+
is_exec=self.exec_command("test -x {} && echo OK".format(file))
170170
returnis_exec==b"OK\n"
171171

172172
defset_env(self,var_name:str,var_val:str):
@@ -176,7 +176,7 @@ def set_env(self, var_name: str, var_val: str):
176176
- var_name (str): The name of the environment variable.
177177
- var_val (str): The value to be set for the environment variable.
178178
"""
179-
returnself.exec_command(f"export{var_name}={var_val}")
179+
returnself.exec_command("export {}={}".format(var_name,var_val))
180180

181181
# Get environment variables
182182
defget_user(self):
@@ -195,12 +195,12 @@ def makedirs(self, path, remove_existing=False):
195195
- remove_existing (bool): If True, the existing directory at the path will be removed.
196196
"""
197197
ifremove_existing:
198-
cmd=f"rm -rf{path} && mkdir -p{path}"
198+
cmd="rm -rf {} && mkdir -p {}".format(path,path)
199199
else:
200-
cmd=f"mkdir -p{path}"
200+
cmd="mkdir -p {}".format(path)
201201
exit_status,result,error=self.exec_command(cmd,verbose=True)
202202
ifexit_status!=0:
203-
raiseException(f"Couldn't create dir{path} because of error{error}")
203+
raiseException("Couldn't create dir {} because of error {}".format(path,error))
204204
returnresult
205205

206206
defrmdirs(self,path,verbose=False,ignore_errors=True):
@@ -211,7 +211,7 @@ def rmdirs(self, path, verbose=False, ignore_errors=True):
211211
- verbose (bool): If True, return exit status, result, and error.
212212
- ignore_errors (bool): If True, do not raise error if directory does not exist.
213213
"""
214-
cmd=f"rm -rf{path}"
214+
cmd="rm -rf {}".format(path)
215215
exit_status,result,error=self.exec_command(cmd,verbose=True)
216216
ifverbose:
217217
returnexit_status,result,error
@@ -224,11 +224,11 @@ def listdir(self, path):
224224
Args:
225225
path (str): The path to the directory.
226226
"""
227-
result=self.exec_command(f"ls{path}")
227+
result=self.exec_command("ls {}".format(path))
228228
returnresult.splitlines()
229229

230230
defpath_exists(self,path):
231-
result=self.exec_command(f"test -e{path}; echo $?",encoding='utf-8')
231+
result=self.exec_command("test -e {}; echo $?".format(path),encoding='utf-8')
232232
returnint(result.strip())==0
233233

234234
@property
@@ -239,7 +239,7 @@ def pathsep(self):
239239
elifos_name=="nt":
240240
pathsep=";"
241241
else:
242-
raiseException(f"Unsupported operating system:{os_name}")
242+
raiseException("Unsupported operating system: {}".format(os_name))
243243
returnpathsep
244244

245245
defmkdtemp(self,prefix=None):
@@ -249,7 +249,7 @@ def mkdtemp(self, prefix=None):
249249
- prefix (str): The prefix of the temporary directory name.
250250
"""
251251
ifprefix:
252-
temp_dir=self.exec_command(f"mktemp -d{prefix}XXXXX",encoding='utf-8')
252+
temp_dir=self.exec_command("mktemp -d {}XXXXX".format(prefix),encoding='utf-8')
253253
else:
254254
temp_dir=self.exec_command("mktemp -d",encoding='utf-8')
255255

@@ -262,7 +262,7 @@ def mkdtemp(self, prefix=None):
262262

263263
defmkstemp(self,prefix=None):
264264
ifprefix:
265-
temp_dir=self.exec_command(f"mktemp{prefix}XXXXX",encoding='utf-8')
265+
temp_dir=self.exec_command("mktemp {}XXXXX".format(prefix),encoding='utf-8')
266266
else:
267267
temp_dir=self.exec_command("mktemp",encoding='utf-8')
268268

@@ -277,8 +277,8 @@ def copytree(self, src, dst):
277277
ifnotos.path.isabs(dst):
278278
dst=os.path.join('~',dst)
279279
ifself.isdir(dst):
280-
raiseFileExistsError(f"Directory{dst} already exists.")
281-
returnself.exec_command(f"cp -r{src}{dst}")
280+
raiseFileExistsError("Directory {} already exists.".format(dst))
281+
returnself.exec_command("cp -r {} {}".format(src,dst))
282282

283283
# Work with files
284284
defwrite(self,filename,data,truncate=False,binary=False,read_and_write=False,encoding='utf-8'):
@@ -344,10 +344,10 @@ def touch(self, filename):
344344
345345
This method behaves as the 'touch' command in Unix. It's equivalent to calling 'touch filename' in the shell.
346346
"""
347-
self.exec_command(f"touch{filename}")
347+
self.exec_command("touch {}".format(filename))
348348

349349
defread(self,filename,binary=False,encoding=None):
350-
cmd=f"cat{filename}"
350+
cmd="cat {}".format(filename)
351351
result=self.exec_command(cmd,encoding=encoding)
352352

353353
ifnotbinaryandresult:
@@ -357,9 +357,9 @@ def read(self, filename, binary=False, encoding=None):
357357

358358
defreadlines(self,filename,num_lines=0,binary=False,encoding=None):
359359
ifnum_lines>0:
360-
cmd=f"tail -n{num_lines}{filename}"
360+
cmd="tail -n {} {}".format(num_lines,filename)
361361
else:
362-
cmd=f"cat{filename}"
362+
cmd="cat {}".format(filename)
363363

364364
result=self.exec_command(cmd,encoding=encoding)
365365

@@ -371,31 +371,31 @@ def readlines(self, filename, num_lines=0, binary=False, encoding=None):
371371
returnlines
372372

373373
defisfile(self,remote_file):
374-
stdout=self.exec_command(f"test -f{remote_file}; echo $?")
374+
stdout=self.exec_command("test -f {}; echo $?".format(remote_file))
375375
result=int(stdout.strip())
376376
returnresult==0
377377

378378
defisdir(self,dirname):
379-
cmd=f"if [ -d{dirname} ]; then echo True; else echo False; fi"
379+
cmd="if [ -d {} ]; then echo True; else echo False; fi".format(dirname)
380380
response=self.exec_command(cmd)
381381
returnresponse.strip()==b"True"
382382

383383
defremove_file(self,filename):
384-
cmd=f"rm{filename}"
384+
cmd="rm {}".format(filename)
385385
returnself.exec_command(cmd)
386386

387387
# Processes control
388388
defkill(self,pid,signal):
389389
# Kill the process
390-
cmd=f"kill -{signal}{pid}"
390+
cmd="kill -{} {}".format(signal,pid)
391391
returnself.exec_command(cmd)
392392

393393
defget_pid(self):
394394
# Get current process id
395395
returnint(self.exec_command("echo $$",encoding='utf-8'))
396396

397397
defget_process_children(self,pid):
398-
command=f"pgrep -P{pid}"
398+
command="pgrep -P {}".format(pid)
399399
stdin,stdout,stderr=self.ssh.exec_command(command)
400400
children=stdout.readlines()
401401
return [PsUtilProcessProxy(self.ssh,int(child_pid.strip()))forchild_pidinchildren]
@@ -437,4 +437,4 @@ def db_connect(self, dbname, user, password=None, host="127.0.0.1", port=5432, s
437437
returnconn
438438
exceptExceptionase:
439439
self.tunnel.stop()
440-
raiseExecUtilException("Could not create db tunnel.")
440+
raiseExecUtilException("Could not create db tunnel. {}".format(e))

‎testgres/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def execute_utility(args, logfile=None, verbose=False):
7272
lines= [u'\n']+ ['# '+lineforlineinout.splitlines()]+ [u'\n']
7373
tconf.os_ops.write(filename=logfile,data=lines)
7474
exceptIOError:
75-
raiseExecUtilException(f"Problem with writing to logfile `{logfile}` during run command `{args}`")
75+
raiseExecUtilException("Problem with writing to logfile `{}` during run command `{}`".format(logfile,args))
7676
ifverbose:
7777
returnexit_status,out,error
7878
else:

‎tests/test_simple_remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,8 @@ def test_pgbench(self):
750750

751751
# run TPC-B benchmark
752752
out=node.pgbench(stdout=subprocess.PIPE,
753-
stderr=subprocess.STDOUT,
754-
options=['-T3'])
755-
753+
stderr=subprocess.STDOUT,
754+
options=['-T3'])
756755
self.assertTrue(b'tps = 'inout)
757756

758757
deftest_pg_config(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp