ChangeSet 1.1440, 2005/05/17 23:29:19+01:00, cl349@xxxxxxxxxxxxxxxxxxxx
Many files:
g/c _readline{,s} and use regular readline{,s} functions -- the
special
_readline{,s} functions were only needed because of Twisted.
ip.py:
Also use readlines() instead of xreadlines().
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>
sv/Daemon.py | 4 +---
util/blkif.py | 4 +---
util/ip.py | 38 ++++----------------------------------
xend/Blkctl.py | 2 --
xend/XendDomainInfo.py | 1 -
xend/encode.py | 4 +---
xend/server/SrvDaemon.py | 4 +---
xend/sxp.py | 3 +--
8 files changed, 9 insertions(+), 51 deletions(-)
diff -Nru a/tools/python/xen/sv/Daemon.py b/tools/python/xen/sv/Daemon.py
--- a/tools/python/xen/sv/Daemon.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/sv/Daemon.py 2005-05-17 19:05:06 -04:00
@@ -15,8 +15,6 @@
from twisted.internet import reactor
from twisted.web import static, server, script
-from xen.util.ip import _readline, _readlines
-
class Daemon:
"""The xend daemon.
"""
@@ -59,7 +57,7 @@
return 0
# Read the pid of the previous invocation and search active process
list.
pid = open(PID_FILE, 'r').read()
- lines = _readlines(os.popen('ps ' + pid + ' 2>/dev/null'))
+ lines = os.popen('ps ' + pid + ' 2>/dev/null').readlines()
for line in lines:
if re.search('^ *' + pid + '.+xensv', line):
if not kill:
diff -Nru a/tools/python/xen/util/blkif.py b/tools/python/xen/util/blkif.py
--- a/tools/python/xen/util/blkif.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/util/blkif.py 2005-05-17 19:05:06 -04:00
@@ -4,8 +4,6 @@
from xen.xend.XendLogging import log
-from xen.util.ip import _readline, _readlines
-
def expand_dev_name(name):
if not name:
return name
@@ -71,7 +69,7 @@
def mount_mode(name):
mode = None
name = expand_dev_name(name)
- lines = _readlines(os.popen('mount 2>/dev/null'))
+ lines = os.popen('mount 2>/dev/null').readlines()
exp = re.compile('^' + name + ' .*[\(,]r(?P<mode>[ow])[,\)]')
for line in lines:
pm = exp.match(line)
diff -Nru a/tools/python/xen/util/ip.py b/tools/python/xen/util/ip.py
--- a/tools/python/xen/util/ip.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/util/ip.py 2005-05-17 19:05:06 -04:00
@@ -4,41 +4,11 @@
import struct
import errno
-def _readlines(fd):
- """Version of readlines safe against EINTR.
- """
- import errno
-
- lines = []
- while 1:
- try:
- line = fd.readline()
- except IOError, ex:
- if ex.errno == errno.EINTR:
- continue
- else:
- raise
- if line == '': break
- lines.append(line)
- return lines
-
-def _readline(fd):
- """Version of readline safe against EINTR.
- """
- while 1:
- try:
- return fd.readline()
- except IOError, ex:
- if ex.errno == errno.EINTR:
- continue
- else:
- raise
-
##### Networking-related functions
def get_defaultroute():
fd = os.popen('/sbin/ip route list 2>/dev/null')
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search('^default via ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) dev ([^
]*)',
line)
if m:
@@ -57,7 +27,7 @@
if not dev:
return
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^\s+inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
if m:
@@ -76,7 +46,7 @@
if not dev:
return
fd = os.popen( '/sbin/ifconfig ' + dev + ' 2>/dev/null' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^.+Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*',
line )
if m:
@@ -95,7 +65,7 @@
if not dev:
return
fd = os.popen( '/sbin/route -n' )
- for line in fd.xreadlines():
+ for line in fd.readlines():
m = re.search( '^\S+\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' +
'\s+\S+\s+\S*G.*' + dev + '.*', line )
if m:
diff -Nru a/tools/python/xen/xend/Blkctl.py b/tools/python/xen/xend/Blkctl.py
--- a/tools/python/xen/xend/Blkctl.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/xend/Blkctl.py 2005-05-17 19:05:06 -04:00
@@ -8,8 +8,6 @@
from xen.xend import XendRoot
-from xen.util.ip import _readline, _readlines
-
xroot = XendRoot.instance()
"""Where network control scripts live."""
diff -Nru a/tools/python/xen/xend/XendDomainInfo.py
b/tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/xend/XendDomainInfo.py 2005-05-17 19:05:06 -04:00
@@ -14,7 +14,6 @@
import xen.lowlevel.xc; xc = xen.lowlevel.xc.new()
import xen.util.ip
-from xen.util.ip import _readline, _readlines
from xen.xend.server import channel, controller
from xen.util.blkif import blkdev_uname_to_file
diff -Nru a/tools/python/xen/xend/encode.py b/tools/python/xen/xend/encode.py
--- a/tools/python/xen/xend/encode.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/xend/encode.py 2005-05-17 19:05:06 -04:00
@@ -14,8 +14,6 @@
import random
import md5
-from xen.util.ip import _readline, _readlines
-
# Extract from HTML4 spec.
## The following example illustrates "multipart/form-data"
## encoding. Suppose we have the following form:
@@ -124,7 +122,7 @@
out.write('"\r\n')
out.write('Content-Type: application/octet-stream\r\n')
out.write('\r\n')
- for l in _readlines(v):
+ for l in v.readlines():
out.write(l)
else:
out.write('Content-Disposition: form-data; name="')
diff -Nru a/tools/python/xen/xend/server/SrvDaemon.py
b/tools/python/xen/xend/server/SrvDaemon.py
--- a/tools/python/xen/xend/server/SrvDaemon.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/xend/server/SrvDaemon.py 2005-05-17 19:05:06 -04:00
@@ -27,8 +27,6 @@
from xen.xend import XendRoot
from xen.xend.XendLogging import log
-from xen.util.ip import _readline, _readlines
-
import channel
import controller
import event
@@ -99,7 +97,7 @@
"""
running = 0
if pid:
- lines = _readlines(os.popen('ps %d 2>/dev/null' % pid))
+ 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 -Nru a/tools/python/xen/xend/sxp.py b/tools/python/xen/xend/sxp.py
--- a/tools/python/xen/xend/sxp.py 2005-05-17 19:05:06 -04:00
+++ b/tools/python/xen/xend/sxp.py 2005-05-17 19:05:06 -04:00
@@ -17,7 +17,6 @@
import errno
import string
from StringIO import StringIO
-from xen.util.ip import _readline, _readlines
__all__ = [
"mime_type",
@@ -714,7 +713,7 @@
"""
pin = Parser()
while 1:
- buf = _readline(io)
+ buf = io.readline()
pin.input(buf)
if len(buf) == 0:
break
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|