@@ -300,7 +300,7 @@ def exec_command(self, cmd):
300300 # retry for up to 3 times
301301 # ensure alive
302302 self .ensure_alive ()
303- raise RetrySignal ("SSH session not active in calling %s" % cmd ) from e
303+ raise RetrySignal (f "SSH session not active in calling { cmd } " ) from e
304304
305305 @property
306306 def sftp (self ):
@@ -628,8 +628,7 @@ def upload(
628628 # check sha256
629629 # `:` means pass: https://stackoverflow.com/a/2421592/9567349
630630 _ , stdout , _ = self .block_checkcall (
631- "sha256sum -c %s --quiet >.sha256sum_stdout 2>/dev/null || :"
632- % shlex .quote (sha256_file )
631+ f"sha256sum -c { shlex .quote (sha256_file )} --quiet >.sha256sum_stdout 2>/dev/null || :"
633632 )
634633 self .sftp .remove (sha256_file )
635634 # regenerate file list
@@ -708,7 +707,7 @@ def download(
708707 os .path .join (
709708 self .local_root ,
710709 ii .task_work_path ,
711- "tag_failure_download_%s" % jj ,
710+ f "tag_failure_download_{ jj } " ,
712711 ),
713712 "w" ,
714713 ) as fp :
@@ -758,9 +757,9 @@ def block_checkcall(self, cmd, asynchronously=False, stderr_whitelist=None):
758757 assert self .remote_root is not None
759758 self .ssh_session .ensure_alive ()
760759 if asynchronously :
761- cmd = "nohup %s >/dev/null &" % cmd
760+ cmd = f "nohup { cmd } >/dev/null &"
762761 stdin , stdout , stderr = self .ssh_session .exec_command (
763- ("cd %s ;" % shlex .quote (self .remote_root )) + cmd
762+ (f "cd { shlex .quote (self .remote_root )} ;" ) + cmd
764763 )
765764 exit_status = stdout .channel .recv_exit_status ()
766765 if exit_status != 0 :
@@ -779,7 +778,7 @@ def block_call(self, cmd):
779778 assert self .remote_root is not None
780779 self .ssh_session .ensure_alive ()
781780 stdin , stdout , stderr = self .ssh_session .exec_command (
782- ("cd %s ;" % shlex .quote (self .remote_root )) + cmd
781+ (f "cd { shlex .quote (self .remote_root )} ;" ) + cmd
783782 )
784783 exit_status = stdout .channel .recv_exit_status ()
785784 return exit_status , stdin , stdout , stderr
@@ -846,12 +845,12 @@ def _rmtree(self, remotepath, verbose=False):
846845 # Thus, it's better to use system's `rm` to remove a directory, which may
847846 # save a lot of time.
848847 if verbose :
849- dlog .info ("removing %s" % remotepath )
848+ dlog .info (f "removing { remotepath } " )
850849 # In some supercomputers, it's very slow to remove large numbers of files
851850 # (e.g. directory containing trajectory) due to bad I/O performance.
852851 # So an asynchronously option is provided.
853852 self .block_checkcall (
854- "rm -rf %s" % shlex .quote (remotepath ),
853+ f "rm -rf { shlex .quote (remotepath )} " ,
855854 asynchronously = self .clean_asynchronously ,
856855 )
857856
@@ -921,7 +920,7 @@ def _put_files(
921920 f"from { from_f } to { self .ssh_session .username } @ { self .ssh_session .hostname } : { to_f } Error!"
922921 )
923922 # remote extract
924- self .block_checkcall ("tar xf %s" % of )
923+ self .block_checkcall (f "tar xf { of } " )
925924 # clean up
926925 os .remove (from_f )
927926 self .sftp .remove (to_f )
0 commit comments