aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/binrepo.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py
index 874a091..d96507c 100644
--- a/MgaRepo/binrepo.py
+++ b/MgaRepo/binrepo.py
@@ -2,6 +2,7 @@ from MgaRepo import Error, config, mirror, layout
from MgaRepo.util import execcmd, rellink, get_helper
from MgaRepo.svn import SVN
+from tqdm import tqdm
import sys
import os
import string
@@ -11,8 +12,8 @@ import re
import tempfile
import hashlib
import urllib.parse
-import threading
import httplib2
+import subprocess
from io import StringIO
@@ -101,13 +102,31 @@ def upload_binary(topdir, filename):
if binary_exists(sha1sum):
return
host = config.get("binrepo", "upload_host")
+ # upload_bin_helper by default: /usr/local/bin/wrapper.upload-bin
upload_bin_helper = get_helper("upload-bin")
- command = "ssh %s %s %s" % (host, upload_bin_helper, filename)
+ command = ["ssh", host, upload_bin_helper, filename]
try:
- filein = open(filepath, 'r')
+ b = os.path.getsize(filepath)
except Error as e:
raise Error("Could not open file %s\n" % filepath)
- status, output = execcmd(command, show=True, geterr=True, stdin=filein)
+ with open(filepath, "rb") as f:
+ # file is sent chunk by chunk to allow displaying of a progress bar
+ bs = 4096 * 128
+ written = 0
+ ncuts = int(b / bs)
+ pbar = tqdm(total=b, unit='B', unit_scale=True, unit_divisor=1024, desc=filename)
+ while ncuts <= 100:
+ bs = int(bs / 2)
+ ncuts = int(b / bs)
+ p = subprocess.Popen(command, stdin=subprocess.PIPE)
+ for i in range(0, int(ncuts) + 1):
+ buf = f.read(bs)
+ p.stdin.write(buf)
+ written += len(buf)
+ pbar.update(len(buf))
+ p.stdin.flush()
+ pbar.close()
+ p.communicate()
def import_binaries(topdir, pkgname):
"""Import all binaries from a given package checkout