Subversion Repositories SmartDukaan

Rev

Rev 5087 | Rev 5092 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5087 Rev 5091
Line 21... Line 21...
21
DB_USER = "root"
21
DB_USER = "root"
22
DB_PASSWORD = "shop2020"
22
DB_PASSWORD = "shop2020"
23
DB_NAME = "sales"
23
DB_NAME = "sales"
24
 
24
 
25
# KEY NAMES
25
# KEY NAMES
26
 
-
 
-
 
26
#'abhishek.mathur@shop2020.in', 
27
MAILTO = ['abhishek.mathur@shop2020.in', 'anupam.singh@shop2020.in']
27
MAILTO = ['anupam.singh@shop2020.in']
28
SENDER = "cnc.center@shop2020.in"
28
SENDER = "cnc.center@shop2020.in"
29
PASSWORD = "5h0p2o2o"
29
PASSWORD = "5h0p2o2o"
30
SUBJECT = "MySmartPrice Report"
30
SUBJECT = "MySmartPrice Report"
31
SMTP_SERVER = "smtp.gmail.com"
31
SMTP_SERVER = "smtp.gmail.com"
32
SMTP_PORT = 587    
32
SMTP_PORT = 587    
Line 84... Line 84...
84
      print "Error: unable to fetch data"
84
      print "Error: unable to fetch data"
85
      print e
85
      print e
86
    
86
    
87
    return productTuples
87
    return productTuples
88
 
88
 
89
def createXlsReport(productTuples):
89
def createXlsReport(productTuples, dateYesterday):
90
    workbook = Workbook()
90
    workbook = Workbook()
91
    worksheet = workbook.add_sheet("Sheet 1")
91
    worksheet = workbook.add_sheet("Sheet 1")
92
    boldStyle = XFStyle()
92
    boldStyle = XFStyle()
93
    f = Font()
93
    f = Font()
94
    f.bold = True
94
    f.bold = True
Line 109... Line 109...
109
        worksheet.write(row, 2, str(productTuple[2]))
109
        worksheet.write(row, 2, str(productTuple[2]))
110
        
110
        
111
    workbook.save(TMP_FILE)
111
    workbook.save(TMP_FILE)
112
    print "Spreadsheet Saved"
112
    print "Spreadsheet Saved"
113
 
113
 
114
def sendmail():
114
def sendmail(dateYesterday):
115
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
115
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
116
    mailServer.ehlo()
116
    mailServer.ehlo()
117
    mailServer.starttls()
117
    mailServer.starttls()
118
    mailServer.ehlo()
118
    mailServer.ehlo()
119
    
119
    
Line 142... Line 142...
142
        exit(1)
142
        exit(1)
143
    
143
    
144
    productTuples = getProductSaleData()
144
    productTuples = getProductSaleData()
145
    print "Number of tuples on " + dateYesterday + " : " + str(len(productTuples))
145
    print "Number of tuples on " + dateYesterday + " : " + str(len(productTuples))
146
    createXlsReport(productTuples, dateYesterday)
146
    createXlsReport(productTuples, dateYesterday)
147
    sendmail()
147
    sendmail(dateYesterday)
148
    
148
    
149
if __name__ == '__main__':
149
if __name__ == '__main__':
150
    main()
150
    main()