Subversion Repositories SmartDukaan

Rev

Rev 16259 | 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 = {}
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"]
6704 rajveer 34
to_addresses[3] = ["dispatch@delhivery.com", "bhavesh.manglani@delhivery.com", "milind.sharma@delhivery.com", 
12812 manish.sha 35
                   "divya.jyoti@delhivery.com","sandeep.sachdeva@shop2020.in","sunil.kumar@shop2020.in"] 
36
to_addresses[6] = ["sandeep.sachdeva@shop2020.in","sunil.kumar@shop2020.in", 'bookings@getsetred.net', 'arvind.chauhan@getsetred.net', 'okaops@getsetred.net'] 
4254 rajveer 37
from_user = "cnc.center@shop2020.in"
38
from_pwd = "5h0p2o2o"
39
 
6704 rajveer 40
def send_report(providerId):
41
    filenames = []
42
    for warehouseId in warehouses.keys():
43
        today = datetime.date.today()
44
        datestr = str(today.year) + "-" + str(today.month) + "-" + str(today.day)
45
 
46
        subject = "Saholic: Soft Data - All Warehouses - Date:" + datestr
47
        text = "Find attached file for All Warehouses pickup data" 
48
 
49
        filename = "/CourierDetailReports/courier-details-" + "cod" + "-" + str(warehouseId) + "-" + str(providerId) + "-" + datestr + ".xls";
50
        print filename
51
        if os.path.exists(filename):
52
            filenames.append(filename)
53
 
54
        filename = "/CourierDetailReports/courier-details-" + "prepaid" + "-" + str(warehouseId) + "-" + str(providerId) + "-" + datestr + ".xls";
55
        print filename
56
        if os.path.exists(filename):
57
            filenames.append(filename)
58
    mail(from_user, from_pwd, to_addresses[providerId], subject, text, [get_attachment_part(filename) for filename in filenames])
4254 rajveer 59
 
60
 
61
def main():
62
    '''
63
    parser = optparse.OptionParser()
64
    parser.add_option("-p", "--provider", dest="provider",
65
                   default="1", type="int",
66
                   help="The PROVIDER this alert is for",
67
                   metavar="PROVIDER")
68
    parser.add_option("-t", "--type", dest="type",
69
                   default="Prepaid", type="string",
70
                   help="TYPE of AWB nos. to track",
71
                   metavar="TYPE")
72
    parser.add_option("-T", "--threshold", dest="threshold",
73
                   default="200", type="int",
74
                   help="The THRESHOLD below which the alert should be raised",
75
                   metavar="THRESHOLD")
76
    (options, args) = parser.parse_args()
77
    if len(args) != 0:
78
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
79
    '''
80
 
81
 
6940 rajveer 82
    for i in (1,3,6):
6704 rajveer 83
        send_report(i)
4254 rajveer 84
 
85
if __name__ == '__main__':
86
    main()