54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import sys
|
|
import time
|
|
|
|
|
|
def progressbar(it, prefix="", size=60, out=sys.stdout):
|
|
count = len(it)
|
|
|
|
def show(j):
|
|
x = int(size*j/count)
|
|
print("{}[{}{}] {}/{}".format(prefix, u"█"*x, "."*(size-x), j, count), end='\r', file=out, flush=True)
|
|
|
|
show(0)
|
|
for i, item in enumerate(it):
|
|
yield item
|
|
show(i+1)
|
|
print("", flush=True, file=out)
|
|
|
|
|
|
def bordered(text):
|
|
lines = text.splitlines()
|
|
width = max(len(s) for s in lines)
|
|
res = ['┌' + '─' * width + '┐']
|
|
for s in lines:
|
|
res.append('│' + (s + ' ' * width)[:width] + '│')
|
|
res.append('└' + '─' * width + '┘')
|
|
return '\n'.join(res)
|
|
|
|
|
|
def underlined(text):
|
|
lines = text.splitlines()
|
|
width = max(len(s) for s in lines)
|
|
res = []
|
|
for s in lines:
|
|
res.append(s)
|
|
res.append('─' * width)
|
|
return '\n'.join(res)
|
|
|
|
|
|
def print_welcome(script_version, compiler, compiler_version, mpi, mpi_version, instDir, installs):
|
|
out = underlined("Patricks Simple Library Installer " + script_version)
|
|
out = out + "\n" + "Compiler: " + compiler.upper() + ", Version: " + compiler_version
|
|
out = out + "\n" + "MPI: " + mpi.upper() + ", Version: " + mpi_version
|
|
out = out + "\n" + "Install Directory: "+instDir
|
|
out = out + "\n"
|
|
out = out + "\n" + "The following Libraries will be installed:"
|
|
for lib in installs:
|
|
out = out + "\n" + lib['name'] + " v." + lib['version']
|
|
print(bordered(out) + "\n")
|
|
|
|
# short sleep to enable user to abprt if selected options are wrong
|
|
for i in progressbar(range(5), "Waiting 5s to start build: ", 10):
|
|
time.sleep(1)
|
|
|
|
print("\n") |