python script template


#!/usr/bin/env python
"""
Some documentation:
Usage:
-h help
-r results file
"""
# Import libraries
import sys
import getopt
 
def process(arg):
  if arg.endswith(".results"):
   print_results(arg)
  else:
   print arg, "not recognized :'("
 
class Usage(Exception):
  def __init__(self, msg):
   self.msg = msg
 
def main(argv=None):
  if argv is None:
   argv=sys.argv
   try:
   # parse command line options
   try:
   opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
   except getopt.error, msg:
   raise Usage(msg)
   # process options
   for o, a in opts:
   if o in ("-h", "--help"):
   print __doc__
   return 0
   # process arguments
   for arg in args:
   process(arg)
   except Usage, err:
   print >> sys.stderr, err.msg
   print >> sys.stderr, "for help use -help"
   return 2
 
if __name__ == "__main__":
  sys.exit(main())

Filed under  //

Comments [0]

running appengine on kubuntu 9

I finally got Google appengine running on my Dell mini9 and heres how ...

Download and upzip the appengine stk

unzip google_appengine_1.2.2.zip

appengine does not run on python 2.6 (the kubuntu default version) so install 2.5 from the commandline

sudo apt-get install python2.5

edit the first line of the dev_appserver.py file in the google_appengine sdk folder

#!/usr/bin/env python

to read

#!/usr/bin/env python2.5

Now that's out of the way we have to fix the permissions on the files in the SDK:

cd google_appengine
sudo chmod -R o+rx ./*

All done, enjoy

Filed under  //

Comments [0]