diff options
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | python/__init__.py (renamed from test/__init__.py) | 0 | ||||
-rw-r--r-- | python/hello.py | 7 | ||||
-rw-r--r-- | python/interp.py | 7 | ||||
-rw-r--r-- | python/server.py | 33 |
5 files changed, 53 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 845cd4c9..e2a0a15d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/test/__init__.py b/python/__init__.py index e69de29b..e69de29b 100644 --- a/test/__init__.py +++ b/python/__init__.py diff --git a/python/hello.py b/python/hello.py new file mode 100644 index 00000000..b5b072bb --- /dev/null +++ b/python/hello.py @@ -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 diff --git a/python/interp.py b/python/interp.py new file mode 100644 index 00000000..afc62ba4 --- /dev/null +++ b/python/interp.py @@ -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 diff --git a/python/server.py b/python/server.py new file mode 100644 index 00000000..64a91ca3 --- /dev/null +++ b/python/server.py @@ -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() + |