Skip to content

Commit

Permalink
Use print function
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
mistotebe authored and jwiegley committed Dec 5, 2019
1 parent 85f94ee commit e264eb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions python/demo.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python


from __future__ import print_function

import sys import sys
from datetime import datetime from datetime import datetime


Expand All @@ -9,7 +11,7 @@


import ledger import ledger


print "Welcome to the Ledger.Python demo!" print("Welcome to the Ledger.Python demo!")


# Some quick helper functions to help us assert various types of truth # Some quick helper functions to help us assert various types of truth
# throughout the script. # throughout the script.
Expand Down Expand Up @@ -290,4 +292,4 @@ def assertEqual(pat, candidate):
#journal.collect('-M food') #journal.collect('-M food')
#journal.collect_accounts('^assets ^liab ^equity') #journal.collect_accounts('^assets ^liab ^equity')


print 'Demo completed successfully.' print('Demo completed successfully.')
14 changes: 8 additions & 6 deletions python/server.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-


from __future__ import print_function

import ledger import ledger
import cgi import cgi
import sys import sys
Expand Down Expand Up @@ -129,15 +131,15 @@ def do_GET(self):
self.wfile.write(html) self.wfile.write(html)


def do_POST(self): def do_POST(self):
print "Saw a POST request!" print("Saw a POST request!")
try: try:
ctype, pdict = cgi.parse_header(self.headers.getheader('content-type')) ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))
if ctype == 'multipart/form-data': if ctype == 'multipart/form-data':
query = cgi.parse_multipart(self.rfile, pdict) query = cgi.parse_multipart(self.rfile, pdict)
self.send_response(301) self.send_response(301)
self.end_headers() self.end_headers()
except Exception: except Exception:
print "Saw exception in POST handler" print("Saw exception in POST handler")


# This code is straight from SimpleHTTPServer.py # This code is straight from SimpleHTTPServer.py
def copyfile(self, source, outputfile): def copyfile(self, source, outputfile):
Expand Down Expand Up @@ -182,15 +184,15 @@ def main(*args):
try: try:
port = 9000 port = 9000
server = HTTPServer(('', port), LedgerHandler) server = HTTPServer(('', port), LedgerHandler)
print "Local HTTP server listening on port %d... (Control-C to exit)" \ print("Local HTTP server listening on port %d... (Control-C to exit)" \
% port % port)
server.serve_forever() server.serve_forever()
except KeyboardInterrupt: except KeyboardInterrupt:
print "Shutting down server" print("Shutting down server")
server.socket.close() server.socket.close()


if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 3: if len(sys.argv) < 3:
print "usage: server.py <DATA-FILE> <REPORT-QUERY>" print("usage: server.py <DATA-FILE> <REPORT-QUERY>")
sys.exit(1) sys.exit(1)
main() main()

0 comments on commit e264eb6

Please sign in to comment.