Subversion Repositories SmartDukaan

Rev

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

Rev 16174 Rev 16429
Line 32... Line 32...
32
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
32
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
33
            'Accept-Language' : 'en-US,en;q=0.8',                     
33
            'Accept-Language' : 'en-US,en;q=0.8',                     
34
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
34
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
35
        }
35
        }
36
 
36
 
-
 
37
ignoreItems = [24291, 24102, 24101]
-
 
38
 
37
def get_mongo_connection(host=options.mongoHost, port=27017):
39
def get_mongo_connection(host=options.mongoHost, port=27017):
38
    global con
40
    global con
39
    if con is None:
41
    if con is None:
40
        print "Establishing connection %s host and port %d" %(host,port)
42
        print "Establishing connection %s host and port %d" %(host,port)
41
        try:
43
        try:
Line 94... Line 96...
94
#    pool.join()
96
#    pool.join()
95
#    print "joining threads at %s"%(str(datetime.now()))
97
#    print "joining threads at %s"%(str(datetime.now()))
96
 
98
 
97
 
99
 
98
def updatePrices(data):
100
def updatePrices(data):
-
 
101
    if data['_id'] in ignoreItems:
-
 
102
        print "Ignored items returning for %d"%(data['_id'])
-
 
103
        return
99
    if data['source_id']!=3:
104
    if data['source_id']!=3:
100
        return
105
        return
101
    print data['identifier']
106
    print data['identifier']
102
    if data['identifier'] is None or len(data['identifier'].strip())==0:
107
    if data['identifier'] is None or len(data['identifier'].strip())==0:
103
        print "returning"
108
        print "returning"
Line 129... Line 134...
129
        return
134
        return
130
    encoding =  chardet.detect(snapdeal_data)
135
    encoding =  chardet.detect(snapdeal_data)
131
    try:
136
    try:
132
        snapdeal_data = snapdeal_data.decode(encoding.get('encoding'))
137
        snapdeal_data = snapdeal_data.decode(encoding.get('encoding'))
133
    except:
138
    except:
134
        snapdeal_data = snapdeal_data.decode(encoding.get('latin-1'))
139
        snapdeal_data = snapdeal_data.decode('latin-1')
135
    try:
140
    try:
136
        vendorInfo = json.loads(snapdeal_data)
141
        vendorInfo = json.loads(snapdeal_data)
137
    except:
142
    except:
138
        print "Unable to load json for %d"%(data['_id'])
143
        print "Unable to load json for %d"%(data['_id'])
139
        return
144
        return