From 8dd9d63e8f22915d0e89622acd9ca13ec94f9c5e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 11 Apr 2017 23:49:10 +0200 Subject: [PATCH] server: show progress bar when pushing git mirrors The git mirrors can be really slow to upload, so they need a progress bar. --- fdroidserver/server.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index 93ef2563..ae3d8c9a 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -315,6 +315,7 @@ def update_servergitmirrors(servergitmirrors, repo_section): ''' import git + from clint.textui import progress if config.get('local_copy_dir') \ and not config.get('sync_from_local_copy_dir'): logging.debug('Offline machine, skipping git mirror generation until `fdroid server update`') @@ -340,12 +341,27 @@ def update_servergitmirrors(servergitmirrors, repo_section): logging.info('Mirroring to: ' + mirror) # sadly index.add don't allow the --all parameter + logging.debug('Adding all files to git mirror') repo.git.add(all=True) + logging.debug('Committing all files into git mirror') repo.index.commit("fdroidserver git-mirror") + if options.verbose: + bar = progress.Bar() + + class MyProgressPrinter(git.RemoteProgress): + def update(self, op_code, current, maximum=None, message=None): + if isinstance(maximum, float): + bar.show(current, maximum) + progress = MyProgressPrinter() + else: + progress = None # push for every remote. This will overwrite the git history for remote in repo.remotes: - remote.push('master', force=True, set_upstream=True) + logging.debug('Pushing to ' + remote.url) + remote.push('master', force=True, set_upstream=True, progress=progress) + if progress: + bar.done() def upload_to_android_observatory(repo_section):