本文整理匯總了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.")