WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

Commit f45c9940 authored by Tobias Pape's avatar Tobias Pape Committed by Stefan Marr
Browse files

rpythonize the shell

for that, provide own raw_input.
also: crtl-d works now.
parent de1f0fd7
from rpython.rlib.objectmodel import we_are_translated
class Shell(object):
def __init__(self, universe, interpreter):
......@@ -9,10 +11,10 @@ class Shell(object):
self._bootstrap_method = method
def start(self):
from som.vm.universe import std_println, error_println, raw_input
counter = 0
it = self._universe.nilObject
from som.vm.universe import std_println
std_println("SOM Shell. Type \"quit\" to exit.\n");
# Create a fake bootstrap frame
......@@ -25,7 +27,7 @@ class Shell(object):
# Read a statement from the keyboard
stmt = raw_input("---> ")
if stmt == "quit":
if stmt == "quit" or stmt == "":
# Generate a temporary class with a run method
......@@ -65,8 +67,9 @@ class Shell(object):
# Save the result of the run method
it = current_frame.pop()
except Exception, e:
if not we_are_translated(): # this cannot be done in rpython
import traceback
self._universe.error_println("Caught exception: " + str(e))
error_println("Caught exception: %s" % e)
......@@ -588,6 +588,22 @@ def std_print(msg):
def std_println(msg=""):
print msg
def _read_raw(answer):
buf = os.read(1, 32)
if len(buf) == 0:
return (answer, False)
elif buf[-1] == "\n":
return (answer + buf[:-1], False)
return (answer + buf, True)
def raw_input(msg=""):
os.write(1, msg)
answer, cont = _read_raw("")
while cont:
answer, cont = _read_raw(answer)
return answer
def main(args):
u = Universe()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment