From: Angus Salkeld Date: Fri, 25 May 2012 01:51:21 +0000 (+1000) Subject: Fix jeos_path when not intalled as an egg X-Git-Tag: 2014.1~1783^2~1 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=07018fe88a020532649369750fbcc529196571d7;p=openstack-build%2Fheat-build.git Fix jeos_path when not intalled as an egg Also use os.path.join() to sort out trailing "/" Change-Id: I212cffacc018f456894e9b7921fef75256edcf45 Signed-off-by: Angus Salkeld --- diff --git a/bin/heat b/bin/heat index 04845bfc..f4282eda 100755 --- a/bin/heat +++ b/bin/heat @@ -23,6 +23,7 @@ API server. import gettext import optparse import os +import os.path import sys import time import json @@ -34,15 +35,19 @@ from urlparse import urlparse possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) +jeos_path = '' +cfntools_path = '' if os.path.exists(os.path.join(possible_topdir, 'heat', '__init__.py')): sys.path.insert(0, possible_topdir) jeos_path = '%s/heat/%s/' % (possible_topdir, "jeos") cfntools_path = '%s/heat/%s/' % (possible_topdir, "cfntools") + jeos_path = os.path.join(possible_topdir, 'jeos') + cfntools_path = os.path.join(possible_topdir, 'cfntools') else: for p in sys.path: - if 'heat' in p: - jeos_path = '%s/heat/%s/' % (p, "jeos") - cfntools_path = '%s/heat/%s/' % (p, "cfntools") + jeos_path = os.path.join(p, 'heat', 'jeos') + cfntools_path = os.path.join(p, 'heat', 'cfntools') + if os.access(jeos_path, os.R_OK): break gettext.install('heat', unicode=1) diff --git a/heat/utils.py b/heat/utils.py index d008a10d..df639bc8 100644 --- a/heat/utils.py +++ b/heat/utils.py @@ -15,6 +15,7 @@ import functools import os +import os.path import sys import base64 from lxml import etree @@ -132,7 +133,8 @@ def jeos_create(options, arguments, jeos_path, cfntools_path): logging.error('*** %s does not exist.' % (iso)) sys.exit(1) - tdl_path = '%s%s-%s-%s-jeos.tdl' % (jeos_path, distro, arch, instance_type) + tdl_file = '%s-%s-%s-jeos.tdl' % (distro, arch, instance_type) + tdl_path = os.path.join(jeos_path, tdl_file) if options.debug: print "Using tdl: %s" % tdl_path