Richard W.M. Jones
2015-Sep-16 12:07 UTC
[Libguestfs] [PATCH] python: Set program name to the true name instead of 'python'.
As in commit e102bcf3cfcbcb2b47ad88334f03d5abf636f1e5 (for Perl), any
Python program has the handle program name field set to 'python'. Set
it to the true name (derived from sys.argv[0]).
---
generator/python.ml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/generator/python.ml b/generator/python.ml
index c1128f8..1e043fc 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -671,6 +671,8 @@ logvols = g.lvs ()
\"\"\"
+import os
+import sys
import libguestfsmod
";
@@ -714,6 +716,10 @@ class GuestFS(object):
self._o = libguestfsmod.create (flags)
self._python_return_dict = python_return_dict
+ # If we don't do this, the program name is always set to
'python'.
+ program = os.path.basename (sys.argv[0])
+ libguestfsmod.set_program (self._o, program)
+
def __del__ (self):
if self._o:
libguestfsmod.close (self._o)
--
2.5.0
