Subversion Repositories SmartDukaan

Rev

Rev 4279 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/python

'''
This script sends the daily report to bluedart

@author : Rajveer
'''
import optparse
import sys
import datetime


if __name__ == '__main__' and __package__ is None:
    import os
    sys.path.insert(0, os.getcwd())

from shop2020.utils.EmailAttachmentSender import mail, get_attachment_part
warehouses = {}
warehouses[0] = 'YusufSarai'
warehouses[3] = 'Gurgaon'
warehouses[4] = 'Ghaziabad'
warehouses[7] = 'Mahipalpur'
    
to_addresses = ["ajays@bluedart.com","samns@bluedart.com","shambhum@bluedart.com","mukesh.exchnet@bluedart.com",
                "sanjeevy.exchnet@bluedart.com","Satishkkumar.EXCHNET@bluedart.com","SarbjitS@bluedart.com",
                "ShahnawazM.EXCHNET@bluedart.com","smanoj@bluedart.com","kNarendra.EXCHNET@bluedart.com",
                "BittooN.EXCHNET@bluedart.com","AmitT.EXCHNET@bluedart.com","sandeep.sachdeva@shop2020.in"]
from_user = "cnc.center@shop2020.in"
from_pwd = "5h0p2o2o"

def send_report(warehouseId, warehouseName, providerId, isCod):
    today = datetime.date.today().strftime("%Y-%m-%d")
    filename = "/CourierDetailReports/courier-details-"
    if isCod:
        subject = "Saholic: COD Soft Data - " + warehouseName + " - Date:" + today
        text = "Find attached file for COD data" 
        filename = filename + "cod"
    else:
        subject = "Saholic: Prepaid Soft Data - " + warehouseName + " - Date:" + today
        text = "Find attached file for Prepaid data"
        filename = filename + "prepaid"
    
    
    filename = filename + "-" + str(warehouseId) + "-" + str(providerId) + "-" + today + ".xls";
    
    print filename
    if os.path.exists(filename):
        mail(from_user, from_pwd, to_addresses, subject, text, [get_attachment_part(filename)])

    
def main():
    '''
    parser = optparse.OptionParser()
    parser.add_option("-p", "--provider", dest="provider",
                   default="1", type="int",
                   help="The PROVIDER this alert is for",
                   metavar="PROVIDER")
    parser.add_option("-t", "--type", dest="type",
                   default="Prepaid", type="string",
                   help="TYPE of AWB nos. to track",
                   metavar="TYPE")
    parser.add_option("-T", "--threshold", dest="threshold",
                   default="200", type="int",
                   help="The THRESHOLD below which the alert should be raised",
                   metavar="THRESHOLD")
    (options, args) = parser.parse_args()
    if len(args) != 0:
        parser.error("You've supplied extra arguments. Are you sure you want to run this program?")
    '''
    
     
    for i in warehouses.keys():
        send_report(i, warehouses.get(i), 1, True)
        send_report(i, warehouses.get(i), 1, False)

if __name__ == '__main__':
    main()