def extract_item_end_callback(item, success): if success: if not args.silent: name = item.get_name() size = item.get_size() if isinstance(item, hl.HLDirectoryFile): print("OK ({0} B)".format(size)) elif isinstance(item, hl.HLDirectoryFolder): print(" Done {0}: OK ({1} B)".format(name, size)) else: assert False else: if not args.silent: if isinstance(item, hl.HLDirectoryFile): error = hl.get_value(hl.HLOption.HL_ERROR_SHORT_FORMATED) print("Errored.\n " + error) elif isinstance(item, hl.HLDirectoryFolder): print(" Done {0}: Errored".format(name)) else: assert False else: path = item.get_path() if isinstance(item, hl.HLDirectoryFile): error = hl.get_value(HLOption.HL_ERROR_SHORT_FORMATED) print(" Error extracting {0}:\n {1}".format(path, error)) elif isinstance(item, hl.HLDirectoryFolder): print(" Error extracting {0}.".format(path)) else: assert False
def console_status(): hlo = hl.HLOption size = hl.get_value(hlo.HL_PACKAGE_SIZE) allocs = hl.get_value(hlo.HL_PACKAGE_TOTAL_ALLOCATIONS) allocated = hl.get_value(hlo.HL_PACKAGE_TOTAL_MEMORY_ALLOCATED) used = hl.get_value(hlo.HL_PACKAGE_TOTAL_MEMORY_USED) print("Total size: {0} B".format(size)) print("Total mapping allocations: {0}".format(allocs)) print("Total mapping memory allocated: {0} B".format(allocated)) print("Total mapping memory used: {0} B".format(used)) for idx in range(hl.Package.get_attribute_count()): try: attribute = hl.Package.get_attribute(idx) print_attribute("", attribute, "") except hl.HLError as ex: print(ex)
def defragment(): if not args.silent: print("Defragmenting...\n\n Progress: ", end="") # XXX Check output this is diff from original prog. progress_start() try: hl.Package.defragment() except HLError: print(" " + hl.get_value(HLOption.HL_ERROR_SHORT_FORMATED), end="") if not args.silent: print("\n\nDone.\n")