本文整理汇总了Python中xen.xend.XendLogging.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: waitForDevice
def waitForDevice(self, devid):
log.debug("Waiting for %s.", devid)
status = self.waitForBackend(devid)
if status == Timeout:
self.destroyDevice(devid)
raise VmError("Device %s (%s) could not be connected. "
"Hotplug scripts not working." %
(devid, self.deviceClass))
elif status == Error:
self.destroyDevice(devid)
raise VmError("Device %s (%s) could not be connected. "
"Backend device not found." %
(devid, self.deviceClass))
elif status == Missing:
# Don't try to destroy the device; it's already gone away.
raise VmError("Device %s (%s) could not be connected. "
"Device not found." % (devid, self.deviceClass))
elif status == Busy:
err = None
frontpath = self.frontendPath(devid)
backpath = xstransact.Read(frontpath, "backend")
if backpath:
err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE)
if not err:
err = "Busy."
self.destroyDevice(devid)
raise VmError("Device %s (%s) could not be connected.\n%s" %
(devid, self.deviceClass, err))
示例2: waitForBackend
def waitForBackend(self, devid):
frontpath = self.frontendPath(devid)
# lookup a phantom
phantomPath = xstransact.Read(frontpath, 'phantom_vbd')
if phantomPath is not None:
log.debug("Waiting for %s's phantom %s.", devid, phantomPath)
statusPath = phantomPath + '/' + HOTPLUG_STATUS_NODE
ev = Event()
result = { 'status': Timeout }
xswatch(statusPath, hotplugStatusCallback, ev, result)
ev.wait(DEVICE_CREATE_TIMEOUT)
err = xstransact.Read(statusPath, HOTPLUG_ERROR_NODE)
if result['status'] != 'Connected':
return (result['status'], err)
backpath = xstransact.Read(frontpath, "backend")
if backpath:
statusPath = backpath + '/' + HOTPLUG_STATUS_NODE
ev = Event()
result = { 'status': Timeout }
xswatch(statusPath, hotplugStatusCallback, ev, result)
ev.wait(DEVICE_CREATE_TIMEOUT)
err = xstransact.Read(backpath, HOTPLUG_ERROR_NODE)
return (result['status'], err)
else:
return (Missing, None)
示例3: createSocket
def createSocket(self):
from OpenSSL import SSL
# make a SSL socket
ctx = SSL.Context(SSL.SSLv23_METHOD)
ctx.set_options(SSL.OP_NO_SSLv2)
ctx.use_privatekey_file (self.ssl_key_file)
ctx.use_certificate_file(self.ssl_cert_file)
sock = SSL.Connection(ctx,
socket.socket(socket.AF_INET, socket.SOCK_STREAM))
sock.set_accept_state()
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# SO_REUSEADDR does not always ensure that we do not get an address
# in use error when restarted quickly
# we implement a timeout to try and avoid failing unnecessarily
timeout = time.time() + 30
while True:
try:
if not self.isValidIP(self.interface):
self.interface = self.getIfAddr(self.interface)
log.debug("Listening on %s:%s" % (self.interface, self.port))
sock.bind((self.interface, self.port))
return sock
except socket.error, (_errno, strerrno):
if _errno == errno.EADDRINUSE and time.time() < timeout:
time.sleep(0.5)
else:
raise
示例4: show_dict
def show_dict(self,dict=None):
if self.debug == 0 :
return
if dict == None :
dict = self.udi_dict
for key in dict:
log.debug('udi_info %s udi_info:%s',key,dict[key])
示例5: recv2fd
def recv2fd(sock, fd):
try:
while True:
try:
data = sock.recv(BUFFER_SIZE)
if data == "":
break
count = 0
while count < len(data):
try:
nbytes = os.write(fd, data[count:])
count += nbytes
except os.error, ex:
if ex.args[0] not in (EWOULDBLOCK, EAGAIN, EINTR):
raise
except socket.error, ex:
if ex.args[0] not in (EWOULDBLOCK, EAGAIN, EINTR):
break
except (SSL.WantReadError, SSL.WantWriteError, \
SSL.WantX509LookupError):
# The operation did not complete; the same I/O method
# should be called again.
continue
except SSL.ZeroReturnError:
# The SSL Connection has been closed.
break
except SSL.SysCallError, (retval, desc):
if ((retval == -1 and desc == "Unexpected EOF")
or retval > 0):
# The SSL Connection is lost.
break
log.debug("SSL SysCallError:%d:%s" % (retval, desc))
break
示例6: fd2send
def fd2send(sock, fd):
try:
while True:
try:
data = os.read(fd, BUFFER_SIZE)
if data == "":
break
count = 0
while count < len(data):
try:
nbytes = sock.send(data[count:])
count += nbytes
except socket.error, ex:
if ex.args[0] not in (EWOULDBLOCK, EAGAIN, EINTR):
raise
except (SSL.WantReadError, SSL.WantWriteError, \
SSL.WantX509LookupError):
# The operation did not complete; the same I/O method
# should be called again.
continue
except SSL.ZeroReturnError:
# The SSL Connection has been closed.
raise
except SSL.SysCallError, (retval, desc):
if not (retval == -1 and data == ""):
# errors when writing empty strings are expected
# and can be ignored
log.debug("SSL SysCallError:%d:%s" % (retval, desc))
raise
except SSL.Error, e:
# other SSL errors
log.debug("SSL Error:%s" % e)
raise
示例7: device_added_callback
def device_added_callback(self,udi):
log.debug('UDI %s was added', udi)
self.show_dict(self.udi_dict)
dev_obj = self.bus.get_object ('org.freedesktop.Hal', udi)
dev = dbus.Interface (dev_obj, 'org.freedesktop.Hal.Device')
device = dev.GetProperty ('block.device')
major = dev.GetProperty ('block.major')
minor = dev.GetProperty ('block.minor')
udi_info = {}
udi_info['device'] = device
udi_info['major'] = major
udi_info['minor'] = minor
udi_info['udi'] = udi
already = 0
cnt = 0;
for key in self.udi_dict:
info = self.udi_dict[key]
if info['udi'] == udi:
already = 1
break
cnt = cnt + 1
if already == 0:
self.udi_dict[cnt] = udi_info;
log.debug('UDI %s was added, device:%s major:%s minor:%s index:%d\n', udi, device, major, minor, cnt)
self.change_xenstore( "add", device, major, minor)
示例8: __matchPCIdev
def __matchPCIdev( self, list ):
ret = False
if list == None:
return False
for id in list:
if id.startswith(self.devid[:9]): # id's vendor and device ID match
skey = id.split(':')
size = len(skey)
if (size == 2): # subvendor/subdevice not suplied
ret = True
break
elif (size == 4): # check subvendor/subdevice
# check subvendor
subven = '%04x' % self.subvendor
if ((skey[2] != 'FFFF') and
(skey[2] != 'ffff') and
(skey[2] != subven)):
continue
# check subdevice
subdev = '%04x' % self.subdevice
if ((skey[3] != 'FFFF') and
(skey[3] != 'ffff') and
(skey[3] != subdev)):
continue
ret = True
break
else:
log.debug("WARNING: invalid configuration entry: %s" % id)
ret = False
break
return ret
示例9: do_FLR_for_GM45_iGFX
def do_FLR_for_GM45_iGFX(self):
reg32 = self.pci_conf_read32(PCI_CAP_IGFX_CAP09_OFFSET)
if ((reg32 >> 16) & 0x000000FF) != 0x06 or \
((reg32 >> 24) & 0x000000F0) != 0x20:
return
self.pci_conf_write8(PCI_CAP_IGFX_GDRST_OFFSET, PCI_CAP_IGFX_GDRST)
for i in range(0, 10):
time.sleep(0.100)
reg8 = self.pci_conf_read8(PCI_CAP_IGFX_GDRST_OFFSET)
if (reg8 & 0x01) == 0:
break
if i == 10:
log.debug("Intel iGFX FLR fail on GM45")
return
# This specific reset will hang if the command register does not have
# memory space access enabled
cmd = self.pci_conf_read16(PCI_COMMAND)
self.pci_conf_write16(PCI_COMMAND, (cmd | 0x02))
af_pos = PCI_CAP_IGFX_CAP09_OFFSET
self.do_AF_FLR(af_pos)
self.pci_conf_write16(PCI_COMMAND, cmd)
log.debug("Intel iGFX FLR on GM45 done")
示例10: decode
def decode(self, uri):
for scheme in self.schemes:
try:
# If this passes, it is the correct scheme
return scheme.decode(uri)
except scheme_error, se:
log.debug("Decode throws an error: '%s'" % se)
示例11: op_start
def op_start(self, _, req):
self.acceptCommand(req)
paused = False
if 'paused' in req.args and req.args['paused'] == [1]:
paused = True
log.debug("Starting domain " + self.dom.getName() + " " + str(paused))
return self.xd.domain_start(self.dom.getName(), paused)
示例12: get_host_block_device_io
def get_host_block_device_io(self):
# iostat | grep "sd*" | awk '{if (NF==6 && ($1 ~ /sd/)) print $1, $(NR-1), $NR}'
usage_at = time.time()
cmd = "iostat | grep \"sd*\"| awk '{if (NF==6 && ($1 ~ /sd/)) print $1, $NF-1, $NF}'"
# log.debug(cmd)
(rc, stdout, stderr) = doexec(cmd)
out = stdout.read()
result = []
if rc != 0:
err = stderr.read();
stderr.close();
stdout.close();
log.debug('Failed to excute iostat!error:%s' % err)
return result
else:
try:
if out:
lines = out.split('\n')
for line in lines:
if line.strip() and len(line.strip().split()) == 3:
dev, rd_stat, wr_stat = line.strip().split()
rd_stat = int(rd_stat)
wr_stat = int(wr_stat)
l = (usage_at, dev, rd_stat, wr_stat)
result.append(l)
except Exception, exn:
log.debug(exn)
finally:
示例13: waitForDevice
def waitForDevice(self, devid):
log.debug("Waiting for %s.", devid)
if not self.hotplug:
return
(status, err) = self.waitForBackend(devid)
if status == Timeout:
self.destroyDevice(devid, False)
raise VmError("Device %s (%s) could not be connected. "
"Hotplug scripts not working." %
(devid, self.deviceClass))
elif status == Error:
self.destroyDevice(devid, False)
if err is None:
raise VmError("Device %s (%s) could not be connected. "
"Backend device not found." %
(devid, self.deviceClass))
else:
raise VmError("Device %s (%s) could not be connected. "
"%s" % (devid, self.deviceClass, err))
elif status == Missing:
# Don't try to destroy the device; it's already gone away.
raise VmError("Device %s (%s) could not be connected. "
"Device not found." % (devid, self.deviceClass))
elif status == Busy:
self.destroyDevice(devid, False)
if err is None:
err = "Busy."
raise VmError("Device %s (%s) could not be connected.\n%s" %
(devid, self.deviceClass, err))
示例14: main
def main(self):
try:
while True:
try:
data = self.sock.recv(BUFFER_SIZE)
if data == "":
break
if self.protocol.dataReceived(data):
break
except socket.error, ex:
if ex.args[0] not in (EWOULDBLOCK, EAGAIN, EINTR):
break
except (SSL.WantReadError, SSL.WantWriteError, \
SSL.WantX509LookupError):
# The operation did not complete; the same I/O method
# should be called again.
continue
except SSL.ZeroReturnError:
# The SSL Connection has been closed.
break
except SSL.SysCallError, (retval, desc):
if ((retval == -1 and desc == "Unexpected EOF")
or retval > 0):
# The SSL Connection is lost.
break
log.debug("SSL SysCallError:%d:%s" % (retval, desc))
break
示例15: forkHelper
def forkHelper(cmd, fd, inputHandler, closeToChild):
child = xPopen3(cmd, True, -1, [fd])
if closeToChild:
child.tochild.close()
thread = threading.Thread(target = slurp, args = (child.childerr,))
thread.start()
try:
try:
while 1:
line = child.fromchild.readline()
if line == "":
break
else:
line = line.rstrip()
log.debug('%s', line)
inputHandler(line, child.tochild)
except IOError, exn:
raise XendError('Error reading from child process for %s: %s' %
(cmd, exn))
finally:
child.fromchild.close()
if not closeToChild:
child.tochild.close()
thread.join()
child.childerr.close()
status = child.wait()
if status >> 8 == 127:
raise XendError("%s failed: popen failed" % string.join(cmd))
elif status != 0:
raise XendError("%s failed" % string.join(cmd))