Subversion Repositories SmartDukaan

Rev

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

Rev 17041 Rev 17233
Line 1... Line 1...
1
from datetime import datetime
1
from datetime import datetime
-
 
2
from email import encoders
-
 
3
from email.mime.base import MIMEBase
-
 
4
from email.mime.multipart import MIMEMultipart
-
 
5
from email.mime.text import MIMEText
2
from paramiko.client import SSHClient
6
from paramiko.client import SSHClient
3
import StringIO
7
import StringIO
4
import base64
8
import base64
5
import gzip
9
import gzip
6
import logging
10
import logging
7
import os
11
import os
8
import paramiko
12
import paramiko
9
import pymongo
13
import pymongo
10
import random
14
import random
-
 
15
import smtplib
11
import socket
16
import socket
12
import time
17
import time
13
import urllib
18
import urllib
14
import urllib2
19
import urllib2
15
import urlparse
20
import urlparse
16
#TODO Need to add messy stuff to conf.
21
#TODO Need to add messy stuff to conf.
-
 
22
 
-
 
23
 
-
 
24
SENDER = "cnc.center@shop2020.in"
-
 
25
PASSWORD = "5h0p2o2o"
-
 
26
SMTP_SERVER = "smtp.gmail.com"
-
 
27
SMTP_PORT = 587    
-
 
28
 
-
 
29
 
-
 
30
 
17
con=None
31
con=None
18
headers = { 
32
headers = { 
19
            'User-agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
33
            'User-agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
20
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
34
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
21
            'Accept-Language' : 'en-US,en;q=0.8',                     
35
            'Accept-Language' : 'en-US,en;q=0.8',                     
Line 249... Line 263...
249
    except ValueError:
263
    except ValueError:
250
        return ""
264
        return ""
251
        
265
        
252
if __name__ == '__main__':
266
if __name__ == '__main__':
253
    print transformUrl("http://www.flipkart.com/redmi-2/p/itme8ygtcfax6w39",2)
267
    print transformUrl("http://www.flipkart.com/redmi-2/p/itme8ygtcfax6w39",2)
-
 
268
 
-
 
269
def sendmail(email, message, title, *varargs):
-
 
270
    if email == "":
-
 
271
        return
-
 
272
    mailServer = smtplib.SMTP(SMTP_SERVER, SMTP_PORT)
-
 
273
    mailServer.ehlo()
-
 
274
    mailServer.starttls()
-
 
275
    mailServer.ehlo()
-
 
276
    
-
 
277
    # Create the container (outer) email message.
-
 
278
    msg = MIMEMultipart()
-
 
279
    msg['Subject'] = title
-
 
280
    msg.preamble = title
-
 
281
    html_msg = MIMEText(message, 'html')
-
 
282
    msg.attach(html_msg)
-
 
283
    
-
 
284
    #snapdeal more to be added here
-
 
285
    for fileName in varargs:
-
 
286
        snapdeal = MIMEBase('application', 'vnd.ms-excel')
-
 
287
        snapdeal.set_payload(file(fileName).read())
-
 
288
        encoders.encode_base64(snapdeal)
-
 
289
        snapdeal.add_header('Content-Disposition', 'attachment;filename=' + fileName)
-
 
290
        msg.attach(snapdeal)
-
 
291
 
-
 
292
 
-
 
293
    MAILTO = email 
-
 
294
    mailServer.login(SENDER, PASSWORD)
-
 
295
    mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
254
    
296
    
255
    
297
    
256
def readSSh(fileName):
298
def readSSh(fileName):
257
    try:
299
    try:
258
        str1 = open(fileName).read()
300
        str1 = open(fileName).read()