From 8550730aff8db8061ed13537e0b9f7a7492342e1 Mon Sep 17 00:00:00 2001 From: "iap10@labyrinth.cl.cam.ac.uk" Date: Thu, 4 Nov 2004 10:33:34 +0000 Subject: bitkeeper revision 1.1159.1.364 (418a057eM4RcTJveJTOXENObPg0_SQ) Cset exclude: mwilli2@equilibrium.research|ChangeSet|20041103171613|48470 --- tools/python/xen/sv/Daemon.py | 5 ++--- tools/python/xen/util/Brctl.py | 6 ++---- tools/python/xen/util/ip.py | 8 +++---- tools/python/xen/xend/Blkctl.py | 3 +-- tools/python/xen/xend/server/SrvDaemon.py | 5 ++--- tools/python/xen/xend/server/blkif.py | 3 +-- tools/python/xen/xend/util.py | 36 ------------------------------- 7 files changed, 11 insertions(+), 55 deletions(-) diff --git a/tools/python/xen/sv/Daemon.py b/tools/python/xen/sv/Daemon.py index 8aeb58720e..510cfa9f04 100644 --- a/tools/python/xen/sv/Daemon.py +++ b/tools/python/xen/sv/Daemon.py @@ -11,7 +11,6 @@ import sys import re from xen.sv.params import * -from xen.xend import util from twisted.internet import reactor from twisted.web import static, server, script @@ -30,7 +29,7 @@ class Daemon: cmdex = '(?P.*)' procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$') xendre = re.compile('^/usr/sbin/xend\s*(start|restart)\s*.*$') - procs = util.popen('ps -e -o pid,args 2>/dev/null') + procs = os.popen('ps -e -o pid,args 2>/dev/null') for proc in procs: pm = procre.match(proc) if not pm: continue @@ -58,7 +57,7 @@ class Daemon: return 0 # Read the pid of the previous invocation and search active process list. pid = open(PID_FILE, 'r').read() - lines = util.popen('ps ' + pid + ' 2>/dev/null').readlines() + lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines() for line in lines: if re.search('^ *' + pid + '.+xensv', line): if not kill: diff --git a/tools/python/xen/util/Brctl.py b/tools/python/xen/util/Brctl.py index 569d1b3357..7a6f4871df 100644 --- a/tools/python/xen/util/Brctl.py +++ b/tools/python/xen/util/Brctl.py @@ -5,8 +5,6 @@ import os.path import re import sys -from xen.xend import util - os.defpath = os.defpath + ':/sbin:/usr/sbin:/usr/local/sbin' CMD_IFCONFIG = 'ifconfig' CMD_ROUTE = 'route' @@ -83,7 +81,7 @@ def bridge_del(bridge): def routes(): """Return a list of the routes. """ - fin = util.popen(CMD_ROUTE + ' -n', 'r') + fin = os.popen(CMD_ROUTE + ' -n', 'r') routes = [] for x in fin: if x.startswith('Kernel'): continue @@ -104,7 +102,7 @@ def routes(): def ifconfig(interface): """Return the ip config for an interface, """ - fin = util.popen(CMD_IFCONFIG + ' %s' % interface, 'r') + fin = os.popen(CMD_IFCONFIG + ' %s' % interface, 'r') inetre = re.compile('\s*inet\s*addr:(?P
\S*)\s*Bcast:(?P\S*)\s*Mask:(?P\S*)') info = None for x in fin: diff --git a/tools/python/xen/util/ip.py b/tools/python/xen/util/ip.py index d130f19421..9dd558a178 100644 --- a/tools/python/xen/util/ip.py +++ b/tools/python/xen/util/ip.py @@ -4,8 +4,6 @@ import socket import struct import errno -from xen.xend import util - def _readlines(fd): """Version of readlines safe against EINTR. """ @@ -51,7 +49,7 @@ def get_current_ipaddr(dev='eth0'): returns interface address as a string """ - fd = util.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) + fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) lines = _readlines(fd) for line in lines: m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*', @@ -69,7 +67,7 @@ def get_current_ipmask(dev='eth0'): returns interface netmask as a string """ - fd = util.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) + fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' ) lines = _readlines(fd) for line in lines: m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*', @@ -87,7 +85,7 @@ def get_current_ipgw(dev='eth0'): returns gateway address as a string """ - fd = util.popen( '/sbin/route -n' ) + fd = os.popen( '/sbin/route -n' ) lines = _readlines(fd) for line in lines: m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' + diff --git a/tools/python/xen/xend/Blkctl.py b/tools/python/xen/xend/Blkctl.py index f912a42473..a5bda19470 100644 --- a/tools/python/xen/xend/Blkctl.py +++ b/tools/python/xen/xend/Blkctl.py @@ -5,7 +5,6 @@ import os.path import sys import string -from xen.xend import util from xen.xend import XendRoot xroot = XendRoot.instance() @@ -36,7 +35,7 @@ def block(op, type, dets, script=None): script = os.path.join(SCRIPT_DIR, script) args = [op] + string.split(dets, ':') args = ' '.join(args) - out = util.popen(script + ' ' + args) + out = os.popen(script + ' ' + args) output = out.readline() out.close() diff --git a/tools/python/xen/xend/server/SrvDaemon.py b/tools/python/xen/xend/server/SrvDaemon.py index a95e1124d7..41a5965221 100644 --- a/tools/python/xen/xend/server/SrvDaemon.py +++ b/tools/python/xen/xend/server/SrvDaemon.py @@ -34,7 +34,6 @@ from xen.xend.XendError import XendError from xen.xend.server import SrvServer from xen.xend import XendRoot from xen.xend.XendLogging import log -from xen.xend import util import channel import blkif @@ -337,7 +336,7 @@ class Daemon: cmdex = '(?P.*)' procre = re.compile('^\s*' + pidex + '\s*' + pythonex + '\s*' + cmdex + '$') xendre = re.compile('^/usr/sbin/xend\s*(start|restart)\s*.*$') - procs = util.popen('ps -e -o pid,args 2>/dev/null') + procs = os.popen('ps -e -o pid,args 2>/dev/null') for proc in procs: pm = procre.match(proc) if not pm: continue @@ -383,7 +382,7 @@ class Daemon: """ running = 0 if pid: - lines = util.popen('ps %d 2>/dev/null' % pid).readlines() + lines = os.popen('ps %d 2>/dev/null' % pid).readlines() exp = '^ *%d.+%s' % (pid, name) for line in lines: if re.search(exp, line): diff --git a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py index df32613470..9ca8eab5fe 100755 --- a/tools/python/xen/xend/server/blkif.py +++ b/tools/python/xen/xend/server/blkif.py @@ -8,7 +8,6 @@ from xen.xend import sxp from xen.xend import Blkctl from xen.xend.XendLogging import log from xen.xend.XendError import XendError, VmError -from xen.xend import util import os import re @@ -26,7 +25,7 @@ def expand_dev_name(name): def check_mounted(self, name): mode = None name = expand_dev_name(name) - lines = util.popen('mount 2>/dev/null').readlines() + lines = os.popen('mount 2>/dev/null').readlines() exp = re.compile('^' + name + ' .*[\(,]r(?P[ow])[,\)]') for line in lines: pm = exp.match(line) diff --git a/tools/python/xen/xend/util.py b/tools/python/xen/xend/util.py index 111d8cd011..e69de29bb2 100644 --- a/tools/python/xen/xend/util.py +++ b/tools/python/xen/xend/util.py @@ -1,36 +0,0 @@ -# Misc utility functions for Xend -# (c) 2004 Mark A. Williamson - -from twisted.internet import utils -from twisted.internet import reactor -from XendLogging import log -from StringIO import StringIO - -# This is rather distasteful. Twisted doesn't play nicely with Python's -# standard os.popen, so here's an implementation of a synchronous popen that -# should work reliably. - MAW -def popen(cmd): - global done_flag, result - - done_flag = False - result = '' - - def done(output): - global done_flag, result - done_flag = True - result = output - - def err(output): - global done_flag -# For normal use, suppress debug output here. It grumbles about stderr if the -# program exits with $? != 0, even if stderr is redirected. Grrr! -# log.debug("util.popen(\'%s\'): %s" % (cmd, output)) - done_flag = True - - d = utils.getProcessOutput(cmd) - d.addCallbacks(done, err) - - while not done_flag: - reactor.iterate() - - return StringIO(result) -- cgit v1.2.3