#! /usr/bin/env python """compileall.py: Load all the packages in IRAF and compile all the CL scripts The results are stored in the system cache. The system cache must be writable for this script to run. Set the -r flag to recompile (default is to rename the system cache so that everything gets compiled from scratch.) $Id: compileallcl.py,v 1.1 2001/11/16 14:00:24 dencheva Exp $ """ import os, sys, traceback, time def printcenter(s, length=70, char="-"): l1 = (length-len(s))/2 l2 = length-l1-len(s) print l1*char, s, l2*char sys.stdout.flush() def compileall(): """Compile all CL procedures & packages""" # start the timer t0 = time.time() # now do the IRAF startup from pyraf import iraf, cl2py from pyraf.iraftask import IrafCLTask, IrafPkg iraf.setVerbose() pkgs_tried = {} tasks_tried = {} npkg_total = 0 ntask_total = 0 ntask_failed = 0 # main loop -- keep loading packages as long as there are # new ones to try, and after loading each package look for # and initialize any CL tasks npass = 0 pkg_list = iraf.getPkgList() keepGoing = 1 while keepGoing and (npkg_total 0: print "Error: no positional arguments accepted" usage() except getopt.error, e: print str(e) usage() clearcache = 1 for opt, value in optlist: if opt == "-r": clearcache = 0 elif opt == "-r": usage() else: print "Program bug, uninterpreted option", opt raise SystemExit sysCache = os.path.join(absPyrafDir, 'pyraf', 'clcache') usrCache = os.path.expanduser('~/iraf/pyraf/clcache') if clearcache: # move the old system cache if os.path.exists(sysCache): os.rename(sysCache, sysCache + '.old') # lock user cache so that it is not readable or writable # this forces all compiled code to go into the system cache if not os.path.exists(usrCache): os.mkdir(usrCache) os.chmod(usrCache,0) print 'Locked user cache to force updates into system cache' sys.stdout.flush() try: compileall() finally: # restore user cache permissions os.chmod(usrCache,0755)