restart python if running an old version and 2.5 or 2.6 is available on PATH (Windows)
This commit is contained in:
parent
fed180d945
commit
4dd9a8877d
|
@ -32,6 +32,9 @@ def fpdb_options():
|
|||
parser.add_option("-c", "--configFile",
|
||||
dest="config", default=None,
|
||||
help="Specifies a configuration file.")
|
||||
parser.add_option("-r", "--rerunPython",
|
||||
action="store_true",
|
||||
help="Indicates program was restarted with a different path (only allowed once).")
|
||||
(options, sys.argv) = parser.parse_args()
|
||||
return (options, sys.argv)
|
||||
|
||||
|
|
|
@ -17,6 +17,33 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
||||
# if path is set to use an old version of python look for a new one:
|
||||
# (does this work in linux?)
|
||||
if os.name == 'nt' and sys.version[0:3] not in ('2.5', '2.6') and '-r' not in sys.argv:
|
||||
#print "old path =", os.environ['PATH']
|
||||
dirs = re.split(os.pathsep, os.environ['PATH'])
|
||||
# remove any trailing / or \ chars from dirs:
|
||||
dirs = [re.sub('[\\/]$','',p) for p in dirs]
|
||||
# remove any dirs containing 'python' apart from those ending in 'python25', 'python26' or 'python':
|
||||
dirs = [p for p in dirs if not re.search('python', p, re.I) or re.search('python25$', p, re.I) or re.search('python26$', p, re.I)]
|
||||
tmppath = ";".join(dirs)
|
||||
#print "new path =", tmppath
|
||||
if re.search('python', tmppath, re.I):
|
||||
os.environ['PATH'] = tmppath
|
||||
print "Python " + sys.version[0:3] + ' - press return to continue\n'
|
||||
sys.stdin.readline()
|
||||
os.execvpe('python.exe', ('python.exe', 'fpdb.py', '-r'), os.environ) # first arg is ignored (name of program being run)
|
||||
else:
|
||||
print "\npython 2.5 not found, please install python 2.5 or 2.6 for fpdb\n"
|
||||
exit
|
||||
else:
|
||||
pass
|
||||
#print "debug - not changing path"
|
||||
|
||||
print "Python " + sys.version[0:3] + '...\n'
|
||||
|
||||
import threading
|
||||
import Options
|
||||
import string
|
||||
|
|
Loading…
Reference in New Issue
Block a user