本文整理汇总了Python中Message.Message类的典型用法代码示例。如果您正苦于以下问题:Python Message类的具体用法?Python Message怎么用?Python Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Message类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: createResponse
def createResponse(self):
''' Get response from similarity check. If good, send reply '''
new = Message('lastEmail.txt')
# print "Incoming Mail: " + '\n' + new.getBody()
subject = new.getSubject()
subject = "AMR Response: " + subject
# print new.getBody()
tool = 's' # Chose g for Gensim or s for Scikit Learn
modelToUse = "lda"
if tool == 'g':
match, accuracy, self.models = main.emailCheck(
self.path, self.corpusName, modelToUse, "gensim",
new, self.models)
elif tool == 's':
match, accuracy, self.models = main.emailCheck(
self.path, self.corpusName, modelToUse, "scikit",
new, self.models)
else:
match, accuracy = None, None
if match is not None:
# print "Outgoing Mail: " + '\n' + match.getBody()
reply = self.buildReply(match, accuracy)
# print reply
self.send(reply, subject)
return True
return False
开发者ID:zacheryschiller,项目名称:amr,代码行数:27,代码来源:ProcessEmail.py
示例2: add_new_conversation
def add_new_conversation(cls, sender, receiver, title, content):
"""Adds new conversation with receiver for sender, returns Conversation object
"""
#TODO: check if sender and receiver aren't the same person, if so, add only once
skey = ndb.Key('User', sender)
rkey = ndb.Key('User', receiver)
if sender == receiver:
rl = [skey]
rln = [sender]
else:
rl = [rkey, skey]
rln = [sender, receiver]
conv = Conversation(
owner = sender,
receivers_list = rl,
receivers_list_norm = rln,
title = title,
)
msg = Message(
sender = sender,
content = content
)
k = msg.put()
conv.insert_message(k)
ck = conv.put()
User.add_conversation_for_users(ck, sender, receiver)
return conv, msg
开发者ID:nitishparkar,项目名称:udacityplus,代码行数:34,代码来源:User.py
示例3: takeUserInput
def takeUserInput(self):
print("--------------------------------------------------------------------------")
print("-----------------------Welcome to Safeway!!-------------------------------")
enterOption = input("Press 1 to Enter, Press 2 to Exit")
if enterOption == 1:
print("-----------------------------------------------------------------------")
new_customer = ""
while True:
print("-----------------------------------------------------------------------")
print("Enter 1 for creating a customer")
print("Enter 2 for generating a random customer")
print("Enter 3 to exit")
option = input("Please Enter your choice")
print("\n")
if option == 1:
new_customer = Customer()
del new_customer.items[:]
while True:
print("Enter 1 for Adding Item")
print("Enter 2 to see all the Items")
print("Enter 3 If finished shopping")
option2 = input("Please Enter your choice")
if option2 == 1:
item = Item.Item()
new_customer.items.append(item)
print("---------------------New Item Added-------------------------\n")
elif option2 == 2:
print("Item Name Item Price\n")
print("-----------------------------------------")
for i in new_customer.items:
print(str(i.name)+" "+ str(i.value))
print("\n")
elif option2 ==3:
message = Message('addcustomer', new_customer)
m = message.get_message_json()
self.protocol.sendLine(m)
print("Customer sent to the queue")
break
if option==2:
message = Message('addcustomer', Customer())
m = message.get_message_json()
self.protocol.sendLine(m)
print("Customer sent to the queue")
continue
if option ==3:
break
if enterOption == 2:
print("Good Bye")
sys.exit()
开发者ID:akshaybhasme,项目名称:cmpe275project2,代码行数:60,代码来源:CustomerGenerator.py
示例4: createFromBytes
def createFromBytes(self, msgtype, data):
Message.createFromBytes(self, msgtype, data)
self.options = unpack(">B", data[0])[0]
numcerts = unpack(">B", data[1])[0]
for i in range(0, numcerts):
# TODO: Not implemented
pass
开发者ID:UCASREN,项目名称:Crossbear,代码行数:7,代码来源:CertVerifyReq.py
示例5: createKeywordText
def createKeywordText(path, corpusName):
''' This function takes in the location of the email files and finds the
keywords from all of the files and saves the corpus to a text file that
can be read later '''
saveCorpus = open(corpusName + ".txt", 'w')
saveCorpusIndex = open(corpusName + ".index", 'w')
messages = []
i = 0
errors = 0
l = len(os.listdir(path))
for filename in os.listdir(path):
print "Working on", str(filename)
if errors == 10:
print "More than 10 errors. Stopping."
break
else:
new = Message(path + filename)
messages.append(new)
result = new.getError()
tokens = ' '.join(map(str, messages[i].getTokens()))
saveCorpus.write(tokens + '\n')
saveCorpusIndex.write(filename + '\n')
if result:
errors += 1
i += 1
print("Completed " + str(i) + " of " + str(l) + '\n')
saveCorpus.close()
saveCorpusIndex.close()
print "Errors creating keyword text = " + str(errors)
return True
开发者ID:zacheryschiller,项目名称:amr,代码行数:32,代码来源:main.py
示例6: sendmail
def sendmail(From, To, Cc=None, Bcc=None, Subject="",
Body="", File=None, Filename="", InReplyTo=None):
text = makePart(Body, "quoted-printable")
if File is not None:
data = File.read()
if data:
attach = makePart(data, "base64")
ext = os.path.splitext(Filename)[1]
ctype = mimetypes.guess_type(ext)[0] or "application/octet-stream"
attach["Content-Type"] = ctype
Filename = os.path.split(Filename)[1]
attach["Content-Disposition"] = 'attachment; filename="%s"' % Filename
msg = Message(StringIO())
msg.boundary = choose_boundary()
msg["Content-Type"] = 'multipart/mixed; boundary="%s"' % msg.boundary
msg.parts.extend([text, attach])
else: msg = text
else: msg = text
msg["From"] = From
msg["To"] = To
if Cc: msg["Cc"] = Cc
if Bcc: msg["Bcc"] = Bcc
if InReplyTo: msg["In-Reply-To"] = InReplyTo
msg["Subject"] = Subject or ""
msg["Mime-Version"] = "1.0"
text["Content-Type"] = "text/plain; charset=ISO-8859-1"
msg["X-Mailer"] = XMailer
Recipients = msg.getaddrlist("to") + msg.getaddrlist("cc") + msg.getaddrlist("bcc")
for i in range(len(Recipients)):
Recipients[i] = Recipients[i][1]
return sendMessage(From, Recipients, msg)
开发者ID:MinasAbrahamyan,项目名称:bobomail,代码行数:31,代码来源:sendmail.py
示例7: __init__
def __init__(self):
"""Initialize the request.
Subclasses are responsible for invoking super
and initializing self._time.
"""
Message.__init__(self)
self._transaction = None
开发者ID:Cito,项目名称:w4py,代码行数:8,代码来源:Request.py
示例8: createFromValues
def createFromValues(self, taskid, ts, hmac, certhash, trace):
# set message type and length (72B for taskid, ts, hmac and
# certhash plus length of traceroute)
Message.createFromValues(self, messageTypes["TASK_REPLY_KNOWN_CERT"], 72 + len(trace))
self.taskid = taskid
self.ts = ts
self.hmac = hmac
self.certhash = certhash
self.trace = trace
开发者ID:crossbear,项目名称:Crossbear,代码行数:9,代码来源:HTRepKnownCert.py
示例9: getAvailability
def getAvailability(strProvider, serviceStr, bidId):
messageGetAvailability = Message('')
messageGetAvailability.setMethod(Message.GET_AVAILABILITY)
messageGetAvailability.setParameter('Provider', strProvider)
messageGetAvailability.setParameter('Service', serviceStr)
messageGetAvailability.setParameter('Bid', bidId)
return messageGetAvailability
开发者ID:lmarent,项目名称:network_agents_ver2_python,代码行数:7,代码来源:socket_client_test_marketplace.py
示例10: send_availability
def send_availability(strProv,strResource, quantity):
messageAvail = Message('')
messageAvail.setMethod(Message.SEND_AVAILABILITY)
messageAvail.setParameter('Provider', strProv)
messageAvail.setParameter('Resource', strResource)
messageAvail.setParameter('Quantity', quantity)
return messageAvail
开发者ID:lmarent,项目名称:network_agents_ver2_python,代码行数:7,代码来源:socket_client_test_marketplace.py
示例11: verifyPurchaseMessage
def verifyPurchaseMessage(sock2, qty):
received = sock2.recv(16800)
messagePurchase= Message(received)
print messagePurchase.__str__()
if (not messagePurchase.isMessageStatusOk()):
raise FoundationException("error in creating purchase")
else:
# verify that the quantity purchased.
qtyPurchasedStr = messagePurchase.getParameter('Quantity_Purchased')
qtyPurchased = float(qtyPurchasedStr)
if (qtyPurchased <> qty):
print "error in creating purchase - Qty purchased" + str(qtyPurchased)+ " not equal to " + str(qty)
开发者ID:lmarent,项目名称:network_agents_ver2_python,代码行数:12,代码来源:socket_client_test_marketplace.py
示例12: createFromValues
def createFromValues(self, options, certs, hostname, ip, port):
self.certchain = []
chainlength = 0
for cert in certs:
derobj = ssl.PEM_cert_to_DER_cert(cert)
chainlength += len(derobj)
self.certchain.append(derobj)
Message.createFromValues(self, messageTypes['CERT_VERIFY_REQUEST'], 4 + chainlength + len(hostname) + len(ip) + len(str(port)))
self.options = options
self.hostname = hostname
self.ip = ip
self.port = port
开发者ID:UCASREN,项目名称:Crossbear,代码行数:13,代码来源:CertVerifyReq.py
示例13: createFromValues
def createFromValues(self, taskid, ts, hmac, certchain, trace):
# Convert certs to DER
self.certchain = []
for cert in certchain[:min(255,len(certchain))]:
self.certchain.append(ssl.PEM_cert_to_DER_cert(cert))
certlength = sum(len(x) for x in self.certchain)
# set message type and length ( 41 Bytes for taskid, ts, hmac and number of certificates
# plus length of trace and length of cert chain.
Message.createFromValues(self, messageTypes['TASK_REPLY_NEW_CERT'], 41 + len(trace) + certlength)
self.taskid = taskid
self.ts = ts
self.hmac = hmac
self.trace = trace
开发者ID:UCASREN,项目名称:Crossbear,代码行数:13,代码来源:HTRepNewCert.py
示例14: __getitem__
def __getitem__(self, index):
if type(index) == type(""):
self.chdir(index)
return self
if type(index) == type(()): index, preview = index
else: preview = false
if preview: resp, data = self.con.query("fetch", (index, '(FLAGS RFC822.HEADER RFC822.SIZE)'))
else: resp, data = self.con.query("fetch", (index, '(FLAGS RFC822 RFC822.SIZE)'))
m = Message(StringIO(data[0][1]), preview)
m.unique_num = int(index)
m.Size = int(data[1][find(data[1], "RFC822.SIZE")+11:-1])
m.SizeStr = bytesizestr(m.Size)
return m
开发者ID:MinasAbrahamyan,项目名称:bobomail,代码行数:13,代码来源:fetchmail.py
示例15: run
def run(self):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(('', self.port))
while True:
data, ip_addr = s.recvfrom(1024)
incomeMessage = Message()
incomeMessage.decapsulate(data)
# print (incomeMessage.header.type)
# print (incomeMessage.header.length)
# start a new thread to handle message
_thread.start_new_thread(self.handleMessage, (incomeMessage, ip_addr))
开发者ID:CharKwayTeow,项目名称:ddsp,代码行数:13,代码来源:DDSP.py
示例16: verifyAvailabilityMessage
def verifyAvailabilityMessage(sock2, qty):
received = sock2.recv(16800)
messageAvail= Message(received)
print messageAvail.__str__()
if (not messageAvail.isMessageStatusOk()):
raise FoundationException("error in the availability message")
else:
# verify that the quantity purchased.
qtyStr = messageAvail.getParameter('Quantity')
qtyAvail = float(qtyStr)
qtyAvail = round(qtyAvail,2)
if (qtyAvail <> qty):
print "error in the quantity available" + str(qtyAvail)+ "- Qty not equal to " + str(qty)
开发者ID:lmarent,项目名称:network_agents_ver2_python,代码行数:13,代码来源:socket_client_test_marketplace.py
示例17: createFromBytes
def createFromBytes(self, msgtype, data):
Message.createFromBytes(self, msgtype, data)
self.hmac = data[:32]
if msgtype == MessageTypes.messageTypes['PUBLIC_IP_NOTIF4']:
ipLen = 4
self.ipversion = 4
elif msgtype == MessageTypes.messageTypes['PUBLIC_IP_NOTIF6']:
ipLen = 16
self.ipversion = 6
self.publicIP = unpack(">" + "B" * ipLen, data[32:32 + ipLen])
if ipLen == 4:
self.publicIPString = ".".join(str(x) for x in self.publicIP)
elif ipLen == 16:
self.publicIPString = ":".join(str(x) for x in self.publicIP)
开发者ID:UCASREN,项目名称:Crossbear,代码行数:14,代码来源:PipNot.py
示例18: createFromBytes
def createFromBytes(self, msgtype, data):
"""
Initialiser. Compute the difference between cb server time and local time
# (in milliseconds) and store it.
"""
Message.createFromBytes(self, msgtype, data)
if len(data) != 4:
raise (ValueError,
"Supplied data doesn't have the correct length: " +\
str(len(data)))
# get four bytes from data and convert them to long. Why is this a signed long?
# Python documentation says that time() returns a float.
(self.servertime,) = unpack(">l", data[:4])
self.diff = self.servertime - time()
开发者ID:UCASREN,项目名称:Crossbear,代码行数:14,代码来源:CurServTime.py
示例19: writing_log
def writing_log(input_file, output_file):
time = 0
out = open(output_file, "w")
packet = "IDH: %02X, IDL: %02X, Len: 08, Data: "
# out.write(packet + '\n')
f = open(input_file, "r")
for line in f:
time += 1
msg = Message(line)
msg.TS = time
message = "IDH: %02X, IDL: %02X, Len: %02X, Data: %s TS: %s" % (int(msg.idh, 16), int(msg.idl, 16), int(msg.len, 16), msg.data, msg.TS)
print message
out.write(message + '\n')
f.close()
开发者ID:zambreno,项目名称:RCL,代码行数:15,代码来源:R_W_Logs.py
示例20: makePart
def makePart(body, encoding):
msg = Message(StringIO())
msg["Content-Transfer-Encoding"] = encoding
out = StringIO()
if encoding != "base64":
encode(StringIO(replace(body,"\r","")), out, encoding)
else:
encode(StringIO(body), out, encoding)
msg.body = out.getvalue()
if encoding == "quoted-printable":
lines = split(msg.body, "\n")
for i in xrange(len(lines)):
if lines[i] and lines[i][:5] == 'From ':
lines[i] = "=%02x" % ord("F") + lines[i][1:]
msg.body = join(lines, "\n")
return msg
开发者ID:MinasAbrahamyan,项目名称:bobomail,代码行数:16,代码来源:sendmail.py
注:本文中的Message.Message类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论