]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix jeos_path when not intalled as an egg
authorAngus Salkeld <asalkeld@redhat.com>
Fri, 25 May 2012 01:51:21 +0000 (11:51 +1000)
committerAngus Salkeld <asalkeld@redhat.com>
Fri, 25 May 2012 01:51:21 +0000 (11:51 +1000)
Also use os.path.join() to sort out trailing "/"

Change-Id: I212cffacc018f456894e9b7921fef75256edcf45
Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
bin/heat
heat/utils.py

index 04845bfc1c960c948e07939a27e928e2509f6ef2..f4282eda7ccce56fba15c552466bcc1aa03fa1b4 100755 (executable)
--- 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)
index d008a10d4401a4ac0719a4690c5aedac68b79a3e..df639bc892f178b9fcd231ddb1618926a172bb57 100644 (file)
@@ -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