3 ms·
Oops: > import subprocess Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/lib/python2.7/subprocess.py", line 429, in
by pyre 15y ago
Oops:
> import subprocess
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python2.7/subprocess.py", line 429, in <module>
import select
ImportError: No module named select
Also:
> os.name
=> 'posix'
> os.uname()
=> ('Emscripten', 'emscripten', '1.0', '#1', 'x86-JS')
> os.environ
=> {'LANG': 'en_US.UTF-8', 'PYTHONHOME': '/:/', 'PWD': '/',
'USER': 'root', 'HOME': '/', 'PATH': '/', '_': './this.program'}
> os.getcwd()
=> '/sandbox'
> os.chdir('/')
> os.getcwd()
=> '/'
> os.popen2('ls -l')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python2.7/os.py", line 667, in popen2
import subprocess
File "/lib/python2.7/subprocess.py", line 429, in <module>
import select
ImportError: No module named select
> os.popen('ls -l')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 24] Too many open files
* I liked the 'x86-JS' as the architecture.
* I know about os.listdir() but I wanted the permissions.
* I automatically did a ^W to delete a word and closed the tab. I don't feel like opening it again or I would probably have more.
* I realize that since this is a CPython -> JS converter that the REPL is running in my browser and no on a server (AFAIK) so it's not like this attempting to hack someone's server, but I found it interesting to probe the environment.
- max99x 15y agoThanks for trying it out. * The ^W is fixable, but I'm not sure how I personally feel about hijacking fundamental browser shortcuts. We'll look into it though. * Regarding the environment, in general, multi-threading and multi-processing (and anything that depends on them) are not supported, since Emscripten translates the code to JS rather than emulating a machine. * The Emscripten virtual filesystem has a simple single-user permission model and the libc functions for accessing/modifying the permissions are supported. So technically you could get the permissions through os.access. Not as convenient as ls, of course, but doable.
- pyre 15y agoI will note that when copying the text out of the interpreter, the prompt (>) doesn't copy (I assume that you may be using a CSS :after or :before decorator, though I didn't look). Sometimes even the newline itself didn't copy. For that post I had to cleanup all of the text so that it would display properly. This may be an issue you want to look at if you want to support people copy/pasting stuff that they are working on out of the console (or you may just want to add a button that generates a Github gist or pastebin entry and displays a link to it).
- max99x 15y agoThe prompt label is an image, hence it's not copyable. We experimented a bit with various copy-friendly approaches, but couldn't find anything that was cross-browser and did not damage the look/layout we were going for. To share a session, click the save button on the top right - it'll generate a shareable link with the editor content and the whole REPL session in replayable form.