home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_pyppm.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  1.5 KB  |  52 lines

  1. # Copyright 2001 (C) ActiveState Tool Corp., All Rights Reserved.
  2. # Written by Houman Ghaemi <houmang@activestate.com>
  3. #
  4. import PPM
  5. from PPM import PyPMHelps
  6. import os, sys, getopt
  7. from PPM.ppmerrors import errorreporter
  8. import traceback
  9.  
  10. def run(args):
  11.     try:
  12.         args = filter(None, args)
  13.  
  14.     # first parse the option list
  15.     pause = 0
  16.     if len(args) >= 1:
  17.         if args[0] == '-p' or args[0] == '--pause':
  18.             pause = 1
  19.             args = args[1:]
  20.         # why is genconfig special?
  21.         if len(args)>=1 and \
  22.            args[0]=='genconfig':
  23.             if os.name=='nt':
  24.                 OSVALUE='MSWin32'
  25.             else:
  26.                 OSVALUE=os.name
  27.             tempvar= os.path.join(sys.exec_prefix,'Downloads') 
  28.             try:
  29.                 print PyPMHelps.configstr % (os.name , os.environ['TEMP'] , '')
  30.             except KeyError:
  31.                 print PyPMHelps.configstr % (os.name , tempvar , '')
  32.  
  33.         else:
  34.             shell = PPM.Pyshell(args,pause)
  35.             shell.cmdloop()
  36.     except SystemExit, e: 
  37.         sys.exit(e.code)
  38.     except KeyboardInterrupt:
  39.         return
  40.  
  41.     except:
  42.         type, value, tb = sys.exc_info()
  43.         
  44.         tb = "".join(traceback.format_tb(tb))
  45.         msg = "Unhandled exception: %s \n %s \n %s" % (type, value, tb)
  46.         errorreporter.Msg(msg)
  47.         error = "Unhandled exception: %s \n %s" % (type, value)
  48.         errorreporter.Fatal(msg)
  49.     
  50. if __name__=='__main__':
  51.     run(sys.argv[1:])
  52.