Subversion Repositories SmartDukaan

Rev

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

Rev 4066 Rev 4067
Line 10... Line 10...
10
from email import encoders
10
from email import encoders
11
from email.mime.text import MIMEText
11
from email.mime.text import MIMEText
12
from email.mime.base import MIMEBase
12
from email.mime.base import MIMEBase
13
from email.mime.multipart import MIMEMultipart
13
from email.mime.multipart import MIMEMultipart
14
from pyExcelerator import Workbook, Font, XFStyle
14
from pyExcelerator import Workbook, Font, XFStyle
-
 
15
from datetime import date
15
 
16
 
16
# Initialize db connection settings.
17
# Initialize db connection settings.
17
DB_HOST = "localhost"
18
DB_HOST = "localhost"
18
DB_USER = "root"
19
DB_USER = "root"
19
DB_PASSWORD = "shop2020"
20
DB_PASSWORD = "shop2020"
Line 111... Line 112...
111
    
112
    
112
    datecolmap = {}
113
    datecolmap = {}
113
    col = 6
114
    col = 6
114
    for monthnumber in monthdatesmap.keys():
115
    for monthnumber in monthdatesmap.keys():
115
        monthname = monthdatesmap[monthnumber][MONTHNAME]
116
        monthname = monthdatesmap[monthnumber][MONTHNAME]
116
        worksheet.write(0, col, monthname)
117
        worksheet.write(0, col, monthname, boldStyle)
117
        worksheet.write(1, col, 'Month', boldStyle)
118
        worksheet.write(1, col, 'Month', boldStyle)
118
        datemap ={}
119
        datemap ={}
119
        datemap[0] = col
120
        datemap[0] = col
120
        datecolmap[monthnumber] = datemap
121
        datecolmap[monthnumber] = datemap
121
        col += 1
122
        col += 1
Line 159... Line 160...
159
    mailServer.starttls()
160
    mailServer.starttls()
160
    mailServer.ehlo()
161
    mailServer.ehlo()
161
    
162
    
162
    # Create the container (outer) email message.
163
    # Create the container (outer) email message.
163
    msg = MIMEMultipart()
164
    msg = MIMEMultipart()
164
    msg['Subject'] = SUBJECT
165
    msg['Subject'] = SUBJECT + ' - ' + date.today().isoformat()
165
    msg['From'] = "bi@saholic.com"
166
    msg['From'] = "bi@saholic.com"
166
    msg['To'] = 'sku-recipients@saholic.com'
167
    msg['To'] = 'sku-recipients@saholic.com'
167
    msg.preamble = SUBJECT
168
    msg.preamble = SUBJECT + ' - ' + date.today().isoformat() 
168
    
169
    
169
    fileMsg = MIMEBase('application','vnd.ms-excel')
170
    fileMsg = MIMEBase('application','vnd.ms-excel')
170
    fileMsg.set_payload(file(TMP_FILE).read())
171
    fileMsg.set_payload(file(TMP_FILE).read())
171
    encoders.encode_base64(fileMsg)
172
    encoders.encode_base64(fileMsg)
172
    fileMsg.add_header('Content-Disposition','attachment;filename=Product-Report.xls')
173
    fileMsg.add_header('Content-Disposition','attachment;filename=Product-Report' + ' - ' + date.today().isoformat() + '.xls')
173
    msg.attach(fileMsg)
174
    msg.attach(fileMsg)
174
 
175
 
175
    mailServer.login(SENDER, PASSWORD)
176
    mailServer.login(SENDER, PASSWORD)
176
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
177
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
177
 
178