Created some new Python scripts under python/
This commit is contained in:
parent
153563d165
commit
e012917ceb
5 changed files with 53 additions and 1 deletions
|
|
@ -228,6 +228,11 @@ ledger_la_DEPENDENCIES = $(lib_LTLIBRARIES)
|
|||
ledger_la_LDFLAGS = -avoid-version -module
|
||||
ledger_la_LIBADD = $(LIBOBJS) $(lib_LTLIBRARIES) $(INTLLIBS)
|
||||
|
||||
pkgpython_PYTHON = python/__init__.py \
|
||||
python/hello.py \
|
||||
python/interp.py \
|
||||
python/server.py
|
||||
|
||||
endif
|
||||
|
||||
######################################################################
|
||||
|
|
@ -397,7 +402,7 @@ dist-hook:
|
|||
rm -fr $(distdir)/doc/latex \
|
||||
$(distdir)/doc/Doxyfile.bak \
|
||||
$(distdir)/doc/Doxyfile.gen
|
||||
cp -pR $(srcdir)/doc/html $(distdir)/doc
|
||||
cp -pR doc/html $(distdir)/doc
|
||||
rm -f $(distdir)/README.textile
|
||||
cp -p $(srcdir)/doc/README $(distdir)/README
|
||||
|
||||
|
|
|
|||
7
python/hello.py
Normal file
7
python/hello.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import ledger
|
||||
|
||||
def precmd_hello():
|
||||
hello = ledger.Value()
|
||||
hello.set_string("Well, hello yourself! This is Ledger, coming to you from Python Land.")
|
||||
print hello
|
||||
return hello
|
||||
7
python/interp.py
Normal file
7
python/interp.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from code import InteractiveConsole
|
||||
|
||||
def cmd_python():
|
||||
interpreter = InteractiveConsole()
|
||||
interpreter.push("from ledger import *")
|
||||
interpreter.interact("Welcome to Ledger")
|
||||
return True
|
||||
33
python/server.py
Normal file
33
python/server.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import ledger
|
||||
import cgi
|
||||
import sys
|
||||
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
class LedgerHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
print "Saw a GET request!"
|
||||
sys.exit(0)
|
||||
|
||||
def do_POST(self):
|
||||
print "Saw a POST request!"
|
||||
try:
|
||||
ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
|
||||
if ctype == 'multipart/form-data':
|
||||
query = cgi.parse_multipart(self.rfile, pdict)
|
||||
self.send_response(301)
|
||||
self.end_headers()
|
||||
except Exception:
|
||||
print "Saw exception in POST handler"
|
||||
|
||||
def cmd_server():
|
||||
try:
|
||||
port = 9000
|
||||
server = HTTPServer(('', port), LedgerHandler)
|
||||
print "Local HTTP server listening on port %d... (Control-C to exit)" \
|
||||
% port
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print "Shutting down server"
|
||||
server.socket.close()
|
||||
|
||||
Loading…
Add table
Reference in a new issue