Subversion Repositories SmartDukaan

Rev

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

Rev 13898 Rev 13904
Line 7... Line 7...
7
import email
7
import email
8
from email.mime.multipart import MIMEMultipart
8
from email.mime.multipart import MIMEMultipart
9
import email.encoders
9
import email.encoders
10
import smtplib
10
import smtplib
11
 
11
 
12
p = []
-
 
13
con = None
12
con = None
14
 
13
 
15
class __SkuInfo:
14
class __SkuInfo:
16
    
15
    
17
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
16
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
Line 46... Line 45...
46
        except Exception, e:
45
        except Exception, e:
47
            print e
46
            print e
48
            return None
47
            return None
49
    return con
48
    return con
50
 
49
 
51
 
-
 
52
def getProducts():
50
def writeSheet():
53
    global p
51
    p = []
54
    data = get_mongo_connection().Catalog.Deals.find().sort([('totalPoints',pymongo.DESCENDING)])
52
    data = get_mongo_connection().Catalog.Deals.find().sort([('totalPoints',pymongo.DESCENDING)])
55
    print data.count()
53
    print data.count()
56
    for x in data:
54
    for x in data:
57
        s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
55
        s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
58
                           x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
56
                           x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
59
                           x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'])
57
                           x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'])
60
        p.append(s_info)
58
        p.append(s_info)
61
 
59
    
62
def writeSheet():
-
 
63
    wbk = xlwt.Workbook()
60
    wbk = xlwt.Workbook()
64
    sheet = wbk.add_sheet('Deals')
61
    sheet = wbk.add_sheet('Deals')
65
    xstr = lambda s: s or ""
62
    xstr = lambda s: s or ""
66
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
63
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
67
    
64
    
Line 159... Line 156...
159
        print "Successfully sent email"
156
        print "Successfully sent email"
160
    except:
157
    except:
161
        print "Error: unable to send email."
158
        print "Error: unable to send email."
162
 
159
 
163
def sendMail():
160
def sendMail():
164
    getProducts()
-
 
165
    writeSheet()
161
    writeSheet()
166
 
162
 
167
def main():
163
def main():
168
    sendMail()
164
    sendMail()
169
 
165