Subversion Repositories SmartDukaan

Rev

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

Rev 14840 Rev 15174
Line 10... Line 10...
10
from dtr.storage.MemCache import MemCache
10
from dtr.storage.MemCache import MemCache
11
from functools import partial
11
from functools import partial
12
import threading
12
import threading
13
from dtr.utils.utils import getCashBack
13
from dtr.utils.utils import getCashBack
14
import traceback
14
import traceback
-
 
15
from shop2020.config.client.ConfigClient import ConfigClient
-
 
16
 
-
 
17
config_client = ConfigClient()
-
 
18
host_memCache = config_client.get_property('mem_cache_host_dtr')
-
 
19
host = config_client.get_property('mongo_dtr_host')
-
 
20
 
-
 
21
mc = MemCache(host_memCache)
15
 
22
 
16
mc = MemCache("127.0.0.1")
-
 
17
 
23
 
18
con = None
24
con = None
19
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
25
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
20
 
26
 
21
headers = { 
27
headers = { 
Line 23... Line 29...
23
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
29
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
24
            'Accept-Language' : 'en-US,en;q=0.8',                     
30
            'Accept-Language' : 'en-US,en;q=0.8',                     
25
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
31
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
26
        }
32
        }
27
 
33
 
28
def get_mongo_connection(host='localhost', port=27017):
34
def get_mongo_connection(port=27017):
29
    global con
35
    global con
30
    if con is None:
36
    if con is None:
31
        print "Establishing connection %s host and port %d" %(host,port)
37
        print "Establishing connection %s host and port %d" %(host,port)
32
        try:
38
        try:
33
            con = pymongo.MongoClient(host, port)
39
            con = pymongo.MongoClient(host, port)
Line 362... Line 368...
362
        if len(manualDeals) > 0:
368
        if len(manualDeals) > 0:
363
            item['dealFlag'] = 1
369
            item['dealFlag'] = 1
364
            item['dealType'] =manualDeals[0]['dealType']
370
            item['dealType'] =manualDeals[0]['dealType']
365
        info = returnLatestPrice(item, item['source_id'],False)
371
        info = returnLatestPrice(item, item['source_id'],False)
366
        print info
372
        print info
367
    try:
-
 
368
        thread = threading.Thread(target=recomputeDeal, args = (skuBundleId,))
-
 
369
        thread.daemon = True
-
 
370
        thread.start()    
-
 
371
    except:
-
 
372
        print "Unable to compute deal for ",skuBundleId
-
 
373
 
-
 
374
 
373
 
375
def main():
374
def main():
376
    print "retuned %s"%(str(getLatestPrice(2313, 4)))
375
    print "retuned %s"%(str(getLatestPrice(2313, 4)))
377
 
376
 
378
if __name__=='__main__':
377
if __name__=='__main__':