Subversion Repositories SmartDukaan

Rev

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

Rev 20172 Rev 21135
Line 7... Line 7...
7
from datetime import datetime
7
from datetime import datetime
8
import optparse
8
import optparse
9
import smtplib
9
import smtplib
10
from email.mime.text import MIMEText
10
from email.mime.text import MIMEText
11
from email.mime.multipart import MIMEMultipart
11
from email.mime.multipart import MIMEMultipart
-
 
12
from shop2020.utils.EmailAttachmentSender import get_attachment_part
-
 
13
from shop2020.utils import EmailAttachmentSender
12
 
14
 
13
con = None
15
con = None
14
parser = optparse.OptionParser()
16
parser = optparse.OptionParser()
15
parser.add_option("-m", "--m", dest="mongoHost",
17
parser.add_option("-m", "--m", dest="mongoHost",
16
                      default="localhost",
18
                      default="localhost",
Line 148... Line 150...
148
        <td style="text-align:center">"""+(item.category)+"""</td>
150
        <td style="text-align:center">"""+(item.category)+"""</td>
149
        <td style="text-align:center">"""+str(item.rank)+"""</td>
151
        <td style="text-align:center">"""+str(item.rank)+"""</td>
150
        </tr>"""
152
        </tr>"""
151
    message+="""</tbody></table></body></html>"""
153
    message+="""</tbody></table></body></html>"""
152
    print message
154
    print message
153
    #recipients = ['kshitij.sood@saholic.com']
155
    recipients = ['kshitij.sood@saholic.com','ritesh.chauhan@saholic.com','aishwarya.singh@saholic.com']
154
    recipients = ['rajneesh.arora@saholic.com','kshitij.sood@saholic.com','chaitnaya.vats@saholic.com','ritesh.chauhan@saholic.com','khushal.bhatia@saholic.com']
156
    EmailAttachmentSender.mail_send_grid("dtr@profitmandi.com","apikey", "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", recipients, "Saholic Best Sellers",message ,[],[],[])              
155
    msg = MIMEMultipart()
157
    
156
    msg['Subject'] = "Saholic Best Sellers" + ' - ' + str(datetime.now())
-
 
157
    msg['From'] = ""
158
    
158
    msg['To'] = ",".join(recipients)
-
 
159
    msg.preamble = "Saholic Best Sellers" + ' - ' + str(datetime.now())
-
 
160
    html_msg = MIMEText(message, 'html')
-
 
161
    msg.attach(html_msg)
159
    
162
    
160
    
163
    smtpServer = smtplib.SMTP('localhost')
-
 
164
    smtpServer.set_debuglevel(1)
-
 
165
    sender = 'dtr@shop2020.in'
-
 
166
    try:
-
 
167
        smtpServer.sendmail(sender, recipients, msg.as_string())
-
 
168
        print "Successfully sent email"
-
 
169
    except:
-
 
170
        print "Error: unable to send email."        
-
 
171
 
-
 
172
def main():
161
def main():
173
    scrapeBestSellerMobiles()
162
    scrapeBestSellerMobiles()
174
    if len(bestSellers) > 0:
163
    if len(bestSellers) > 0:
175
        resetRanks('Mobiles')
164
        resetRanks('Mobiles')
176
        commitBestSellers('MOBILES')
165
        commitBestSellers('MOBILES')