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


Python console.log函数代码示例

本文整理汇总了Python中wolfpack.console.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: checkRestockInventory

	def checkRestockInventory(self, vendor, force = False):
		# If the inventory check is not forced,
		# see if the last check was performed more than an hour ago
		if not force:
			vendor_magic = vendor.gettag('magic')
			if vendor_magic == magic:
				return

		restock = vendor.itemonlayer(LAYER_NPCRESTOCK)
		if restock:
			restock.delete() # Delete the old restock container

		restock = self.getRestockContainer(vendor) # Create a new restock container

		# Recreate the content from our buyitems array
		for i in range(0, len(self.buylist)):
			dispitem = self.buylist[i].createDisplayItem() # Try to create a display item
			
			# Unable to create display item
			if not dispitem:
				console.log(LOG_ERROR, "Unable to create display item for buyitem at index %u for vendor 0x%x.\n" % (i, vendor.serial))
				continue
				
			dispitem.settag('buyitemindex', i) # Store the index of the buyitem that created the dispitem
			restock.additem(dispitem) # Add the dispitem to the restock container

		# Once the check has been completed, save the vendor magic
		vendor.settag('magic', magic)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:28,代码来源:__init__.py

示例2: onUpdateDatabase

def onUpdateDatabase(current, version):
	# Find the update table for the database driver in use
	driver = database.driver(WORLD)
	if driver == 'mysql':
		updates = MYSQL_UPDATES
	elif driver == 'sqlite':
		updates = SQLITE_UPDATES
	else:
		console.log(LOG_ERROR, "Unknown database driver: %s.\n" % driver)
		return False

	for i in range(version, current):
		# No update for this version available
		if not updates.has_key(i):
			console.log(LOG_ERROR, "No update available for database version %u.\n" % i)
			return False

		console.log(LOG_MESSAGE, "Updating database from version %u to %u.\n" % (i, i+1))

		try:
			if not updates[i]():
				return False
		except Exception, e:
			console.log(LOG_ERROR, str(e) + "\n")
			return False

		wolfpack.setoption('db_version', str(i + 1))
		try:
			if driver == 'mysql':
				database.execute("REPLACE INTO `settings` VALUES('db_version', '%u');" % (i + 1))
			elif driver == 'sqlite':
				database.execute("REPLACE INTO settings VALUES('db_version', '%u');" % (i + 1))
		except Exception, e:
			console.log(LOG_WARNING, "Unable to update database version to %u:\n%s\n" % (i + 1, str(e)))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:34,代码来源:dbupdate.py

示例3: updatebook

def updatebook(socket, packet):
	item = wolfpack.finditem(packet.getint(3))

	if not item:
		console.log(LOG_ERROR, "Client tried to update non existing book %x." % (packet.getint(3)))
		return 1

	title_length = packet.getshort(11)
	title = ""
	for i in range(0, title_length):
		byte = packet.getbyte(13 + i)
		if byte > 0:
			title += chr(byte)
	title = unicode(title, 'utf-8')

	author_length = packet.getshort(13 + title_length)
	author = ""
	for i in range(0, author_length):
		byte = packet.getbyte(15 + title_length + i)
		if byte > 0:
			author += chr(byte)
	author = unicode(author, 'utf-8')

	if item.hastag('protected'):
		char.message('This book is read only.')
		return 1

	if len(author) == 0:
		item.deltag('author')
	else:
		item.settag('author', author)

	item.name = title
	item.resendtooltip()
	return 1
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:35,代码来源:book.py

示例4: handlepage

def handlepage(socket, packet):
	item = wolfpack.finditem(packet.getint(3))

	if not item:
		console.log(LOG_ERROR, "Client tried to update non existing book %x." % (packet.getint(3)))
		return 1

	page = packet.getshort(9)
	linecount = packet.getshort(11)

	# A page was requested
	if linecount == -1:
		if item.hastag('pages'):
			pages = int(item.gettag('pages'))
		else:
			pages = 64

		if page > pages or page == 0:
			return

		if item.hastag('page%u' % page):
			content = item.gettag('page%u' % page).split("\n")
		else:
			content = []

		sendPage(socket, item.serial, page)

	# The client wants to update the page.
	else:
		if item.hastag('protected'):
			socket.sysmessage('This book is read only.')
			return 1

		if item.hastag('pages'):
			pages = int(item.gettag('pages'))
		else:
			pages = 64

		# Invalid page
		if page > pages or page < 1:
			socket.log("Client tried to update invalid page %d of book 0x%x.\n" % (page, item.serial))
			return 1

		offset = 13
		lines = []
		for i in range(0, linecount):
			line = packet.getascii(offset, 0)
			offset += len(line) + 1
			lines.append(unicode(line, 'utf-8'))

		content = "\n".join(lines)

		if not content or len(content.strip()) == 0:
			item.deltag('page%u' % page)
			return 1

		item.settag('page%u' % page, content)
		item.resendtooltip()

	return 1
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:60,代码来源:book.py

示例5: onLoad

def onLoad():
	# Send a message to the log
	console.log(LOG_MESSAGE, "Starting shard status page thread.\n")
	# Create the worker thread
	global processthread
	processthread = ProcessThread()
	processthread.start()
	return
开发者ID:BackupTheBerlios,项目名称:rayonnant-shard-svn,代码行数:8,代码来源:shard_status.py

示例6: updateacctversion

def updateacctversion(version, driver):
	try:
		if driver == 'mysql':
			database.execute("REPLACE INTO `settings` VALUES('db_version', '%u');" % version)
		else:
			database.execute("REPLACE INTO settings VALUES('db_version', '%u');" % version)
	except Exception, e:
		console.log(LOG_WARNING, "Unable to update account database version to %u:\n%s\n" % (i + 1, str(e)))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:8,代码来源:dbupdate.py

示例7: loadMenu

def loadMenu(id, parent = None):
	definition = wolfpack.getdefinition(WPDT_MENU, id)
	if not definition:
		if parent:
			console.log(LOG_ERROR, "Unknown submenu %s in menu %s.\n" % (id, parent.id))
		else:
			console.log(LOG_ERROR, "Unknown menu: %s.\n" % id)
		return

	name = definition.getattribute('name', '')
	menu = MasonryMenu(id, parent, name)

	# See if we have any submenus
	for i in range(0, definition.childcount):
		child = definition.getchild(i)
		# Submenu
		if child.name == 'menu':
			if not child.hasattribute('id'):
				console.log(LOG_ERROR, "Submenu with missing id attribute in menu %s.\n" % menu.id)
			else:
				loadMenu(child.getattribute('id'), menu)

		# Craft an item
		elif child.name in ['masonry', 'semasonry']:
			if not child.hasattribute('definition'):
				console.log(LOG_ERROR, "Masonry action without definition in menu %s.\n" % menu.id)
			else:
				itemdef = child.getattribute('definition')
				try:
					# See if we can find an item id if it's not given
					if not child.hasattribute('itemid'):
						item = wolfpack.getdefinition(WPDT_ITEM, itemdef)
						itemid = 0
						if item:
							itemchild = item.findchild('id')
							if itemchild:
								itemid = itemchild.value
					else:
						itemid = hex2dec(child.getattribute('itemid', '0'))
					if child.hasattribute('name'):
						name = child.getattribute('name')
					else:
						name = generateNamefromDef(itemdef)
					if child.name == 'semasonry':
						action = SeStonecrafterItemAction(menu, name, int(itemid), itemdef)
					else:
						action = StonecrafterItemAction(menu, name, int(itemid), itemdef)		
				except:
					console.log(LOG_ERROR, "Masonry action with invalid item id in menu %s.\n" % menu.id)

				# Process subitems
				for j in range(0, child.childcount):
					subchild = child.getchild(j)
					action.processnode(subchild, menu)

	# Sort the menu. This is important for the makehistory to make.
	menu.sort()
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:57,代码来源:masonry.py

示例8: startElement

	def startElement( self, name, atts ):
		if name == "item":
			self.itemid = str(atts.getValue("id"));
			if "hue" in atts:
				self.hue = int(hex2dec(str(atts.getValue("hue"))));
			else:
				self.hue = 0
			if "amount" in atts:
				self.amount = int(atts.getValue("amount"));
			else:
				self.amount = 0
			self.statements = []
		elif name == "attribute":
			type = "str"
			if "type" in atts:
				type = str(atts.getValue("type"))
			if "value" in atts and "key" in atts:
				self.statements.append( str(atts.getValue("key")) + "," + type + ","+ str(atts.getValue("value")) )
		elif name == "pos":
			if int(hex2dec( self.itemid )) >= 0x4000:
				item = wolfpack.addmulti( "%x" %  hex2dec( self.itemid ) )
			else:
				item = wolfpack.additem( "%x" %  hex2dec( self.itemid ) )

			if not item or item == None:
				return
			if self.hue > 0:
				item.color = self.hue
			if self.amount > 0:
				item.amount = self.amount
			for p in self.statements:
				parts = p.split(",")
				if hasattr(item, parts[0]):
					if parts[1] == "str":
						value = parts[2]
					elif parts[1] == "int":
						value = int(parts[2])
					setattr(item, parts[0], value)

			x = int( atts.getValue("x") )
			y = int( atts.getValue("y") )
			z = int( atts.getValue("z") )
			map = int( atts.getValue("map") )
			item.moveto( x, y, z, map )
			item.movable = 3 # not movable
			item.decay = 0 # no decay
			item.update()
		elif name == "include":
			path = atts.getValue("file")
			if not os.path.isfile(path):
				console.log(LOG_ERROR, tr("File '%s' not found.\n") % (path))
				return
			parser = xml.sax.make_parser()
			handler = DecorationHandler()
			parser.setContentHandler(handler)
			parser.parse(path)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:56,代码来源:decoration.py

示例9: onUnload

def onUnload():
	console.log(LOG_MESSAGE, "Stopping shard status page thread.\n")
	global processthread
	if processthread:
		processthread.stopped.set()
		time.sleep( 0.01 ) # Sleep a little to give the thread time to exit
		if processthread:
			processthread.join()
		processthread = None
	return
开发者ID:BackupTheBerlios,项目名称:rayonnant-shard-svn,代码行数:10,代码来源:shard_status.py

示例10: growthCheck

def growthCheck(obj, args):
	if args[0] != magic:
		return # This is an outdated timer

	# Notify the log that we're running a growth check
	console.log(LOG_MESSAGE, "Running plant growth check for %u plants.\n" % len(PLANTS))

	# Copy the list of known plant serials and
	# start the subprocessing function
	processGrowthCheck(None, ( PLANTS[:], 0, magic ))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:10,代码来源:__init__.py

示例11: gainresObject

def gainresObject(obj, args):
    if args[0] != magic_farming:
        return  # This is an outdated timer

        # Notify the log that we're running a growth check
    console.log(LOG_MESSAGE, "Running farming growth check for %u objects.\n" % len(OBJECTS))

    # Copy the list of known object serials and
    # start the subprocessing function
    processGainresObject(None, (OBJECTS[:], 0, magic_farming))
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:10,代码来源:farming.py

示例12: onCollide

def onCollide(player, item):
	if item.hastag('playersonly') and player.npc:
		return False

	if not item.hastag('target'):
		if player.socket:
			player.socket.sysmessage( tr('This gate leads nowhere...') )
		else:
			console.log(LOG_ERROR, tr("NPC [%x] using gate [%x] without target.\n") % (player.serial, item.serial))
		return False

	target = item.gettag('target').split(',')

	# Convert the target of the gate.
	try:
		target = map(int, target)
	except:
		player.socket.sysmessage( tr('This gate leads nowhere...') )
		return False

	# Validate the coord
	try:
		m = target[3]
	except:
		m = player.pos.map
	pos = wolfpack.coord( target[0], target[1], target[2], m )

	if not utilities.isValidPosition( pos ):
		player.socket.sysmessage( tr('This gate leads nowhere...') )
		return False

	if not utilities.isMapAvailableTo( player, pos.map ):
		return False

	# Move his pets if he has any
	if player.player:
		for follower in player.followers:
			if follower.wandertype == 4 and follower.distanceto(player) < 5:
				follower.removefromview()
				follower.moveto(pos)
				follower.update()

	player.removefromview()
	player.moveto(pos)
	player.update()
	if player.socket:
		player.socket.resendworld()

	# show some nice effects
	if not item.hastag('silent'):
		item.soundeffect(0x1fe)
		utilities.smokepuff(player, pos)
		utilities.smokepuff(player, item.pos)

	return True
开发者ID:Mutilador,项目名称:Wolfpack,代码行数:55,代码来源:gate.py

示例13: make

	def make(self, player, arguments, nodelay=0):
		item = wolfpack.additem(self.definition)
		if not item:
			console.log(LOG_ERROR, "Unknown item definition used in action %u of menu %s.\n" % \
				(self.parent.subactions.index(self), self.parent.id))
		else:
			if self.amount > 0:
				item.amount = self.amount
			if not tobackpack(item, player):
				item.update()
			player.socket.sysmessage('You put the new item into your backpack.')
			MakeAction.make(self, player, arguments, nodelay)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:12,代码来源:makemenus.py

示例14: onCollide

def onCollide(player, item):
	if item.hastag('playersonly') and player.npc:
		return 0

	if not item.hastag('target'):
		if player.socket:
			player.socket.sysmessage('This gate leads nowhere...')
		else:
			console.log(LOG_ERROR, "NPC [%x] using gate [%x] without target.\n" % (player.serial, item.serial))
		return 0

	target = item.gettag('target').split(',')

	# Convert the target of the gate.
	try:
		target = map(int, target)
	except:
		player.socket.sysmessage('This gate leads nowhere...')
		return 0

	# Move the player
	pos = player.pos
	pos.x = target[0]
	pos.y = target[1]
	pos.z = target[2]
	if len(target) > 3:
		pos.map = target[3]

	if not utilities.isMapAvailableTo(player, pos.map):
		return False

	# Move his pets if he has any
	if player.player:
		for follower in player.followers:
			if follower.wandertype == 4 and follower.distanceto(player) < 5:
				follower.removefromview()
				follower.moveto(pos)
				follower.update(0)
				
	player.removefromview()
	player.moveto(pos)
	player.update(0)
	if player.socket:
		player.socket.resendworld()

	# show some nice effects
	if not item.hastag('silent'):
		item.soundeffect(0x1fe)
		utilities.smokepuff(player, pos)
		utilities.smokepuff(player, item.pos)

	return 1
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:52,代码来源:gate.py

示例15: sendBuyList

	def sendBuyList(self, vendor, player):
		if not self.canBuyItems(vendor, player):
			return False

		if not self.checkAccess(vendor, player):
			return False
			
		self.ensurePacks(vendor) # Make sure the packs are there

		# Compile a list of items that should be sold
		buylist = BuyList()
		
		restock = self.getRestockContainer(vendor)	
		norestock = self.getBuyContainer(vendor)
				
		# Add items that are in the restock container
		for item in restock.content:
			buyitemindex = item.gettag('buyitemindex')
			
			if buyitemindex == None or buyitemindex < 0 or buyitemindex >= len(self.buylist):
				console.log(LOG_ERROR, "Item 0x%x has invalid buy item index %s.\n" % (item.serial, buyitemindex))
				continue
			
			buyitem = self.buylist[buyitemindex]
			
			# Scale the price
			price = self.scaleBuyPrice(vendor, player, buyitem, buyitem.getPrice(vendor, player))
			
			# Add the item to the buylist
			buylist.add(restock, item, self.getInStock(item), price)

		# Add items from the no restock container
		for item in norestock.content:
			baseid = item.baseid

			if not baseid in self.sellmap:
				continue # Should we delete this?

			sellitem = self.sellmap[baseid]

			price = self.scaleResellPrice(vendor, player, item, sellitem.getPrice(vendor, player, item))

			if price <= 0:
				continue # We don't donate...

			# Another quirk in the osi protocol. no restock items are still in the
			# restock pack, oherwise they don't have a price.
			buylist.add(restock, item, self.getInStock(item), price)

		# Send the buylist to the player
		return buylist.send(vendor, player)
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:51,代码来源:__init__.py


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