direct-io.hg

changeset 7311:c5553e06a8bc

Added auxbin module, for handling auxillary binaries.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Tue Oct 11 14:59:52 2005 +0100 (2005-10-11)
parents 293f4417c089
children 713328270fb3
files tools/python/xen/util/auxbin.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/python/xen/util/auxbin.py	Tue Oct 11 14:59:52 2005 +0100
     1.3 @@ -0,0 +1,44 @@
     1.4 +#============================================================================
     1.5 +# This library is free software; you can redistribute it and/or
     1.6 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     1.7 +# License as published by the Free Software Foundation.
     1.8 +#
     1.9 +# This library is distributed in the hope that it will be useful,
    1.10 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.11 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.12 +# Lesser General Public License for more details.
    1.13 +#
    1.14 +# You should have received a copy of the GNU Lesser General Public
    1.15 +# License along with this library; if not, write to the Free Software
    1.16 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.17 +#============================================================================
    1.18 +# Copyright (C) 2005 XenSource Ltd
    1.19 +#============================================================================
    1.20 +
    1.21 +
    1.22 +LIB_BIN_32 = "/usr/lib/xen/bin"
    1.23 +LIB_BIN_64 = "/usr/lib64/xen/bin"
    1.24 +
    1.25 +
    1.26 +import os
    1.27 +import os.path
    1.28 +
    1.29 +
    1.30 +def execute(exe, args = None):
    1.31 +    exepath = pathTo(exe)
    1.32 +    a = [ exepath ]
    1.33 +    if args:
    1.34 +        a.extend(args)
    1.35 +    os.execv(exepath, a)
    1.36 +
    1.37 +
    1.38 +def pathTo(exe):
    1.39 +    return os.path.join(path(), exe)
    1.40 +
    1.41 +
    1.42 +def path():
    1.43 +    machine = os.uname()[4]
    1.44 +    if machine.find('64') != -1 and os.path.exists(LIB_BIN_64):
    1.45 +        return LIB_BIN_64
    1.46 +    else:
    1.47 +        return LIB_BIN_32