1818import time
1919import cmd
2020
21+ def progress (filename , size , sent ):
22+ sys .stdout .write ("%s\' s progress: %.2f%% \r " % (filename , float (sent )/ float (size )* 100 ) )
2123
2224@dataclass
2325class CLICompose :
@@ -200,7 +202,6 @@ def push(self,tag:str,remotedir:str):
200202 tag (str): Name of the target image tag.
201203 remotedir (str): Absolute path of working directory on host.
202204 """
203-
204205 image = self .docker .images .get (tag )
205206 iid = image .short_id .split (":" )[1 ]
206207 with io .BytesIO () as file :
@@ -209,7 +210,7 @@ def push(self,tag:str,remotedir:str):
209210 file .seek (0 )
210211
211212 if self .ssh :
212- with SCPClient (self .ssh .get_transport ()) as scp :
213+ with SCPClient (self .ssh .get_transport (), progress = progress ) as scp :
213214 scp .putfo (file ,f"{ remotedir } /{ iid } .tar" )
214215 else :
215216 with open (f"{ remotedir } /{ iid } .tar" ,"wb" ) as f :
@@ -240,7 +241,7 @@ def map_remote_volume(self,remote_dir:str,local_dir:str,container_dir:str,send_p
240241 if send_payload and Path (local_dir ).is_dir ():
241242 # If the mapping points to an existing local folder,
242243 # we copy its content in remote_dir/local_host
243- with SCPClient (self .ssh .get_transport ()) as scp :
244+ with SCPClient (self .ssh .get_transport (), progress = progress ) as scp :
244245 scp .put (
245246 local_dir ,
246247 remote_path = remote_dir ,
0 commit comments