[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Break out the Python path interrogation into a separate script. This has the
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Date 1170334133 0 # Node ID afb41f6bc30a9bde738f355b401f7ae6bcaf3d7d # Parent f73e71aa0a9036e759f5fecadf5fbe4a511fda80 Break out the Python path interrogation into a separate script. This has the advantage that the temporary path manipulation cannot affect the main script, and that it can be shared with other programs, such as xm-test. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/misc/Makefile | 2 +- tools/misc/xen-python-path | 41 +++++++++++++++++++++++++++++++++++++++++ tools/misc/xend | 22 ++++++---------------- 3 files changed, 48 insertions(+), 17 deletions(-) diff -r f73e71aa0a90 -r afb41f6bc30a tools/misc/Makefile --- a/tools/misc/Makefile Thu Feb 01 11:55:31 2007 +0000 +++ b/tools/misc/Makefile Thu Feb 01 12:48:53 2007 +0000 @@ -12,7 +12,7 @@ TARGETS = xenperf xc_shadow TARGETS = xenperf xc_shadow INSTALL_BIN = $(TARGETS) xencons -INSTALL_SBIN = netfix xm xen-bugtool xend xenperf +INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf .PHONY: all all: build diff -r f73e71aa0a90 -r afb41f6bc30a tools/misc/xen-python-path --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/misc/xen-python-path Thu Feb 01 12:48:53 2007 +0000 @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# -*- mode: python; -*- +#============================================================================ +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +#============================================================================ +# Copyright (C) 2007 XenSource Inc. +#============================================================================ + + +# Use the auxbin module in Xend to determine the correct Python path. We +# take the first installed instance of auxbin that we find, and then run it +# to determine the correct path, appending that to sys.path. + +AUXBIN = 'xen/util/auxbin.py' + +import os +import os.path +import sys + +for p in ['python%s' % sys.version[:3], 'python']: + for l in ['/usr/lib64', '/usr/lib']: + d = os.path.join(l, p) + if os.path.exists(os.path.join(d, AUXBIN)): + sys.path.append(d) + import xen.util.auxbin + print os.path.join(xen.util.auxbin.libpath(), p) + sys.exit(0) + +print >>sys.stderr, "Cannot find Xen Python modules." +sys.exit(1) diff -r f73e71aa0a90 -r afb41f6bc30a tools/misc/xend --- a/tools/misc/xend Thu Feb 01 11:55:31 2007 +0000 +++ b/tools/misc/xend Thu Feb 01 12:48:53 2007 +0000 @@ -31,23 +31,13 @@ import time import time import commands +result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]), + 'xen-python-path')) +if result[0] != 0: + print >>sys.stderr, result[1] + sys.exit(1) -# Use the auxbin module in Xend to determine the correct Python path. We -# take the first installed instance of auxbin that we find, and then run it -# to determine the correct path, appending that to sys.path. - -AUXBIN = 'xen/util/auxbin.py' - -for p in ['python%s' % sys.version[:3], 'python']: - for l in ['/usr/lib64', '/usr/lib']: - d = os.path.join(l, p) - if os.path.exists(os.path.join(d, AUXBIN)): - sys.path.append(d) - import xen.util.auxbin - libpath = os.path.join(xen.util.auxbin.libpath(), p) - sys.path = sys.path[:-1] - sys.path.append(libpath) - break +sys.path.append(result[1]) from xen.xend.server import SrvDaemon _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |