Changeset 105


Ignore:
Timestamp:
Oct 27, 2005, 12:48:25 PM (19 years ago)
Author:
garonne
Message:

add the pyhton check version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/doc/gendoc.py

    r83 r105  
     1#!/usr/bin/env python
     2
    13#-----------------------------------------------------------
    24# Copyright Christian Arnault LAL-Orsay CNRS
    3 # arnault@lal.in2p3.fr
     5# author: arnault@lal.in2p3.fr
     6# modified by: garonne@lal.in2p3.fr
    47# See the complete license in cmt_license.txt "http://www.cecill.info".
    58#-----------------------------------------------------------
     
    710import sys, os, string, getopt, types
    811import xml.parsers.expat
    9 from datetime import date
     12import commands, glob
     13from   datetime import date
     14
     15
     16#------------------------------------------------------------
     17def checkPythonVersion (major=1,minor=5):   
     18    version      = float(str(major) +'.'+ str(minor))
     19    thisversion  = float(str(sys.version_info[0]) + '.' + str(sys.version_info[1]))
     20    if    version > thisversion:
     21    # try to find the good python version >= 2.3
     22        paths = string.split(os.environ['PATH'],':')
     23        print 'hmmm look for the appropriate python version, this one is',\
     24        thisversion,'and the required version is python >=', version   
     25        pythons = list()     
     26        for path in paths:
     27            pythons = glob.glob1(path, 'python*')
     28            for python in pythons:
     29                cmd = python +' -c "import sys; print sys.version_info"'
     30                status, thisversion = commands.getstatusoutput(cmd)
     31                thisversion         = eval (thisversion)
     32                thisversion         = float(str(thisversion[0]) +'.'+ str(thisversion[1]))
     33                if (thisversion >= version):
     34                    print 'found and load', python
     35                    sys.argv.insert (0, python)
     36                    os.execvp       (python, sys.argv) 
     37        print 'The appropriate version of python >=' + version + ' is not here, check your PATH variable or install it'
     38        sys.exit(-1)
     39
    1040
    1141#------------------------------------------------------------
     
    620650#print '__name__ = ' + __name__
    621651if __name__ == "__main__":
     652  checkPythonVersion (major=2, minor=3)
    622653  main()
    623654# end def
Note: See TracChangeset for help on using the changeset viewer.