Subversion Repositories SmartDukaan

Rev

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