| Line 8... |
Line 8... |
| 8 |
import optparse
|
8 |
import optparse
|
| 9 |
import smtplib
|
9 |
import smtplib
|
| 10 |
from email.mime.text import MIMEText
|
10 |
from email.mime.text import MIMEText
|
| 11 |
from email.mime.multipart import MIMEMultipart
|
11 |
from email.mime.multipart import MIMEMultipart
|
| 12 |
from datetime import datetime
|
12 |
from datetime import datetime
|
| - |
|
13 |
from shop2020.utils.EmailAttachmentSender import mail_html
|
| 13 |
|
14 |
|
| 14 |
order_list = []
|
15 |
order_list = []
|
| 15 |
RECIPIENTS = ['mcom.support@spicedigital.in','mohit.mehral@spicedigital.in','rajneesh.arora@saholic.com','kshitij.sood@saholic.com','anikendra.das@saholic.com']
|
16 |
RECIPIENTS = ['mcom.support@spicedigital.in','mohit.mehral@spicedigital.in','neeti.mittal@spicedigital.in','rajneesh.arora@saholic.com','kshitij.sood@saholic.com','anikendra.das@saholic.com', \
|
| - |
|
17 |
'amit.sirohi@saholic.com','ritesh.chauhan@saholic.com','shailesh.kumar@saholic.com']
|
| 16 |
|
18 |
|
| 17 |
class __Orders():
|
19 |
class __Orders():
|
| 18 |
|
20 |
|
| 19 |
def __init__(self, id, transactionTime, status, amount):
|
21 |
def __init__(self, id, transactionTime, status, amount):
|
| 20 |
self.id = id
|
22 |
self.id = id
|
| Line 22... |
Line 24... |
| 22 |
self.status = status
|
24 |
self.status = status
|
| 23 |
self.amount = amount
|
25 |
self.amount = amount
|
| 24 |
|
26 |
|
| 25 |
|
27 |
|
| 26 |
def getUnknownTransactions():
|
28 |
def getUnknownTransactions():
|
| - |
|
29 |
global order_list
|
| 27 |
saholic_orders = RechargeOrder.query.filter_by(status=RechargeOrderStatus.PAYMENT_SUCCESSFUL).all()
|
30 |
saholic_orders = RechargeOrder.query.filter_by(status=RechargeOrderStatus.PAYMENT_SUCCESSFUL).all()
|
| 28 |
for saholic_order in saholic_orders:
|
31 |
for saholic_order in saholic_orders:
|
| 29 |
order = __Orders(saholic_order.id, saholic_order.creationTimestamp, 'Unknown', saholic_order.totalAmount)
|
32 |
order = __Orders(saholic_order.id, saholic_order.creationTimestamp, 'Unknown', saholic_order.totalAmount)
|
| 30 |
order_list.append(order)
|
33 |
order_list.append(order)
|
| 31 |
hotspot_orders = RechargeTransaction.query.filter_by(status = RechargeOrderStatus.RECHARGE_UNKNOWN).all()
|
34 |
hotspot_orders = RechargeTransaction.query.filter_by(status = RechargeOrderStatus.RECHARGE_UNKNOWN).all()
|
| Line 52... |
Line 55... |
| 52 |
<td style="text-align:center">"""+str(order.amount)+"""</td>
|
55 |
<td style="text-align:center">"""+str(order.amount)+"""</td>
|
| 53 |
<td style="text-align:center">"""+str(order.transactionTime)+"""</td>
|
56 |
<td style="text-align:center">"""+str(order.transactionTime)+"""</td>
|
| 54 |
</tr>"""
|
57 |
</tr>"""
|
| 55 |
message+="""</tbody></table></body></html>"""
|
58 |
message+="""</tbody></table></body></html>"""
|
| 56 |
print message
|
59 |
print message
|
| 57 |
msg = MIMEMultipart()
|
- |
|
| 58 |
msg['Subject'] = "Recharge Status Unknown" + ' - ' + str(datetime.now())
|
60 |
mail_html("cnc.center@shop2020.in", "5h0p2o2o", RECIPIENTS, "Recharge Status Unknown" + ' - ' + str(datetime.now()), message, [])
|
| 59 |
msg['From'] = ""
|
- |
|
| 60 |
msg['To'] = ",".join(RECIPIENTS)
|
- |
|
| 61 |
msg.preamble = "Recharge Status Unknown" + ' - ' + str(datetime.now())
|
- |
|
| 62 |
html_msg = MIMEText(message, 'html')
|
- |
|
| 63 |
msg.attach(html_msg)
|
- |
|
| 64 |
|
- |
|
| 65 |
smtpServer = smtplib.SMTP('localhost')
|
- |
|
| 66 |
smtpServer.set_debuglevel(1)
|
- |
|
| 67 |
sender = 'cnc.center@shop2020.in'
|
- |
|
| 68 |
try:
|
- |
|
| 69 |
smtpServer.sendmail(sender, RECIPIENTS, msg.as_string())
|
- |
|
| 70 |
print "Successfully sent email"
|
- |
|
| 71 |
except:
|
- |
|
| 72 |
print "Error: unable to send email."
|
- |
|
| 73 |
|
61 |
|
| 74 |
def main():
|
62 |
def main():
|
| 75 |
parser = optparse.OptionParser()
|
63 |
parser = optparse.OptionParser()
|
| 76 |
parser.add_option("-H", "--host", dest="hostname",
|
64 |
parser.add_option("-H", "--host", dest="hostname",
|
| 77 |
default="localhost",
|
65 |
default="localhost",
|