WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Vifctl.py:

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Vifctl.py:
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Mon, 16 May 2005 16:16:02 +0000
Delivery-date: Mon, 16 May 2005 17:03:31 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1420, 2005/05/16 17:16:02+01:00, cl349@xxxxxxxxxxxxxxxxxxxx

        Vifctl.py:
          Pass script output through logger.
        process.py:
          os.system() replacement which outputs through the logger
        Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>



 util/process.py |   31 +++++++++++++++++++++++++++++++
 xend/Vifctl.py  |    3 ++-
 2 files changed, 33 insertions(+), 1 deletion(-)


diff -Nru a/tools/python/xen/util/process.py b/tools/python/xen/util/process.py
--- /dev/null   Wed Dec 31 16:00:00 196900
+++ b/tools/python/xen/util/process.py  2005-05-16 13:04:08 -04:00
@@ -0,0 +1,31 @@
+# Copyright (C) 2005 Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
+
+# os.system() replacement which outputs through the logger
+
+import popen2
+import select
+
+from xen.xend.XendLogging import log
+
+def system(cmd):
+    # split after first space, then grab last component of path
+    cmdname = "[%s] " % cmd.split()[0].split('/')[-1]
+    # run command and grab stdin, stdout and stderr
+    cout, cin, cerr = popen2.popen3(cmd)
+    # close stdin to get command to terminate if it waits for input
+    cin.close()
+    # wait for output and process
+    p = select.poll()
+    p.register(cout)
+    p.register(cerr)
+    while True:
+        r = p.poll()
+        for (fd, event) in r:
+            if event == select.POLLHUP:
+                return
+            if fd == cout.fileno():
+                l = cout.readline()
+                log.info(cmdname + l.rstrip())
+            if fd == cerr.fileno():
+                l = cerr.readline()
+                log.error(cmdname + l.rstrip())
diff -Nru a/tools/python/xen/xend/Vifctl.py b/tools/python/xen/xend/Vifctl.py
--- a/tools/python/xen/xend/Vifctl.py   2005-05-16 13:04:08 -04:00
+++ b/tools/python/xen/xend/Vifctl.py   2005-05-16 13:04:08 -04:00
@@ -3,6 +3,7 @@
 import os
 import os.path
 import sys
+import xen.util.process
 
 from xen.xend import XendRoot
 xroot = XendRoot.instance()
@@ -35,7 +36,7 @@
     else:
         args.append("antispoof=no")
     args = ' '.join(args)
-    os.system(script + ' ' + args)
+    xen.util.process.system(script + ' ' + args)
 
 def set_vif_name(vif_old, vif_new):
     if vif_old == vif_new:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Vifctl.py:, BitKeeper Bot <=