Improve, restructure documentation and add screenshot

This commit is contained in:
Sebastian Serth
2020-10-20 12:13:30 +02:00
parent 92be9d56ee
commit d25dd41ccf
18 changed files with 3 additions and 1 deletions

12
docs/webpython/Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM ubuntu:14.04
MAINTAINER "Martin v. Löwis"
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV PYTHONPATH $PYTHONPATH:/usr/lib/python3.4:/workspace
ENV PATH $PATH:/usr/lib/python3.4
ADD assess.py /usr/lib/python3.4/assess.py
ADD webpython.py /usr/lib/python3.4/webpython.py
RUN rm /usr/lib/python3.4/turtle.py
ADD turtle.py /usr/lib/python3.4/turtle.py
RUN adduser --disabled-password --gecos Python python
USER python

58
docs/webpython/Makefile Normal file
View File

@ -0,0 +1,58 @@
CODEMIRROR=html/js/codemirror.js
all: logs
logs:
mkdir logs
# These are put into source control
generated: $(CODEMIRROR)
$(CODEMIRROR): CodeMirror/lib/codemirror.js CodeMirror/mode/python/python.js
(cd CodeMirror; bin/compress codemirror python) > $@
run: all kill
twistd -l logs/webpython.log -y webpython.tac
runpy: killpy
twistd --pidfile pylaunch.pid -l logs/pylaunch.log -y pylaunch.tac
manager: all killmanager
twistd --pidfile manager.pid -l logs/manager.log -y manager.tac
kill:
if [ -f twistd.pid ];\
then\
kill `cat twistd.pid`;\
fi
killpy:
if [ -f pylaunch.pid ];\
then\
kill `cat pylaunch.pid`;\
fi
killmanager:
if [ -f manager.pid ];\
then\
kill `cat manager.pid`;\
fi
docker:
docker.io build --rm -t webpython .
update:
git pull
make docker
service webpython-worker restart
rmexited:
docker.io ps -a|grep 'Exit '|awk '{print $$1;}'|xargs docker.io rm
rmi:
docker.io rmi $$(docker.io images | grep "^<none>" | awk '{print $$3;}')
killold:
-docker.io ps | egrep 'hours? ago' |awk '{print $$1}'|xargs docker.io kill
-killall -o 30m -9 python3

47
docs/webpython/README.md Normal file
View File

@ -0,0 +1,47 @@
Local setup
===========
1. `git checkout webpython-hybrid`
2. Make sure to install all dependencies and migrations:
rake db:migrate
bundle install
3. Create a new docker image containing the Turtle library and the i/o wrapper:
cd webpython
docker build -t IMAGE_NAME .
4. Configure your Docker host at `config/docker.yml.erb`. Make sure to add a websocket host, for example like this (this is probably different for you):
host: tcp://localhost:2375
ws_host: ws://localhost:2375
5. Run the CodeOcean server with `rails s -p 3333`
6. Login with admin@example.org (pw: admin) and create a new execution environment picking the newly created Docker image from the dropdown. Set the initial command to:
cd /usr/lib/python3.4 && python3 webpython.py
7. Create a new exercise for the newly created execution environment with an arbritrary main file.
8. Implement the exercise. The code below can be used as an example to see the canvas and I/O in action:
import turtle
wn = turtle.Screen()
alex = turtle.Turtle()
# i/o test
print("hello!")
print("please enter your name")
name = input()
print("your name is", name)
# canvas test
alex.forward(50)
alex.right(90)
alex.forward(30)
alex.right(90)
alex.forward(30)
wn.mainloop()

1
docs/webpython/assess.py Normal file
View File

@ -0,0 +1 @@
# moved to dockerfiles/ubuntu-python

1
docs/webpython/turtle.py Normal file
View File

@ -0,0 +1 @@
# moved to dockerfiles/ubuntu-python/turtle.py

View File

@ -0,0 +1 @@
# moved to dockerfiles/ubuntu-python/webpython.py