Commit 10fce3eb authored by thiolliere's avatar thiolliere
Browse files

pretty print and quiet argument

parent d6e42dd2
......@@ -20,6 +20,6 @@ def make():
os.mkdir(catalog_dir)
for catalog in catalog_files:
wget.download("{}/{}".format(catalog_url_path, catalog), out="{}/{}".format(catalog_dir, catalog))
print()
wget.download("{}/{}".format(catalog_url_path, catalog), out="{}/{}".format(catalog_dir, catalog), bar=pretty_print.wget_bar)
pretty_print.newline()
......@@ -18,9 +18,13 @@ parser.add_argument('-z', "--zim-install", help="install zim", nargs="*")
parser.add_argument('-r', "--resize", help="resize image in GiB", type=float)
parser.add_argument('-c', "--catalog", help="build zim catalog and exit", action="store_true")
parser.add_argument('-s', "--sd", help="sd card device to put the image onto")
parser.add_argument('-q', "--quiet", help="more quiet", action="store_true")
args = parser.parse_args()
if args.quiet:
pretty_print.wget_bar = None
os.makedirs("build", exist_ok=True)
os.chdir("build")
......@@ -153,7 +157,7 @@ if args.sd:
new_percentage = (100 * current_size) / total_size
if new_percentage != current_percentage:
current_percentage = new_percentage
print(str(current_percentage) + "%")
pretty_print.std(str(current_percentage) + "%")
buf = os.read(image, 4096)
if buf == b"":
......
import wget
def step(step):
print("\033[00;34m--> " + step + "\033[00m")
......@@ -6,3 +8,8 @@ def err(err):
def std(std):
print(std)
def newline():
print()
wget_bar = wget.bar_adaptive
......@@ -121,13 +121,13 @@ class Qemu:
self.__boot()
def exec(self, command):
print(command)
pretty_print.std(command)
_, stdout, stderr = self.__client.exec_command(command)
while True:
line = stdout.readline()
if line == "":
break
print(line.replace("\n", ""))
pretty_print.std(line.replace("\n", ""))
for line in stderr.readlines():
pretty_print.err("STDERR: " + line.replace("\n", ""))
......
......@@ -16,9 +16,9 @@ def make():
if not os.path.isfile(image):
pretty_print.step("download raspbian-lite")
zipFileName = version + "-raspbian-jessie-lite.zip"
raspbianLiteImageZip = wget.download("http://vx2-downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-{}/{}-raspbian-jessie-lite.zip".format(url_dir, version), out=zipFileName)
raspbianLiteImageZip = wget.download("http://vx2-downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-{}/{}-raspbian-jessie-lite.zip".format(url_dir, version), out=zipFileName, bar=pretty_print.wget_bar)
print() # Because wget doesn't return to new line
pretty_print.newline() # Because wget doesn't return to new line
pretty_print.step("extract raspbian-lite")
zipFile = ZipFile(zipFileName)
zipFile.extract(image)
......@@ -25,7 +25,7 @@ def make():
if not os.path.isdir(linux_folder):
pretty_print.step("download linux")
raspbianLiteImageZip = wget.download("https://github.com/torvalds/linux/archive/v{}.zip".format(linux_version), out=linux_zip)
raspbianLiteImageZip = wget.download("https://github.com/torvalds/linux/archive/v{}.zip".format(linux_version), out=linux_zip, bar=pretty_print.wget_bar)
pretty_print.step("extract linux")
zipFile = ZipFile(linux_zip)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment