Merge lp:~soren/glance/glance-upload-sys.path into lp:~glance-coresec/glance/cactus-trunk

Proposed by Soren Hansen
Status: Merged
Approved by: Jay Pipes
Approved revision: 77
Merged at revision: 77
Proposed branch: lp:~soren/glance/glance-upload-sys.path
Merge into: lp:~glance-coresec/glance/cactus-trunk
Diff against target: 19 lines (+9/-0)
1 file modified
bin/glance-upload (+9/-0)
To merge this branch: bzr merge lp:~soren/glance/glance-upload-sys.path
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Review via email: mp+51501@code.launchpad.net

Commit message

Add sys.path mangling to glance-upload.

Description of the change

Add the same sys.path mangling stuff to glance-upload that is in the other bin/*.

This fixes the following test failure in clean environments:

======================================================================
FAIL: test_exception_not_eaten_from_registry_to_api (tests.unit.test_misc.TestMiscellaneous)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/buildd/glance-2011.2~bzr76/tests/unit/test_misc.py", line 170, in test_exception_not_eaten_from_registry_to_api
    "result from glance-upload:\n%(e)s" % locals())
AssertionError: Could not find 'Invalid image type' in result from glance-upload:
Command ./bin/glance-upload --port=32001 --type=invalid /tmp/tmpEd3FfR 'my image' did not succeed. Returned an exit code of 1.

STDOUT:

STDERR: Traceback (most recent call last):
  File "./bin/glance-upload", line 53, in <module>
    from glance.client import Client
ImportError: No module named glance.client

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

nice catch, thx soren.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/glance-upload'
2--- bin/glance-upload 2011-02-24 23:06:10 +0000
3+++ bin/glance-upload 2011-02-28 09:32:31 +0000
4@@ -48,8 +48,17 @@
5 # available
6 import argparse
7 import pprint
8+import os
9 import sys
10
11+# If ../glance/__init__.py exists, add ../ to Python search path, so that
12+# it will override what happens to be installed in /usr/(local/)lib/python...
13+possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
14+ os.pardir,
15+ os.pardir))
16+if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')):
17+ sys.path.insert(0, possible_topdir)
18+
19 from glance.client import Client
20
21

Subscribers

People subscribed via source and target branches