本文整理汇总了Python中log4py.Logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.info方法的具体用法?Python Logger.info怎么用?Python Logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4py.Logger
的用法示例。
在下文中一共展示了Logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: User
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class User(StateNode):
STATE_ACTIVE = 'Active'
def __init__( self, name, parent ):
StateNode.__init__( self, name, parent, initialState = self.STATE_ACTIVE )
self.log = Logger().get_instance( self.__class__.__name__ )
self.dialogs = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, StateChangeNotification ):
if event.node in self.dialogs.itervalues():
return 'Dialog' + event.node.currentState
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def inActive_onRxRequest( self, event ):
callid = event.message['Call-ID']
if not callid in self.dialogs:
dialog = Dialog( callid, self, event )
dialog.addListener( self )
self.dialogs[callid] = dialog
#FIXME: We don't really want to create a dialog for everything (e.g. REGISTER).
# Even if we create a dummy dialog, then the subscribe and register dialogs would conflict.
dialog = self.dialogs[callid]
self.send( event, dialog, False )
def inActive_onRxResponse( self, event ):
callid = event.message['Call-ID']
if not callid in self.dialogs:
self.handled = True
raise SipException( 'Dialog, ' + str(callid) + ' not found in user, ' + str(self.name) + '.' )
else:
dialog = self.dialogs[callid]
self.send( event, dialog, False )
def inActive_onTxRequest( self, event ):
self.notify( event, False )
def inActive_onTxResponse( self, event ):
self.notify( event, False )
def inActive_onDialogEarly( self, event ):
#FIXME:
self.inActive_onDialogProceeding( self, event )
def inActive_onDialogProceeding( self, event ):
dialog = [ d for d in self.dialogs.itervalues() ][0]
transaction = dialog.transaction
#FIXME:
e = transaction.lastRequestEvent
ne = createResponseEvent( e, 200 )
self.notify( ne, True )
event.handled = True
示例2: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class TransitiveInheritanceDictionary:
##
# Initialize a transitive inheritance dictionary given an include dictionary.
##
def __init__(self, inheritanceDictionary):
# initialize an empty dictionary
self.dict = {}
self.inhDict = inheritanceDictionary
self.calculateTransitiveSuperclasses()
self.inhDict = None
self.log = Logger().get_instance(self)
##
# Add the transitive included files for each including file.
##
def calculateTransitiveSuperclasses(self):
for subclass in self.inhDict.dict:
transitiveSuperclasses = self.inhDict.getTransitiveSuperclasses(subclass)
self.dict[subclass] = transitiveSuperclasses
##
# Is the dictionary aware of any superclasses of the given className
##
def hasKey(self, className):
return className in self.dict
##
# Retrieve a list of names of transitive superclasses of the given class-name.
##
def getTransitiveSuperclasses(self, className):
superclasses = []
if className in self.dict:
superclasses = self.dict[className]
return superclasses
##
# Verify whether the given superclass-name is a known (transitive) superclass of the given subclass-name.
##
def isSubclassOf(self, subclassName, superclassName):
return superclassName in self.getTransitiveSuperclasses(subclassName)
##
# Print the contents of the dictionary.
##
def printContent(self):
self.log.info("Dictionary has", len(self.dict), "elements:")
for key in self.dict:
self.log.info("[", key, ",", self.getTransitiveSuperclasses(key), "]")
示例3: Resources
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class Resources(Node):
"""Dispatches incoming MessageEvents based on the Request-URI."""
def __init__( self, name, parent ):
super( Resources, self ).__init__( name, parent )
self.log = Logger().get_instance( self.__class__.__name__ )
self.resources = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, ResourceEvent ):
return event.id
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def onBind( self, event ):
obj = importExtension( event.clsName )
if obj:
resource = obj( str(event.uri), self )
if resource:
resource.addListener( self )
self.resources[event.uri] = resource
if not obj or not resource:
raise Exception( 'Failed to import resource, ' + str(event.uri) + ', of type, ' + str(event.clsName) + '.' )
event.handled = True
def onUnbind( self, event ):
del self.resources[event.uri]
event.handled = True
def onRxRequest( self, event ):
try:
host = event.message.requestUri.host
resource = self.resources[host]
self.send( event, resource, queued=False )
except KeyError:
pass
def onRxResponse( self, event ):
raise 'FIXME:IMPLEMENT: Need to find the corresponding request, then the request-URI, then look up the resource in self.resources.'
def onTxRequest( self, event ):
self.notify( event, queued=False )
def onTxResponse( self, event ):
self.notify( event, queued=False )
示例4: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class AccessDictionary:
# initialize an empty dictionary
dict = {}
##
# Initialize a dictionary.
##
def __init__(self):
self.log = Logger().get_instance(self)
pass
##
# Print the dictionary
##
def printContent(self):
self.log.info("Dictionary has", len(self.dict), "elements:")
for key in self.dict:
self.log.info( "[",key,",",self.convertToList(self.dict[key]),"]")
def createKey(self, fileName, lineNr):
return fileName+":"+lineNr
def hasKeyFor(self, fileName, lineNr):
return self.hasKey(self.createKey(fileName,lineNr))
def hasKey(self, key):
return self.dict.has_key(key)
def getValue(self, fileName, lineNr):
assert self.hasKey(self.createKey(fileName, lineNr))
return self.dict[self.createKey(fileName, lineNr)]
def getValueAsList(self, fileName, lineNr):
return self.getValue(fileName, lineNr).split(",")
def convertToList(self, value):
return value.split(",")
def add(self, fileName, lineNr, typeClass):
if typeClass != "" and typeClass != None:
key = self.createKey(fileName, lineNr)
value = typeClass
if self.dict.has_key(key) :
value = self.dict[key]
valueAsList=self.convertToList(value)
if not typeClass in valueAsList:
value=value+","+typeClass
self.dict[key] = value
示例5: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class Timer:
def __init__(self, activityDescription):
if sys.platform == "win32":
self.timer = time.clock
else:
self.timer = time.time
self.begin = self.end = 0
self.activityDescription = activityDescription
self.logger = Logger().get_instance(self)
##
# Starts the timer.
##
def start(self):
self.begin = self.timer()
##
# Stop the timer.
##
def stop(self):
self.end = self.timer()
def log(self, nrOfWorkItems):
self.logger.info(self.activityDescription + " took "\
+ `self.milli()` + " ms for " + `nrOfWorkItems` + " work items, or " \
+ `self.getMillisPerItem(nrOfWorkItems)` + " ms per item.")
def seconds(self):
return self.milli() / 1000
def getMillisPerItem(self, nrOfItems):
millisPerItem = 0
if nrOfItems != 0:
millisPerItem = float(self.milli()) / float(nrOfItems)
return millisPerItem
def milli(self):
return self.micro() / 1000
def micro(self):
return int((self.end - self.begin) * 1000000)
示例6: Host
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class Host(StateNode):
STATE_ACTIVE = 'Active'
def __init__( self, name, parent ):
StateNode.__init__( self, name, parent, initialState = self.STATE_ACTIVE )
self.log = Logger().get_instance( self.__class__.__name__ )
self.users = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, StateChangeNotification ):
if event.node in self.users.itervalues():
return 'User' + event.node.currentState
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def inActive_onRxRequest( self, event ):
userName = event.message['To'].uri.user
if not userName in self.users:
user = User( userName, self )
user.addListener( self )
self.users[userName] = user
event.localUser = self.users[userName]
self.send( event, event.localUser, False )
def inActive_onRxResponse( self, event ):
userName = event.message['From'].uri.user
if not userName in self.users:
self.users[userName] = User( userName, self )
event.localUser = self.users[userName]
self.send( event, event.localUser, False )
def inActive_onTxRequest( self, event ):
self.notify( event, False )
def inActive_onTxResponse( self, event ):
self.notify( event, False )
示例7: handle
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
def handle(self):
log = Logger().get_instance(self)
f = xmlgen.Factory()
data = self.request.recv(1024)
try:
[strategy,options] = data.split(":")
log.info("Executing query: %s, %s" % (strategy, options))
try:
exec("import TrustStrategies.%s " % (strategy))
exec("debug_module = (TrustStrategies.%s.%s.debug)" % (strategy, strategy))
if debug_module:
exec("reload(TrustStrategies.%s) " % (strategy))
exec("tpf = TrustStrategies.%s.%s(self.server)" % (strategy, strategy))
except (ImportError), i:
from TrustStrategies.DefaultTPF import DefaultTPF
tpf = DefaultTPF(self.server)
log.warn("Caught ImportError: %s\nUsing DefaultTPF strategy." % (i))
searchtime = time.time()
r = tpf.query(options)
searchtime = "%.6f" % (time.time() - searchtime)
# build the xml response
result = f.queryresult(r, executed="1", strategy=strategy, search_time=searchtime)
示例8: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class IncludeDictionary:
##
# Initialize a dictionary.
##
def __init__(self):
# initialize an empty dictionary
self.dict = {}
self.log = Logger().get_instance(self)
##
# Does filename include other files?
##
def hasKey(self, fileName):
normalizedFileName=normalizeFileName(fileName)
return (normalizedFileName in self.dict )
##
# Retrieve a list of files included directly by the given file
##
def getIncludedFiles(self, includingFile):
includedFiles = []
normalizedIncludingFile=normalizeFileName(includingFile)
if ( normalizedIncludingFile in self.dict ):
includedFiles = self.dict[normalizedIncludingFile]
return includedFiles
##
# Retrieve a list of files included directly and indirectly by the given file.
##
def getTransitiveIncludedFiles(self, includingFile):
includedFiles = []
normalizedIncludingFile=normalizeFileName(includingFile)
self.getTransitiveIncludedFilesInternal(normalizedIncludingFile, includedFiles)
return includedFiles
def getTransitiveIncludedFilesInternal(self, includingFile, resultSet):
additionalResultSet = []
if self.hasKey(includingFile):
for includedFile in self.getIncludedFiles(includingFile):
if not ((includedFile in resultSet) or (includedFile in additionalResultSet)):
resultSet.append(includedFile)
additionalResultSet.append(includedFile)
for includedFile in additionalResultSet:
self.getTransitiveIncludedFilesInternal(includedFile, resultSet)
def addEntity(self, includeEntity):
return self.add(includeEntity.getIncludingFile(), \
includeEntity.getIncludedFile())
##
# Appends includedFile to the list of files included by includingFile.
#
# @returns True/False indicating whether the includedFile was added
##
def add(self, includingFile, includedFile):
if ( includingFile == None ) or ( includedFile == None ):
self.log.error("Preconditions violated: ",[includingFile,includedFile])
return False
added = False
normalizedIncludingFile=normalizeFileName(includingFile)
adjustedIncludedFile=adjustPath(normalizedIncludingFile,includedFile)
if not(normalizedIncludingFile in self.dict) :
self.dict[normalizedIncludingFile]=[]
if not (adjustedIncludedFile in self.dict[normalizedIncludingFile]):
self.dict[normalizedIncludingFile].append(adjustedIncludedFile)
added = True
return added
##
# Print the contents of the dictionary.
##
def printContent(self):
self.log.info( "Dictionary has", len(self.dict), "elements:")
for key in self.dict:
self.log.info( "[",key,",",self.getIncludedFiles(key),"]")
示例9: System
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class System(StateNode):
STATE_STOPPED = 'Stopped'
STATE_STARTED = 'Started'
STATE_PAUSED = 'Paused'
EVENT_START = 'Start'
EVENT_PAUSE = 'Pause'
EVENT_CONTINUE = 'Continue'
EVENT_STOP = 'Stop'
def __init__( self, name, parent ):
StateNode.__init__( self, name, parent, initialState = System.STATE_STOPPED )
self.log = Logger().get_instance( self.__class__.__name__ )
self.config = Configuration( 'config', self )
self.config.addListener( self )
self.network = MessageAdapter( 'msg_net', self )
self.network.addListener( self )
self.resources = Resources( 'resources', self )
self.resources.addListener( self )
self.addListener( parent )
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
return event.id
elif isinstance( event, ConfigEvent ):
return event.id
elif isinstance( event, StateChangeNotification ):
return event.id
else:
# Local events.
return event.id
# Stopped
def inStopped_onStart( self, event ):
self.send( Event( Configuration.EVENT_READ ), self.config, queued=False )
self.send( ResourceEvent( ResourceEvent.EVENT_BIND, uri='sip.example.com', clsName='user-agent' ), self.resources, queued=False )
self.send( NetEvent( NetEvent.EVENT_BIND, transport=self.query( 'network.transport' ), localAddress=self.query( 'network.localAddress' ), localPort=self.query( 'network.localPort' ) ), self.network, queued=False )
self.changeState( self.STATE_STARTED )
event.handled = True
# Started
def inStarted_onStop( self, event ):
self.changeState( self.STATE_STOPPED )
event.handled = True
def inStarted_onPause( self, event ):
self.changeState( self.STATE_PAUSED )
event.handled = True
def inStarted_onRxRequest( self, event ):
self.send( event, self.resources, queued=False )
def inStarted_onRxResponse( self, event ):
self.send( event, self.resources, queued=False )
def inStarted_onTxRequest( self, event ):
self.send( event, self.network, queued=False )
def inStarted_onTxResponse( self, event ):
self.send( event, self.network, queued=False )
# Paused
def inPaused_onContinue( self, event ):
self.changeState( self.STATE_STARTED )
event.handled = True
def query( self, name, active = True, args = None, kwargs = None ):
return self.config.query( name, active, args, kwargs )
示例10: UpdateListener
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class UpdateListener(SocketServer.BaseRequestHandler):
def setup(self):
# Create a namespace object for the Friend of a friend namespace.
# figure out trailing pound thing...
#self.FOAF = Namespace(self.server.config.foaf_url + "#")
#self.TRUST = Namespace(self.server.config.trust_url + "#")
#self.WOT = Namespace(self.server.config.wot_url + "#")
#self.RDF = Namespace(self.server.config.rdf_url + "#")
self.FOAF = Namespace("http://xmlns.com/foaf/0.1/")
self.TRUST = Namespace("http://www.konfidi.org/ns/trust/1.2#")
self.WOT = Namespace("http://xmlns.com/wot/0.1/")
self.RDF = Namespace("http://www.w3.org/2000/01/rdf-schema#")
self.log = Logger().get_instance(self)
# load trust values into list for later
#trust = TripleStore()
#trust.load(self.server.config.trust_url)
#trust.load("http://svn.berlios.de/viewcvs/*checkout*/konfidi/schema/trunk/trust.owl#")
#self.trustValues = []
#for s in trust.subjects(self.RDF["subPropertyOf"], self.TRUST["trustValue"]):
# self.trustValues.append(s)
def handle(self):
#print "update connection opened."
#print "FOAF: %s" % (self.FOAF)
#print "TRUST: %s" % (self.TRUST)
#print "WOT: %s" % (self.WOT)
#print "RDF: %s" % (self.RDF)
str = ''
while 1:
data = self.request.recv(1024)
if not data: break
str += data
self.request.send("Ok.")
self.request.close()
self.load(str)
#self.load(openAnything(str))
#print "update connection closed."
def load(self, source):
self.log.info("Parsing input: %s" % source)
# this is the main object we're concerned with
trust = Graph()
trust.load(source)
# new version
count = 0
for (relationship, truster) in trust.subject_objects(self.TRUST["truster"]):
#print "r: %s, t: %s" % (relationship, truster)
# clean up the fingerprints
source_pubkey = trust.objects(truster, self.WOT["hasKey"]).next()
source_fingerprint = trust.objects(source_pubkey, self.WOT["fingerprint"]).next()
sink_pubkey = trust.objects(trust.objects(relationship, self.TRUST["trusted"]).next(), self.WOT["hasKey"]).next()
sink_fingerprint = trust.objects(sink_pubkey, self.WOT["fingerprint"]).next()
# turn these off for now, for our test cases. figure a better solution later
source_fingerprint = re.sub(r'[^0-9A-Z]', r'', source_fingerprint.upper())
sink_fingerprint = re.sub(r'[^0-9A-Z]', r'', sink_fingerprint.upper())
source = self.server.getPerson(source_fingerprint)
sink = self.server.getPerson(sink_fingerprint)
#print "sf: %s, sif: %s" % (source_fingerprint, sink_fingerprint)
for item in trust.objects(relationship, self.TRUST["about"]):
#print "i: %s" % item
topic = trust.objects(item, self.TRUST["topic"]).next().split("#")[1]
rating = float(trust.objects(item, self.TRUST["rating"]).next())
if rating >= 0.0 and rating <= 1.0:
source.addTrustLink(sink.getFingerprint(), topic, rating)
count += 1
self.log.info("Added %d trust links." % count)
示例11: debug
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
common.famix.cdifWriter.generateHeader( True, "snavtofamix", sys.argv[2],\
"4", "Java", "")
common.famix.cdifReader.set_cdifhandle(outputHandle)
# Preamble + famix level 1
debug(" Entering famix Level 1")
dbLoc = sys.argv[1] + "/" + sys.argv[2]
fileDbLoc = dbLoc + ".files"
pkgDbLoc = dbLoc + ".packages"
clDbLoc = dbLoc + ".classes"
impDbLoc = dbLoc + ".includes"
miDbLoc = dbLoc + ".methods"
inDbLoc = dbLoc + ".inheritance"
checkfamixL1Reqs(sys.argv[1] + "/" + sys.argv[2])
log.info(" Parsing files ...")
fileDict = FileDictionary.FileDictionary()
fileDbLoc = dbLoc + ".files"
buildFileDict(fileDbLoc, fileDict)
common.famix.cdifWriter.generateFileInfo(fileDict)
debug(" - parsing packages ...")
pkgDict = PackageDictionary()
snavTableReader.parsePackages(pkgDbLoc, pkgDict)
debug(" - parsing classes ...")
# we use the generic ClassDictionary, shared with C++
classDict = ClassDictionary()
snavTableReader.parseClasses(clDbLoc, pkgDict, classDict)
debug(" - parsing imports ...")
示例12: UserAgent
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class UserAgent(StateNode):
STATE_ACTIVE = 'Active'
def __init__( self, name, parent ):
StateNode.__init__( self, name, parent, initialState = self.STATE_ACTIVE )
self.log = Logger().get_instance( self.__class__.__name__ )
self.authentication = AuthenticationAdapter( 'auth_adapter', self )
self.authentication.addListener( self )
self.authentication = None #FIXME:
self.transactions = {}
self.dialogs = {}
def identifyEvent( self, event ):
self.log.info( str(event) )
if isinstance( event, MessageEvent ):
event.useragent = self
return event.id
elif isinstance( event, StateChangeNotification ):
return event.id
raise SipException( '[' + str(self.name) + '] ' + 'Ignoring event ' + str(event) + '.' )
def getTransaction( self, event, createIfMissing ):
#FIXME: transaction key is more complex than call-id.
key = event.message['Call-ID']
try:
transaction = self.transactions[key]
except KeyError:
if createIfMissing:
# No transaction available, create a new one.
transaction = Transaction( key, self, event )
if transaction:
transaction.addListener( self )
self.transactions[key] = transaction
else:
transaction = None
return transaction
def getDialog( self, event, createIfMissing ):
#FIXME: dialog key is more complex than call-id.
key = event.message['Call-ID']
try:
dialog = self.dialogs[key]
except KeyError:
if createIfMissing:
# No dialog available, create a new one.
dialog = Dialog( key, self, event )
if dialog:
dialog.addListener( self )
self.dialogs[key] = dialog
else:
dialog = None
return dialog
def _inActive_onRx( self, event ):
transaction = self.getTransaction( event, createIfMissing=True )
if transaction:
self.send( event, transaction, queued=False )
dialog = self.getDialog( event, createIfMissing=True )
if dialog:
self.send( event, dialog, queued=False )
event.handled = True
def inActive_onRxRequest( self, event ):
if self.authentication:
# Authenticate incoming requests.
# If the request fails authentication, a 401/407 will be sent automatically
# and event.handled will be true.
self.send( event, self.authentication, queued=False )
if not event.handled:
# Request authenticated successfully.
self._inActive_onRx( event )
def inActive_onRxResponse( self, event ):
if self.authentication:
# Check the authentication status of incoming responses.
# If the response indicates that the request failed to authentication,
# then the request will be re-sent with authentication automatically
# and event.handled will be true.
self.send( event, self.authentication, queued=False )
if not event.handled:
# Request authenticated successfully.
self._inActive_onRx( event )
def inActive_onTxRequest( self, event ):
if not event.message['UserAgent'].type:
event.message['UserAgent'] = self.query( 'sip.useragent' )
#.........这里部分代码省略.........
示例13: Engine
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
class Engine(object):
def __init__(self):
self.log = Logger().get_instance(self.__class__.__name__)
self.loaders = []
self.data = {}
self.donjonSubTypeCount = {}
self.generateDongeonArray = []
self.renderObject = None
self.tableTop = TableTop()
self.firstZoneDealer = None
def load(self):
for loader in self.loaders:
loader.load(self.data)
self.log.info(loader.__class__.__name__ + " Finished")
print "Run loaders Finished"
def authorizeDungeonSubTypeCount(self, subType, count):
if subType in self.data["zone"]:
self.donjonSubTypeCount[subType] = count
def addLoader(self, loader):
self.loaders.append(loader)
def setRender(self, render):
self.renderObject = render
def render(self):
# =======================================================================
# self.tableTop.addZone(self.generateDongeonArray[0])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[1])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[2])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[3])
# self.renderObject.renderTabletop(self.tableTop)
# self.tableTop.addZone(self.generateDongeonArray[4])
# =======================================================================
self.log.debug(str(self.firstZoneDealer))
self.tableTop.initialConnector.zoneDealer = self.firstZoneDealer
self.tableTop.addZone(self.tableTop.initialConnector, self.firstZoneDealer)
self.renderObject.renderTabletop(self.tableTop)
def generateDongeon(self):
zoneDealer = ZoneDealer()
generateDongeonArray = []
for objectType, value in self.donjonSubTypeCount.iteritems():
for i in range(0, value):
generateDongeonArray.append(self.takeOneRandomZoneOfType(objectType, value - i))
random.shuffle(generateDongeonArray)
self.pushObjectiveZoneToDeep(generateDongeonArray)
for zone in generateDongeonArray:
zoneDealer.addZone(zone)
self.firstZoneDealer = zoneDealer
def takeOneRandomZoneOfType(self, subType, countAgain):
tempArray = self.data["zone"][subType]
self.log.debug("data for " + subType + ":" + str(tempArray))
if not self.hasNonUniqueZone(tempArray):
if len(tempArray) < countAgain:
raise Exception(
"There are not enougth zone subtype "
+ subType
+ ". rest "
+ str(len(tempArray))
+ " needed "
+ str(countAgain)
)
random.shuffle(tempArray)
if tempArray[0].unique:
uniqueZone = tempArray[0]
tempArray.remove(uniqueZone)
return uniqueZone
else:
return copy.deepcopy(tempArray[0])
def pushObjectiveZoneToDeep(self, generateDongeon):
for zone in generateDongeon:
if zone.subType == "objective-zone":
generateDongeon.remove(zone)
countItems = len(generateDongeon)
afterLimit = countItems / 3 # * 2
self.log.debug("push objective zone after " + str(afterLimit) + " index")
randomIndex = random.randrange(afterLimit, countItems)
self.log.debug("push objective zone in " + str(randomIndex) + " index")
generateDongeon.insert(randomIndex, zone)
break
#.........这里部分代码省略.........
示例14: __init__
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
20-10-2001 21:19 c1.get_instance [DEBUG]- Instantiated
20-10-2001 21:19 c1.__init__ [INFO]- in c1
20-10-2001 21:19 c2.get_instance [DEBUG]- Instantiated
20-10-2001 21:19 c2.__init__ [INFO]- in c2
20-10-2001 21:19 c1.__init__ [INFO]- in c1
--------
Author: Bruce Kroeze <[email protected]>
"""
from log4py import Logger, LOGLEVEL_DEBUG
class c1:
def __init__(self):
log = Logger().get_instance(self)
log.info("in c1")
class c2:
def __init__(self):
log = Logger().get_instance(self)
log.info("in c2")
if (__name__ == '__main__'):
log = Logger("$HOME/log4py.conf").get_instance()
log.get_root().set_loglevel(LOGLEVEL_DEBUG)
log.info("in main")
a = c1()
b = c2()
c = c1()
示例15: open
# 需要导入模块: from log4py import Logger [as 别名]
# 或者: from log4py.Logger import info [as 别名]
output_handle.close()
output_handle = open(output_file, "a+")
#common.famix.cdifWriter.set_outputfile(output_file)
common.famix.cdifWriter.set_outputhandle(output_handle)
common.famix.cdifWriter.initializeIDCounter()
common.famix.cdifWriter.generateHeader(\
True, "snavtofamix", sys.argv[2], "4", "C++", "ISO98")
common.famix.cdifReader.set_cdifhandle(output_handle)
dbLoc = sys.argv[1] + "/" + sys.argv[2]
dbdumpPath = sys.argv[1]
DataReqs.checkfamixCppReqs(sys.argv[1] + "/" + sys.argv[2])
log.info(" Parsing files ...")
fileDict = FileDictionary()
fileDbLoc = dbLoc + ".files"
buildFileDict(fileDbLoc, fileDict)
common.famix.cdifWriter.generateFileInfo(fileDict)
#log.info(" Parsing includes ...")
#includeDict = IncludeDictionary()
#includeDbLoc = dbLoc + ".includes"
#snav_parseIncludes(includeDbLoc, includeDict, fileDict)
log.info(" Parsing ALTERNATIVE includes...")
includeDict = IncludeDictionary()
includeDbLoc = dbLoc + ".includes2"
snavTableReader.parseAlternativeIncludes(includeDbLoc, includeDict, fileDict)