本文整理汇总了Python中MessageParser.MessageParser.getServiceName方法的典型用法代码示例。如果您正苦于以下问题:Python MessageParser.getServiceName方法的具体用法?Python MessageParser.getServiceName怎么用?Python MessageParser.getServiceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageParser.MessageParser
的用法示例。
在下文中一共展示了MessageParser.getServiceName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _writeMessageToSocket
# 需要导入模块: from MessageParser import MessageParser [as 别名]
# 或者: from MessageParser.MessageParser import getServiceName [as 别名]
#.........这里部分代码省略.........
elif mm.type == 'PRI_DESTADD_TEXT':
mm.destAddress = mp.destAddress
if mm.destAddress:
mm.priority = mp.priority
mm.setFilingTime()
mm.nextCSN()
messageAFTN = MessageAFTN(self.logger, mp.text, mm.stationID, mm.address, mm.priority, mm.destAddress, mm.CSN, mm.filingTime, mm.dateTime)
else:
if mm.isFromDisk():
try:
self.logger.warning("%s has been erased (no valid destination address)", os.path.basename(self.dataFromFiles[0][1]))
os.unlink(self.dataFromFiles[0][1])
except OSError, e:
(type, value, tb) = sys.exc_info()
self.logger.error("Unable to unlink %s ! Type: %s, Value: %s" % (self.dataFromFiles[0][1], type, value))
del self.dataFromFiles[0]
mm.clearPartsToSend()
continue
else:
# True if mm.header is in the routing table with destination addresses
#if mm.header == None: mm.header = 'SACN31 CWAO'
if mm.setInfos(mm.header, rewrite):
messageAFTN = MessageAFTN(self.logger, data[index], mm.stationID, mm.address, mm.priority,
mm.destAddress, mm.CSN, mm.filingTime, mm.dateTime)
else:
if mm.isFromDisk():
try:
self.logger.warning("%s has been erased", os.path.basename(self.dataFromFiles[0][1]))
os.unlink(self.dataFromFiles[0][1])
except OSError, e:
(type, value, tb) = sys.exc_info()
self.logger.error("Unable to unlink %s ! Type: %s, Value: %s" % (self.dataFromFiles[0][1], type, value))
del self.dataFromFiles[0]
mm.clearPartsToSend()
continue
# If it is the first time we sent this message, we archive it.
#if not rewrite:
self.logger.debug('Message as it will be sent:')
self.logger.debug('\n' + messageAFTN.message)
messageAFTN.setLogger(None)
mm.archiveObject(self.archivePath + mm.CSN, messageAFTN)
nbBytesToSend = len(messageAFTN.message)
while nbBytesToSend > 0:
nbBytesSent = self.socket.send(messageAFTN.message)
# This sleep is machiavelic! It permits to see many potential problems
#if self.subscriber:
# time.sleep(5)
messageAFTN.message = messageAFTN.message[nbBytesSent:]
nbBytesToSend = len(messageAFTN.message)
self.totBytes += nbBytesSent
mm.setWaitingForAck(messageAFTN.getTransmitID())
mm.incrementSendingInfos()
# Archive State
mm.state.fill(mm)
mm.archiveObject(AFTNPaths.STATE, mm.state)
self.logger.debug("State has been archived")
# Log the fact that the message has been sent
if not rewrite:
if mm.isFromDisk():
mm.filenameToSend = os.path.basename(self.dataFromFiles[0][1])
mm.filenameToErase = self.dataFromFiles[0][1]
else:
if mp.type == 'SVC':
mm.filenameToSend = mp.getServiceName(mp.getServiceType())
elif mp.type in MessageParser.REPLY_TYPES:
mm.filenameToSend = ''
else:
# We should never go here
self.logger.error("Unknown message type has just been sent. See code!")
self.logger.info("(%5d Bytes) Message %s %s (%s/%s) has been sent => delivered" % (self.totBytes, getWord(mm.type),
mm.filenameToSend, mm.nextPart+1, mm.numberOfParts))
else:
self.logger.info("(%5d Bytes) Message %s %s (%s/%s) has been resent => delivered" % (self.totBytes, getWord(mm.type),
mm.filenameToSend, mm.nextPart+1, mm.numberOfParts))
# Reset byte count
self.totBytes = 0
# If the last part of a message (big or not) has been sent, erase the file.
# We do this even if we have not yet received the ack. At this point, we have already
# archived all the parts with their CSN as filename.
if mm.isLastPart():
if mm.isFromDisk() and not rewrite:
try:
os.unlink(self.dataFromFiles[0][1])
self.logger.debug("%s has been erased", os.path.basename(self.dataFromFiles[0][1]))
except OSError, e:
(type, value, tb) = sys.exc_info()
self.logger.error("Unable to unlink %s ! Type: %s, Value: %s" % (self.dataFromFiles[0][1], type, value))
del self.dataFromFiles[0]