Skip to content

Commit de24f6a

Browse files
committed
added progressbar
1 parent 0e501a6 commit de24f6a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

docksing.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import time
1919
import 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
2325
class 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,

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
setup(
77
name="docksing",
8-
version="0.2.35",
8+
version="0.2.36",
99
description="CLI Utility for deployment of containerized jobs on SLURM HPC ",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",
1212
author="G. Angelotti",
13-
author_email="giovanni.angelotti@idsia.ch",
13+
author_emairel="giovanni.angelotti@idsia.ch",
1414
py_modules=["docksing"],
1515
install_requires=[
1616
"paramiko==3.4.0",

0 commit comments

Comments
 (0)