本文整理汇总了Python中configure.Configuration.getMyID方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.getMyID方法的具体用法?Python Configuration.getMyID怎么用?Python Configuration.getMyID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configure.Configuration
的用法示例。
在下文中一共展示了Configuration.getMyID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lineReceived
# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import getMyID [as 别名]
def lineReceived(self, line):
stdout.write("Server%d Received Data: %s\n" %( Configuration.getMyID(), line))
delMsgs = self.algorithm.receiveMsg(line, self.node)
#return the jsonmsg to various nodes
#send jsonmsg to nodes to notify them
#it's for conflicts
#self.send2Node(0, "fake conflict notification")
if delMsgs:
for delMsg in delMsgs:
#put delete event into the log and execute delete
e = self.node.createEvent(delMsg)
for i in range(self.algorithm.n):#@TODO this line is broadcast
jsonmsg = self.algorithm.sendMsg2Node(i)
self.send2Node(i, jsonmsg)
示例2: sendMsg2Node
# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import getMyID [as 别名]
def sendMsg2Node(self, nodek):
#@TODO load log from database
log = self.dc.getLogs(0,sys.maxint)
NP = {} #partial log
ES = {} #event lists
matrix = [[0 for _ in range(self.n) ] for _ in range(self.n)]
for i in range(self.n):
for j in range(self.n):
matrix[i][j] = self.dc.getTime(i, j)
for (id,name,time,content) in log:
event = Event(id,name,time,content)
if not self.__hasRec(matrix, event, nodek):
ES[event.name] = (event.time, event.node, event.content)
logging.debug((event.time, event.node, event.content))
NP["matrix"] = matrix
NP["events"] = ES
NP["senderID"] = Configuration.getMyID()
NP["receiverID"] = nodek
logging.debug(json.dumps(NP))
return json.dumps(NP)
示例3: __init__
# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import getMyID [as 别名]
def __init__(self):
self.n = Configuration.getN()
self.C = 0
self.ID = Configuration.getMyID()
self.dc = DataConn()
示例4: send2Node
# 需要导入模块: from configure import Configuration [as 别名]
# 或者: from configure.Configuration import getMyID [as 别名]
def send2Node(self, nodeId, data):
for name, protocol in self.users.iteritems():
if name == nodeId and nodeId != Configuration.getMyID():
protocol.sendLine(data)
return
logging.warning("One server's message not reply to client because no connection found or it's itself.")