def mainFooter(self): print(file=stderr) print("[+] End of search -- offset=%s (%s)" % (self.current_offset // 8, humanFilesize( self.current_offset // 8)), file=stderr) size = (self.current_offset - self.start_offset) // 8 duration = time() - self.main_start if 0.1 <= duration: print("Total time: %s -- global rate: %s/sec" % (humanDuration( duration * 1000), humanFilesize(size // duration)), file=stderr)
def durationWin64(field): """ Convert Windows 64-bit duration to string. The timestamp format is a 64-bit number: number of 100ns. See also timestampWin64(). >>> durationWin64(type("", (), dict(value=2146280000, size=64))) '3 min 34 sec 628 ms' >>> durationWin64(type("", (), dict(value=(1 << 64)-1, size=64))) '58494 years 88 days 5 hours' """ assert hasattr(field, "value") and hasattr(field, "size") assert field.size == 64 delta = doDurationWin64(field.value) return humanDuration(delta)
def createDescription(self): tag = self["type"].value if tag == "AVI ": desc = "Microsoft AVI video" if "headers/avi_hdr" in self: header = self["headers/avi_hdr"] desc += ": %ux%u pixels" % (header["width"].value, header["height"].value) microsec = header["microsec_per_frame"].value if microsec: desc += ", %.1f fps" % (1000000.0 / microsec) if "total_frame" in header and header["total_frame"].value: delta = timedelta( seconds=float(header["total_frame"].value) * microsec) desc += ", " + humanDuration(delta) return desc else: try: return self.VALID_TYPES[tag][2] except KeyError: return "Microsoft RIFF container"
def displayProgress(self): """ Display progress (to stdout) of the whole process. Compute data rate (in byte per sec) and time estimation. """ # Program next update self.next_progress = time() + PROGRESS_UPDATE # Progress offset percent = float(self.current_offset - self.start_offset) * \ 100 / (self.size - self.start_offset) offset = self.current_offset // 8 message = "Search: %.2f%% -- offset=%u (%s)" % (percent, offset, humanFilesize(offset)) # Compute data rate (byte/sec) average = self.datarate.average if average: message += " -- %s/sec " % humanFilesize(average // 8) eta = float(self.size - self.current_offset) / average message += " -- ETA: %s" % humanDuration(eta * 1000) # Display message print(message, file=stderr)
def formatJiffie(field): sec = float(field.value) / 60 return humanDuration(timedelta(seconds=sec))
def postMaxTime(self, chunk): return humanDuration(chunk.value * 1000)
def createDisplay(self): return humanDuration(self.value)
def diff(field): return humanDuration(field.value * 1000)
def computeLength(self, field): try: ms = int(field.value) return humanDuration(ms) except Exception: return field.value