Change in vdsm[master]: vdsClient: fix failing to run in vdsm project source directo...

zhshzhou at linux.vnet.ibm.com zhshzhou at linux.vnet.ibm.com
Wed Oct 24 06:35:28 UTC 2012


Zhou Zheng Sheng has uploaded a new change for review.

Change subject: vdsClient: fix failing to run in vdsm project source directory
......................................................................

vdsClient: fix failing to run in vdsm project source directory

There are two problems in the old way of running vdsClient.py.

1. If PYTHONPATH is empty in runtime, PYTHONPATH="@VDSMDIR@:$PYTHONPATH"
will be expanded to PYTHONPATH="/usr/share/vdsm:". The colon at the end
means the current directory, so if vdsClient is run from vdsm project
source directory, the directory will be added to PYTHONPATH, and it
appears before the site-packages directory. When we "from vdsm import
vdscli", it imports from the wrong path but not from the site-packages.

This patch avoids to add a suffix colon when insert @VDSMDIR@ to
PYTHONPATH.

2. vdsClient.y is loaded by "python -m vdsClient"
If vdsClient is run in this way, "sys.path[0]" will be the current
directory[1]. So when run unde vdsm project source directory, the bad
import path appears before site-packages.

Instead, this patch runs vdsClient by
  python /usr/share/vdsm/vdsClient.py
the "sys.path[0]" will be /usr/share/vdsm, so we avoid to have current
directory appear firstly in the "sys.path".

References:
[1] http://docs.python.org/using/cmdline.html#cmdoption-m

Change-Id: Id22b657d26dae8dfc80905b11d5eba0c5a25e2c7
Signed-off-by: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>
---
M vdsm_cli/vdsClient.in
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/8758/1

diff --git a/vdsm_cli/vdsClient.in b/vdsm_cli/vdsClient.in
index 7e306f9..6d4a4a0 100755
--- a/vdsm_cli/vdsClient.in
+++ b/vdsm_cli/vdsClient.in
@@ -1,3 +1,8 @@
 #!/bin/sh
 
-PYTHONPATH="@VDSMDIR@:$PYTHONPATH" python -m vdsClient "$@"
+if [ -z "$PYTHONPATH" ]; then
+	PYTHONPATH="@VDSMDIR@"
+else
+	PYTHONPATH="@VDSMDIR@:$PYTHONPATH"
+fi
+python "@VDSMDIR@/vdsClient.py" "$@"


--
To view, visit http://gerrit.ovirt.org/8758
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id22b657d26dae8dfc80905b11d5eba0c5a25e2c7
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <zhshzhou at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list