mirror of
https://github.com/YunoHost/apps.git
synced 2024-09-03 20:06:07 +02:00
Quiet clones and fetchs, fancy progress bar
This commit is contained in:
parent
7c9b2614d7
commit
29c08d34bd
1 changed files with 26 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
@ -17,6 +18,27 @@ my_env["GIT_TERMINAL_PROMPT"] = "0"
|
||||||
os.makedirs(".apps_cache", exist_ok=True)
|
os.makedirs(".apps_cache", exist_ok=True)
|
||||||
os.makedirs("builds/", exist_ok=True)
|
os.makedirs("builds/", exist_ok=True)
|
||||||
|
|
||||||
|
def error(msg):
|
||||||
|
msg = "[Applist builder error] " + msg
|
||||||
|
if os.path.exists("/usr/bin/sendxmpppy"):
|
||||||
|
subprocess.call(["sendxmpppy", msg], stdout=open(os.devnull, 'wb'))
|
||||||
|
print(msg + "\n")
|
||||||
|
|
||||||
|
# Progress bar helper, stolen from https://stackoverflow.com/a/34482761
|
||||||
|
def progressbar(it, prefix="", size=60, file=sys.stdout):
|
||||||
|
count = len(it)
|
||||||
|
def show(j, name=""):
|
||||||
|
name += " "
|
||||||
|
x = int(size*j/count)
|
||||||
|
file.write("%s[%s%s] %i/%i %s\r" % (prefix, "#"*x, "."*(size-x), j, count, name))
|
||||||
|
file.flush()
|
||||||
|
show(0)
|
||||||
|
for i, item in enumerate(it):
|
||||||
|
yield item
|
||||||
|
show(i+1, item[0])
|
||||||
|
file.write("\n")
|
||||||
|
file.flush()
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# App git clones cache management #
|
# App git clones cache management #
|
||||||
###################################
|
###################################
|
||||||
|
@ -35,9 +57,8 @@ def git(cmd, in_folder=None):
|
||||||
|
|
||||||
def refresh_all_caches():
|
def refresh_all_caches():
|
||||||
|
|
||||||
for app, infos in catalog.items():
|
for app, infos in progressbar(catalog.items(), "Updating git clones: ", 40):
|
||||||
app = app.lower()
|
app = app.lower()
|
||||||
print(app)
|
|
||||||
if not os.path.exists(app_cache_folder(app)):
|
if not os.path.exists(app_cache_folder(app)):
|
||||||
try:
|
try:
|
||||||
init_cache(app, infos)
|
init_cache(app, infos)
|
||||||
|
@ -59,7 +80,7 @@ def init_cache(app, infos):
|
||||||
else:
|
else:
|
||||||
depth = 40
|
depth = 40
|
||||||
|
|
||||||
git("clone --depth {depth} --single-branch --branch master {url} {folder}".format(depth=depth, url=infos["url"], folder=app_cache_folder(app)))
|
git("clone --quiet --depth {depth} --single-branch --branch master {url} {folder}".format(depth=depth, url=infos["url"], folder=app_cache_folder(app)))
|
||||||
|
|
||||||
|
|
||||||
def refresh_cache(app, infos):
|
def refresh_cache(app, infos):
|
||||||
|
@ -70,7 +91,7 @@ def refresh_cache(app, infos):
|
||||||
return
|
return
|
||||||
|
|
||||||
git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app))
|
git("remote set-url origin " + infos["url"], in_folder=app_cache_folder(app))
|
||||||
git("fetch origin master --force", in_folder=app_cache_folder(app))
|
git("fetch --quiet origin master --force", in_folder=app_cache_folder(app))
|
||||||
git("reset origin/master --hard", in_folder=app_cache_folder(app))
|
git("reset origin/master --hard", in_folder=app_cache_folder(app))
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,8 +103,7 @@ def build_catalog():
|
||||||
|
|
||||||
result_dict = {}
|
result_dict = {}
|
||||||
|
|
||||||
for app, infos in catalog.items():
|
for app, infos in progressbar(catalog.items(), "Processing: ", 40):
|
||||||
print("Processing '%s'..." % app)
|
|
||||||
|
|
||||||
app = app.lower()
|
app = app.lower()
|
||||||
|
|
||||||
|
@ -205,13 +225,6 @@ def include_translations_in_manifest(manifest):
|
||||||
return manifest
|
return manifest
|
||||||
|
|
||||||
|
|
||||||
def error(msg):
|
|
||||||
msg = "[Applist builder error] " + msg
|
|
||||||
if os.path.exists("/usr/bin/sendxmpppy"):
|
|
||||||
subprocess.call(["sendxmpppy", msg], stdout=open(os.devnull, 'wb'))
|
|
||||||
print(msg)
|
|
||||||
|
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue