| 4254 |
rajveer |
1 |
#!/usr/bin/python
|
|
|
2 |
|
|
|
3 |
'''
|
|
|
4 |
This script sends the daily report to bluedart
|
|
|
5 |
|
|
|
6 |
@author : Rajveer
|
|
|
7 |
'''
|
|
|
8 |
import optparse
|
|
|
9 |
import sys
|
|
|
10 |
import datetime
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
if __name__ == '__main__' and __package__ is None:
|
|
|
14 |
import os
|
|
|
15 |
sys.path.insert(0, os.getcwd())
|
|
|
16 |
|
|
|
17 |
from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
|
|
|
18 |
warehouses = {}
|
|
|
19 |
warehouses[0] = 'YusufSarai'
|
|
|
20 |
warehouses[3] = 'Gurgaon'
|
|
|
21 |
warehouses[4] = 'Ghaziabad'
|
|
|
22 |
warehouses[7] = 'Mahipalpur'
|
|
|
23 |
|
|
|
24 |
to_addresses = ["ajays@bluedart.com","samns@bluedart.com","shambhum@bluedart.com","mukesh.exchnet@bluedart.com",
|
|
|
25 |
"sanjeevy.exchnet@bluedart.com","Satishkkumar.EXCHNET@bluedart.com","SarbjitS@bluedart.com",
|
|
|
26 |
"ShahnawazM.EXCHNET@bluedart.com","smanoj@bluedart.com","kNarendra.EXCHNET@bluedart.com",
|
|
|
27 |
"BittooN.EXCHNET@bluedart.com","AmitT.EXCHNET@bluedart.com","sandeep.sachdeva@shop2020.in"]
|
|
|
28 |
from_user = "cnc.center@shop2020.in"
|
|
|
29 |
from_pwd = "5h0p2o2o"
|
|
|
30 |
|
|
|
31 |
def send_report(warehouseId, warehouseName, providerId, isCod):
|
|
|
32 |
today = datetime.date.today().strftime("%Y-%m-%d")
|
|
|
33 |
filename = "/CourierDetailReports/courier-details-"
|
|
|
34 |
if isCod:
|
|
|
35 |
subject = "Saholic: COD Soft Data - " + warehouseName + " - Date:" + today
|
|
|
36 |
text = "Find attached file for COD data"
|
|
|
37 |
filename = filename + "cod"
|
|
|
38 |
else:
|
|
|
39 |
subject = "Saholic: Prepaid Soft Data - " + warehouseName + " - Date:" + today
|
|
|
40 |
text = "Find attached file for Prepaid data"
|
|
|
41 |
filename = filename + "prepaid"
|
|
|
42 |
|
|
|
43 |
|
|
|
44 |
filename = filename + "-" + str(warehouseId) + "-" + str(providerId) + "-" + today + ".xls";
|
|
|
45 |
|
|
|
46 |
print filename
|
|
|
47 |
if os.path.exists(filename):
|
|
|
48 |
mail(from_user, from_pwd, to_addresses, subject, text, [get_attachment_part(filename)])
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
def main():
|
|
|
52 |
'''
|
|
|
53 |
parser = optparse.OptionParser()
|
|
|
54 |
parser.add_option("-p", "--provider", dest="provider",
|
|
|
55 |
default="1", type="int",
|
|
|
56 |
help="The PROVIDER this alert is for",
|
|
|
57 |
metavar="PROVIDER")
|
|
|
58 |
parser.add_option("-t", "--type", dest="type",
|
|
|
59 |
default="Prepaid", type="string",
|
|
|
60 |
help="TYPE of AWB nos. to track",
|
|
|
61 |
metavar="TYPE")
|
|
|
62 |
parser.add_option("-T", "--threshold", dest="threshold",
|
|
|
63 |
default="200", type="int",
|
|
|
64 |
help="The THRESHOLD below which the alert should be raised",
|
|
|
65 |
metavar="THRESHOLD")
|
|
|
66 |
(options, args) = parser.parse_args()
|
|
|
67 |
if len(args) != 0:
|
|
|
68 |
parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
|
|
|
69 |
'''
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
for i in warehouses.keys():
|
|
|
73 |
send_report(i, warehouses.get(i), 1, True)
|
|
|
74 |
send_report(i, warehouses.get(i), 1, False)
|
|
|
75 |
|
|
|
76 |
if __name__ == '__main__':
|
|
|
77 |
main()
|