当前位置: 首页>>代码示例>>Python>>正文


Python Logging.debug方法代码示例

本文整理汇总了Python中Logging.Logging.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.debug方法的具体用法?Python Logging.debug怎么用?Python Logging.debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logging.Logging的用法示例。


在下文中一共展示了Logging.debug方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: umount

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def umount(self):
		if os.path.exists(self.mountPoint) and os.path.isdir(self.mountPoint):
			Logging.debug("Unmounting %s." % self.mountPoint)
			
			mountProcess = subprocess.Popen(["/bin/umount", self.mountPoint])
			mountProcess.wait()
			
			if mountProcess.returncode == 0 and len(os.listdir(self.mountPoint)) == 0:
				if self.createdMountPoint:
					Logging.debug("Deleting mounting point: %s" % self.mountPoint)
					os.rmdir(self.mountPoint)
					self.createdMountPoint = False
				
				return True
		
		return False
开发者ID:jaxxer,项目名称:aivm,代码行数:18,代码来源:Location.py

示例2: download

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def download(self):
		fileName = self.path.rsplit("/", 1)
		filePath = "%s/%i-%s" % (self.tempStorage, hash(self), fileName[1])
		
		if os.path.exists(filePath):
			self.path = filePath
			self.downloaded = True
			return self.downloaded
		
		Logging.debug("Trying download %s to %s." % (self.path, filePath))
		
		try:
			httpRequest = urllib2.urlopen(self.path)
		
		except urllib2.HTTPError as e:
			return None
		
		
		if (not os.path.exists(self.tempStorage)
				or not os.access(self.tempStorage, os.W_OK)
				or System.getFreeSpace(self.tempStorage) < int(httpRequest.info().get("Content-Length"))):
			
			return None
		
		try:
			iso = file(filePath, "w")
			while 1:
				buf = httpRequest.read(16*1024)
				
				if not buf:
					break
				
				iso.write(buf)
			
			iso.close()
		
		except IOError as e:
			return None
		
		self.path = filePath
		self.downloaded = os.path.exists(filePath)
		
		return self.downloaded
开发者ID:jaxxer,项目名称:aivm,代码行数:45,代码来源:Location.py

示例3: getNetwork

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def getNetwork(self):
		self.stdin.write("\n")
		
		stdoutRead = open(self.stdout.name)
		stdoutRead.seek(0, os.SEEK_END)
		
		Logging.info("Getting network settings...")
		
		command = self.config.get("commands", "get")
		self.stdin.write("%s\necho ==GET-NETWORK-DONE==\n\n" % command)
		
		addresses = ""
		i = 0
		while not "\n==GET-NETWORK-DONE==" in addresses:
			addresses += stdoutRead.read()
			
			if i > 50:
				raise NetworkSetterError("Error occured while getting network settings from guest '%s'." % self.guest.getHostName())
			
			i += 1
			time.sleep(1)
		
		
		Logging.debug("Raw network settings: %s" % str(addresses))
		
		inets = re.findall("inet6?\s+([a-f0-9:./]+)", addresses)
		
		ipAddresses = map(lambda inet: inet.split("/"), inets)
		ipAddresses = filter(lambda ip: not ip[0].startswith("fe80"), ipAddresses)
		
		Logging.debug("Processed network settings: %s" % str(ipAddresses))
		
		ipDict = {}
		
		for ip in ipAddresses:
			ipDict[ip[0]] = self.guest.getHostName()
		
		time.sleep(2)
		stdoutRead.close()
		
		return ipDict
开发者ID:jaxxer,项目名称:aivm,代码行数:43,代码来源:Network.py

示例4: install

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def install(self, handler=DefaultHandler):
		self.setValues()
		destroy = None
		servers = self.startHttpd()
		
		master, slave = pty.openpty()
		
		stdin = os.fdopen(master, "w")
		
		logPath = self.log % self.values
		Logging.debug("Trying write install log of VM '%s' to %s."
										% (self.guest.getHostName(), logPath))
		stdout = open(logPath, "w")
		
		try:
			self.cmdInstall = self.cmdInstall.replace("\n", " ")
			
			Logging.info("Trying install guest '%s'..." % self.guest.getHostName())
			Logging.debug(self.cmdInstall % self.values)
			
			process = subprocess.Popen(self.cmdInstall % self.values, shell=True,
										stdin=slave, stdout=stdout, stderr=stdout,
										close_fds=True)
			
			analyzator = handler(stdin, stdout, process)
			analyzator.handle()
		except InstallationError as e:
			destroy = subprocess.Popen(self.cmdDestroy % self.values, shell=True)
			Logging.info("Check installation log for details: %s" % logPath)
			raise e
		finally:
			if servers[0]: servers[0].kill()
			if servers[1]: servers[1].kill()
		
		if destroy:
			return not destroy.wait()
		
		Logging.info("Guest '%s' installed." % self.guest.getHostName())
		
		return
开发者ID:jaxxer,项目名称:aivm,代码行数:42,代码来源:VirtInstall.py

示例5: insertDNS

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def insertDNS(self, dnsDict):
		conn = libvirt.open(DC.get("virsh", "connect"))
		xmlDesc = self.network.XMLDesc(0)
		
		Logging.debug("Inserting DNS entries: %s" % str(dnsDict))
		
		localDns = self.makeDNS(dnsDict)
		
		networkXml = xml.parseString(xmlDesc)
		dns = networkXml.getElementsByTagName("dns")
		
		if dns:
			dns = dns[0]
			for entry in localDns.getElementsByTagName("host"):
				dns.appendChild(entry)
		else:
			networkXml.documentElement.appendChild(localDns)
		
		
		self.network.destroy()
		self.network.undefine()
		
		self.network = conn.networkDefineXML(networkXml.documentElement.toxml())
		self.network.setAutostart(1)
		self.network.create()
		
		
		values = {'addr': self.getIPv6Address(), 'prefix': self.getIPv6Prefix(),
					'interface': self.getInterface()}
		
		if (DC.has_option("network", "manual-route")
				and DC.get("network", "manual-route", True)):
			cmd = DC.get("network", "manual-route", False, values)
			cmd = cmd.replace("\n", " ")
			
			subprocess.Popen(cmd, shell=True)
		else:
			Logging.warning("Manual route not set. Skipping.")
		
		return
开发者ID:jaxxer,项目名称:aivm,代码行数:42,代码来源:Network.py

示例6: mount

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def mount(self):
		if not os.path.exists(self.mountPoint) or not os.path.isdir(self.mountPoint):
			Logging.debug("Creating mounting point: %s" % self.mountPoint)
			os.makedirs(self.mountPoint)
			self.createdMountPoint = True
		
		if not os.path.exists(self.getPath()):
			raise IOError("Path '%s' does not exists." % self.getPath())
		
		Logging.debug("Mounting %s to %s." % (self.getPath(), self.mountPoint))
		
		mountProcess = subprocess.Popen(["/bin/mount", '-o', 'loop', self.getPath(), self.mountPoint])
		mountProcess.wait()
		
		if mountProcess.returncode == 0 and len(os.listdir(self.mountPoint)) > 0:
			treeinfo = "%s/.treeinfo" % self.mountPoint
			
			if not os.path.exists(treeinfo):
				Logging.warn("The image doesn't contain .treeinfo file.")
			else:
				cp = ConfigParser.ConfigParser()
				cp.read(treeinfo)
				
				if cp.has_section("general") and cp.has_option("general", "arch"):
					arch = cp.get("general", "arch")
					imagesArch = "images-%s" % arch
					
					if cp.has_section(imagesArch):
						if (not cp.has_option(imagesArch, "kernel")
								or not cp.has_option(imagesArch, "initrd")):
							raise IOError("There's no kernel or initrd option"
											" in '%s' section in .treeinfo file."
											% imagesArch)
					
			
			return True
		
		return False
开发者ID:jaxxer,项目名称:aivm,代码行数:40,代码来源:Location.py

示例7: setNetwork

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def setNetwork(self):
		self.stdin.write("\n")
		
		stdoutRead = open(self.stdout.name)
		stdoutRead.seek(0, os.SEEK_END)
		
		Logging.info("Trying set network...")
		
		settings = self.prepareData()
		commands = self.config.get("commands", "set", False, { "settings": settings })
		
		Logging.debug("Commands to write:\n%s" % str(commands))
		
		singleCommands = commands.split("\n")
		
		for cmd in singleCommands:
			self.stdin.write("%s\n" % cmd)
			time.sleep(0.1)
		
		self.stdin.write("\necho ==SET-NETWORK-DONE==\n\n")
		
		time.sleep(1)
		
		output = ""
		i = 0
		while not "\n==SET-NETWORK-DONE==" in output:
			output += stdoutRead.read()
			
			if i > 50:
				raise NetworkSetterError("Error occured while setting network settings from guest '%s'." % self.guest.getHostName())
			
			i += 1
			time.sleep(1)
		
		time.sleep(1)
		
		stdoutRead.close()
开发者ID:jaxxer,项目名称:aivm,代码行数:39,代码来源:Network.py

示例8: __del__

# 需要导入模块: from Logging import Logging [as 别名]
# 或者: from Logging.Logging import debug [as 别名]
	def __del__(self):
		if self.downloaded and os.path.exists(self.path):
			Logging.debug("Trying unlink file %s." % self.path)
			os.unlink(self.path)
开发者ID:jaxxer,项目名称:aivm,代码行数:6,代码来源:Location.py


注:本文中的Logging.Logging.debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。