Subversion Repositories SmartDukaan

Rev

Rev 16267 | 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 = {}
6707 rajveer 19
warehouses[0] = 'KalkaJI'
20
warehouses[5] = 'KalkaJI'
4254 rajveer 21
warehouses[3] = 'Gurgaon'
22
warehouses[4] = 'Ghaziabad'
6781 rajveer 23
warehouses[9] = 'KalkaJI'
4254 rajveer 24
warehouses[7] = 'Mahipalpur'
7745 rajveer 25
warehouses[12] = 'Goregaon'
16267 manish.sha 26
warehouses[13] = 'Bhiwandi'
12812 manish.sha 27
warehouses[3298] = 'Hyderabad'
16259 manish.sha 28
warehouses[1765] = 'Bangalore'
4254 rajveer 29
 
6704 rajveer 30
to_addresses = {} 
9918 manish.sha 31
to_addresses[1] = ["ajays@bluedart.com","arunsingh@bluedart.com","PraveenKumar@bluedart.com","ADhiran.EXCHNET@bluedart.com",
6781 rajveer 32
                "DarpanS@bluedart.com","BijuS@bluedart.com","VijayK@bluedart.com","SonikaP@bluedart.com",
12812 manish.sha 33
                "sandeep.sachdeva@shop2020.in","sunil.kumar@shop2020.in"]
19395 manish.sha 34
to_addresses[3] = ["dispatch@delhivery.com", "rajaram.gupta@delhivery.com","sandeep.sachdeva@shop2020.in","sunil.kumar@shop2020.in"] 
12812 manish.sha 35
to_addresses[6] = ["sandeep.sachdeva@shop2020.in","sunil.kumar@shop2020.in", 'bookings@getsetred.net', 'arvind.chauhan@getsetred.net', 'okaops@getsetred.net'] 
4254 rajveer 36
from_user = "cnc.center@shop2020.in"
37
from_pwd = "5h0p2o2o"
38
 
6704 rajveer 39
def send_report(providerId):
40
    filenames = []
41
    for warehouseId in warehouses.keys():
42
        today = datetime.date.today()
43
        datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
44
 
45
        subject = "Saholic: Soft Data - All Warehouses - Date:" + datestr
46
        text = "Find attached file for All Warehouses pickup data" 
47
 
48
        filename = "/CourierDetailReports/courier-details-" + "cod" + "-" + str(warehouseId) + "-" + str(providerId) + "-" + datestr + ".xls";
49
        print filename
50
        if os.path.exists(filename):
51
            filenames.append(filename)
52
 
53
        filename = "/CourierDetailReports/courier-details-" + "prepaid" + "-" + str(warehouseId) + "-" + str(providerId) + "-" + datestr + ".xls";
54
        print filename
55
        if os.path.exists(filename):
56
            filenames.append(filename)
57
    mail(from_user, from_pwd, to_addresses[providerId], subject, text, [get_attachment_part(filename) for filename in filenames])
4254 rajveer 58
 
59
 
60
def main():
61
    '''
62
    parser = optparse.OptionParser()
63
    parser.add_option("-p", "--provider", dest="provider",
64
                   default="1", type="int",
65
                   help="The PROVIDER this alert is for",
66
                   metavar="PROVIDER")
67
    parser.add_option("-t", "--type", dest="type",
68
                   default="Prepaid", type="string",
69
                   help="TYPE of AWB nos. to track",
70
                   metavar="TYPE")
71
    parser.add_option("-T", "--threshold", dest="threshold",
72
                   default="200", type="int",
73
                   help="The THRESHOLD below which the alert should be raised",
74
                   metavar="THRESHOLD")
75
    (options, args) = parser.parse_args()
76
    if len(args) != 0:
77
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
78
    '''
79
 
80
 
6940 rajveer 81
    for i in (1,3,6):
6704 rajveer 82
        send_report(i)
4254 rajveer 83
 
84
if __name__ == '__main__':
85
    main()