Commit 91336cf0 authored by 's avatar

Merged Evans product path fix from 2.2 branch

parent 559d3aa0
......@@ -85,41 +85,60 @@
"""Commonly used utility functions."""
__version__='$Revision: 1.3 $'[11:-2]
__version__='$Revision: 1.4 $'[11:-2]
import os, sys, Products, string
from Common import package_home
path_join = os.path.join
path_split = os.path.split
try: home=os.environ['SOFTWARE_HOME']
except:
home=package_home(Products.__dict__)
if not os.path.isabs(home):
home=os.path.join(os.getcwd(), home)
home=path_join(os.getcwd(), home)
home,e=os.path.split(home)
if os.path.split(home)[1]=='.': home=os.path.split(home)[0]
if os.path.split(home)[1]=='..':
home=os.path.split(os.path.split(home)[0])[0]
home,e=path_split(home)
if path_split(home)[1]=='.': home=path_split(home)[0]
if path_split(home)[1]=='..':
home=path_split(path_split(home)[0])[0]
sys.modules['__builtin__'].SOFTWARE_HOME=SOFTWARE_HOME=home
try: chome=os.environ['INSTANCE_HOME']
except:
chome=home
d,e=os.path.split(chome)
d,e=path_split(chome)
if e=='python':
d,e=os.path.split(d)
d,e=path_split(d)
if e=='lib': chome=d or os.getcwd()
sys.modules['__builtin__'].INSTANCE_HOME=INSTANCE_HOME=chome
# If there is a Products package in INSTANCE_HOME, add it to the
# Products package path
ip=os.path.join(INSTANCE_HOME, 'Products')
if os.path.isdir(ip) and ip not in Products.__path__:
ip=path_join(INSTANCE_HOME, 'Products')
ippart = 0
ppath = Products.__path__
if os.path.isdir(ip) and ip not in ppath:
disallow=string.lower(os.environ.get('DISALLOW_LOCAL_PRODUCTS',''))
if disallow in ('no', 'off', '0', ''):
Products.__path__.insert(0, ip)
ppath.insert(0, ip)
ippart = 1
ppathpat = os.environ.get('PRODUCTS_PATH', None)
if ppathpat is not None:
psep = os.pathsep
if string.find(ppathpat, '%(') >= 0:
newppath = string.split(ppathpat % {
'PRODUCTS_PATH': string.join(ppath, psep),
'SOFTWARE_PRODUCTS': string.join(ppath[ippart:], psep),
'INSTANCE_PRODUCTS': ip,
}, psep)
else:
newppath = string.split(ppathpat, psep)
del ppath[:]
for p in filter(None, newppath):
p = os.path.abspath(p)
if os.path.isdir(p) and p not in ppath:
ppath.append(p)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment