bitkeeper revision 1.1440 (428a703fGt3asjVc5fTAW72ClnFOog)

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@cl.cam.ac.uk>
This commit is contained in:
cl349@firebug.cl.cam.ac.uk committed 2005-05-17 22:29:19 +00:00
1 parent 899c0f0840
commit 627aaffcb5
8 files changed
+9 -51

No files matched your search

+1 -3
View File
@@ -15,8 +15,6 @@ from xen.sv.params import *
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 @@ class Daemon:
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:
+1 -3
View File
@@ -4,8 +4,6 @@ import string
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 blkdev_uname_to_file(uname):
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)
+4 -34
View File
@@ -4,41 +4,11 @@ import socket
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 @@ def get_current_ipaddr(dev='defaultroute'):
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 @@ def get_current_ipmask(dev='defaultroute'):
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 @@ def get_current_ipgw(dev='defaultroute'):
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:
-2
View File
@@ -8,8 +8,6 @@ import xen.util.process
from xen.xend import XendRoot
from xen.util.ip import _readline, _readlines
xroot = XendRoot.instance()
"""Where network control scripts live."""
-1
View File
@@ -14,7 +14,6 @@ import time
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
+1 -3
View File
@@ -14,8 +14,6 @@ import httplib
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 @@ def encode_multipart(d):
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="')
+1 -3
View File
@@ -27,8 +27,6 @@ from xen.xend.server import SrvServer
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 @@ class Daemon:
"""
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):
+1 -2
View File
@@ -17,7 +17,6 @@ import types
import errno
import string
from StringIO import StringIO
from xen.util.ip import _readline, _readlines
__all__ = [
"mime_type",
@@ -714,7 +713,7 @@ def parse(io):
"""
pin = Parser()
while 1:
buf = _readline(io)
buf = io.readline()
pin.input(buf)
if len(buf) == 0:
break
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.