def _print_disk_usage(name, path): if os.path.exists(path): size = file_util.disk_usage(path) else: size = 0 ws = " " * max(1, 24 - len(name)) cli.out(" %s:%s%s in %s" % (name, ws, util.format_bytes(size), path))
def _publish_runs(runs, formatted, args): if args.all_files: copy_files = publishlib.COPY_ALL_FILES elif args.files or args.include_links: copy_files = publishlib.COPY_DEFAULT_FILES else: copy_files = None for run, frun in zip(runs, formatted): cli.out("Publishing [%s] %s... " % (frun["short_id"], frun["operation"]), nl=False) frun["_run"] = run try: publishlib.publish_run(run, dest=args.dest, template=args.template, copy_files=copy_files, include_links=args.include_links, md5s=not args.no_md5, formatted_run=frun) except publishlib.PublishError as e: cli.error("error publishing run %s:\n%s" % (run.id, e)) else: dest = args.dest or publishlib.DEFAULT_DEST_HOME size = util.dir_size(os.path.join(dest, run.id)) cli.out("using %s" % util.format_bytes(size))
def file_size(val): if not isinstance(val, (int, float) + six.string_types): return "" try: bytes = int(val) except (ValueError, TypeError): return "" else: return util.format_bytes(bytes)
def _report_dir_size(args): dest = args.dest or publishlib.DEFAULT_DEST_HOME size = util.dir_size(dest) cli.out("Published runs using %s" % util.format_bytes(size))
def _formatted_disk_usage(path): if os.path.exists(path): size = file_util.disk_usage(path) else: size = 0 return util.format_bytes(size)