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):
try:
# Read a statement from the keyboard
stmt = raw_input("---> ")
if stmt == "quit":
if stmt == "quit" or stmt == "":
return
# 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:
import traceback
traceback.print_exc()
self._universe.error_println("Caught exception: " + str(e))
self._universe.error_println(str(
if not we_are_translated(): # this cannot be done in rpython
import traceback
traceback.print_exc()
error_println("Caught exception: %s" % e)
error_println(str(
self._interpreter.get_frame().get_previous_frame()))
......@@ -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)
else:
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