[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Use python discovered through env instead of hardcoding a path



This is more flexible regarding the location of the python binary
but doesn't allow to pass the -u flag. The -i flag can be passed
from inside the script using the PYTHONINSPECT env variable.

This fixes a problem with the esx_vi_generator.py on FreeBSD.
---
 examples/python/dominfo.py    |    2 +-
 examples/python/domrestore.py |    2 +-
 examples/python/domsave.py    |    2 +-
 examples/python/domstart.py   |    2 +-
 examples/python/esxlist.py    |    2 +-
 python/generator.py           |    2 +-
 python/libvirt-override.py    |    5 +++++
 src/esx/esx_vi_generator.py   |    2 +-
 8 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/examples/python/dominfo.py b/examples/python/dominfo.py
index e41709c..2f250e7 100755
--- a/examples/python/dominfo.py
+++ b/examples/python/dominfo.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 # dominfo - print some information about a domain
 
 import libvirt
diff --git a/examples/python/domrestore.py b/examples/python/domrestore.py
index b032138..ccc82f6 100755
--- a/examples/python/domrestore.py
+++ b/examples/python/domrestore.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 # domstart - make sure a given domU is running, if not start it
 
 import libvirt
diff --git a/examples/python/domsave.py b/examples/python/domsave.py
index 35e2c8a..12ffac1 100755
--- a/examples/python/domsave.py
+++ b/examples/python/domsave.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 # domstart - make sure a given domU is running, if not start it
 
 import libvirt
diff --git a/examples/python/domstart.py b/examples/python/domstart.py
index 52fb79e..b1e89b8 100755
--- a/examples/python/domstart.py
+++ b/examples/python/domstart.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 # domstart - make sure a given domU is running, if not start it
 
 import libvirt
diff --git a/examples/python/esxlist.py b/examples/python/esxlist.py
index a0602e8..c55424f 100755
--- a/examples/python/esxlist.py
+++ b/examples/python/esxlist.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python
 # esxlist - list active domains of an ESX host and print some info.
 #           also demonstrates how to use the libvirt.openAuth() method
 
diff --git a/python/generator.py b/python/generator.py
index 68009b9..15751bd 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -1010,7 +1010,7 @@ def buildWrappers():
     classes = open("libvirt.py", "w")
 
     extra = open(os.path.join(srcPref,"libvirt-override.py"), "r")
-    classes.write("#!/usr/bin/python -i\n")
+    classes.write("#!/usr/bin/env python\n")
     classes.write("#\n")
     classes.write("# WARNING WARNING WARNING WARNING\n")
     classes.write("#\n")
diff --git a/python/libvirt-override.py b/python/libvirt-override.py
index d544a0e..909ebe3 100644
--- a/python/libvirt-override.py
+++ b/python/libvirt-override.py
@@ -2,6 +2,11 @@
 # Manually written part of python bindings for libvirt
 #
 
+# Specify -i commandline option after python was started
+if __name__ == "__main__":
+    import os
+    os.environ["PYTHONINSPECT"] = "1"
+
 # On cygwin, the DLL is called cygvirtmod.dll
 try:
     import libvirtmod
diff --git a/src/esx/esx_vi_generator.py b/src/esx/esx_vi_generator.py
index 01636aa..4593379 100755
--- a/src/esx/esx_vi_generator.py
+++ b/src/esx/esx_vi_generator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 
 #
 # esx_vi_generator.py: generates most of the SOAP type mapping code
-- 
1.7.0.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]