| 4076 |
chandransh |
1 |
#!/usr/bin/python
|
|
|
2 |
|
|
|
3 |
import time
|
|
|
4 |
import datetime
|
|
|
5 |
import optparse
|
|
|
6 |
import sys
|
|
|
7 |
import csv
|
|
|
8 |
import xlrd
|
|
|
9 |
import traceback
|
|
|
10 |
|
|
|
11 |
if __name__ == '__main__' and __package__ is None:
|
|
|
12 |
import os
|
|
|
13 |
sys.path.insert(0, os.getcwd())
|
|
|
14 |
|
|
|
15 |
from shop2020.clients.TransactionClient import TransactionClient
|
|
|
16 |
from shop2020.clients.HelperClient import HelperClient
|
|
|
17 |
from shop2020.thriftpy.model.v1.order.ttypes import TransactionServiceException
|
|
|
18 |
|
|
|
19 |
from_user = 'help@saholic.com'
|
|
|
20 |
from_pwd = '5h0p2o2o'
|
| 7331 |
amit.gupta |
21 |
to = ['rajveer.singh@shop2020.in']
|
| 4076 |
chandransh |
22 |
|
|
|
23 |
def create_emails(filename):
|
|
|
24 |
print "Reading order list from:" + filename
|
|
|
25 |
workbook = xlrd.open_workbook(filename)
|
|
|
26 |
sheet = workbook.sheet_by_index(0)
|
|
|
27 |
num_rows = sheet.nrows
|
|
|
28 |
picked_up_orders = {}
|
|
|
29 |
txnClient = TransactionClient().get_client()
|
|
|
30 |
for rownum in range(2, num_rows):
|
|
|
31 |
order_id, product_name = sheet.row_values(rownum)[0:2]
|
|
|
32 |
try:
|
|
|
33 |
order = txnClient.getOrder(int(order_id))
|
|
|
34 |
picked_up_orders[int(order_id)] = [str(product_name), order]
|
|
|
35 |
subject = "Delay in delivery of your order " + str(order.id)
|
|
|
36 |
body = "Dear " + order.customer_name + ",<br/><br/>Thanks for shopping at www.saholic.com.<br/><br/>In reference to your order ID " + str(order.id) + " for " + str(product_name) + " placed with us, we would like to inform you that due to some unforeseen circumstances at our warehouse, delivery would be delayed by a day or two.<br/><br/>We deeply regret the same.<br/><br/>Thanks & Regards<br/>Saholic Team "
|
|
|
37 |
try:
|
|
|
38 |
helper_client = HelperClient().get_client()
|
| 5866 |
rajveer |
39 |
helper_client.saveUserEmailForSending([order.customer_email], "", subject, body, str(order.id), "TransactionInfo", [], [])
|
| 4076 |
chandransh |
40 |
except Exception as e:
|
|
|
41 |
print order.id
|
|
|
42 |
except TransactionServiceException as tex:
|
|
|
43 |
print tex.message
|
|
|
44 |
|
|
|
45 |
print "Picked up Orders:"
|
|
|
46 |
print picked_up_orders
|
|
|
47 |
|
|
|
48 |
def main():
|
|
|
49 |
parser = optparse.OptionParser()
|
|
|
50 |
parser.add_option("-f", "--file", dest="filename",
|
|
|
51 |
default="xxx.xls", type="string",
|
|
|
52 |
help="The FILE this report is for",
|
|
|
53 |
metavar="FILE")
|
|
|
54 |
(options, args) = parser.parse_args()
|
|
|
55 |
if len(args) != 0:
|
|
|
56 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
|
|
57 |
create_emails(options.filename)
|
|
|
58 |
|
|
|
59 |
if __name__ == '__main__':
|
|
|
60 |
main()
|