Subversion Repositories SmartDukaan

Rev

Rev 4254 | Rev 6704 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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):
4279 rajveer 32
    today = datetime.date.today()
33
    datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
4254 rajveer 34
    filename = "/CourierDetailReports/courier-details-"
35
    if isCod:
4279 rajveer 36
        subject = "Saholic: COD Soft Data - " + warehouseName + " - Date:" + datestr
4254 rajveer 37
        text = "Find attached file for COD data" 
38
        filename = filename + "cod"
39
    else:
4279 rajveer 40
        subject = "Saholic: Prepaid Soft Data - " + warehouseName + " - Date:" + datestr
4254 rajveer 41
        text = "Find attached file for Prepaid data"
42
        filename = filename + "prepaid"
43
 
44
 
4279 rajveer 45
    filename = filename + "-" + str(warehouseId) + "-" + str(providerId) + "-" + datestr + ".xls";
4254 rajveer 46
 
47
    print filename
48
    if os.path.exists(filename):
49
        mail(from_user, from_pwd, to_addresses, subject, text, [get_attachment_part(filename)])
50
 
51
 
52
def main():
53
    '''
54
    parser = optparse.OptionParser()
55
    parser.add_option("-p", "--provider", dest="provider",
56
                   default="1", type="int",
57
                   help="The PROVIDER this alert is for",
58
                   metavar="PROVIDER")
59
    parser.add_option("-t", "--type", dest="type",
60
                   default="Prepaid", type="string",
61
                   help="TYPE of AWB nos. to track",
62
                   metavar="TYPE")
63
    parser.add_option("-T", "--threshold", dest="threshold",
64
                   default="200", type="int",
65
                   help="The THRESHOLD below which the alert should be raised",
66
                   metavar="THRESHOLD")
67
    (options, args) = parser.parse_args()
68
    if len(args) != 0:
69
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
70
    '''
71
 
72
 
73
    for i in warehouses.keys():
74
        send_report(i, warehouses.get(i), 1, True)
75
        send_report(i, warehouses.get(i), 1, False)
76
 
77
if __name__ == '__main__':
78
    main()