Skip to content

Instantly share code, notes, and snippets.

@maxvonhippel
Created October 5, 2019 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxvonhippel/838ba96cf31944f4d03561bc0870697f to your computer and use it in GitHub Desktop.
Save maxvonhippel/838ba96cf31944f4d03561bc0870697f to your computer and use it in GitHub Desktop.
import sys
import signal
import os
from ptyprocess import PtyProcessUnicode
# The purpose of this script is to serve as a wrapper around SPIN,
# providing functionality in interactive mode similar to stepping through
# an application, for instance in a MIPS emulator.
# See: http://spinroot.com/fluxbb/viewtopic.php?id=1662
p = PtyProcessUnicode.spawn(['spin', '-p', '-i', '-w', sys.argv[1]])
def no_real_input():
line = p.readline()
if ("Select [" in line):
choice = input()
print(line)
def handler(signum, frame):
raise Exception("end of time")
while p.isalive():
signal.signal(signal.SIGALRM, handler)
signal.alarm(1)
try:
no_real_input()
except Exception as exc:
choice = input()
p.write(choice + "\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment