| Line 4... |
Line 4... |
| 4 |
from dtr.utils.utils import to_java_date
|
4 |
from dtr.utils.utils import to_java_date
|
| 5 |
from datetime import datetime, timedelta
|
5 |
from datetime import datetime, timedelta
|
| 6 |
import time
|
6 |
import time
|
| 7 |
|
7 |
|
| 8 |
con = None
|
8 |
con = None
|
| 9 |
now = datetime.now()
|
- |
|
| 10 |
print to_java_date(now)
|
- |
|
| 11 |
|
9 |
|
| 12 |
headers = {
|
10 |
headers = {
|
| 13 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
11 |
'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
|
| 14 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
12 |
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
| 15 |
'Accept-Language' : 'en-US,en;q=0.8',
|
13 |
'Accept-Language' : 'en-US,en;q=0.8',
|
| Line 26... |
Line 24... |
| 26 |
print e
|
24 |
print e
|
| 27 |
return None
|
25 |
return None
|
| 28 |
return con
|
26 |
return con
|
| 29 |
|
27 |
|
| 30 |
def updatePrices():
|
28 |
def updatePrices():
|
| 31 |
snapdealBestSellers = list(get_mongo_connection().Catalog.MasterData.find({'rank':{'$gt':0},'source_id':3}))
|
29 |
snapdealBestSellers = list(get_mongo_connection().Catalog.MasterData.find({'rank':{'$gt':0}}))
|
| 32 |
for data in snapdealBestSellers:
|
30 |
for data in snapdealBestSellers:
|
| - |
|
31 |
if data['source_id']!=3:
|
| - |
|
32 |
continue
|
| 33 |
print data['identifier']
|
33 |
print data['identifier']
|
| 34 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
34 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 35 |
print "continue"
|
35 |
print "continue"
|
| 36 |
continue
|
36 |
continue
|
| 37 |
|
37 |
|
| 38 |
try:
|
38 |
try:
|
| 39 |
if data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
39 |
if data['priceUpdatedOn'] > to_java_date(datetime.now() - timedelta(minutes=5)):
|
| 40 |
print "sku id is already updated",data['_id']
|
40 |
print "sku id is already updated",data['_id']
|
| 41 |
continue
|
41 |
continue
|
| 42 |
except:
|
42 |
except:
|
| 43 |
pass
|
43 |
pass
|
| 44 |
|
44 |
|
| Line 62... |
Line 62... |
| 62 |
print lowestOfferPrice
|
62 |
print lowestOfferPrice
|
| 63 |
print instock
|
63 |
print instock
|
| 64 |
print stock
|
64 |
print stock
|
| 65 |
print "*************"
|
65 |
print "*************"
|
| 66 |
if instock == 1:
|
66 |
if instock == 1:
|
| 67 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice,'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':instock}}, multi=True)
|
67 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice,'updatedOn':to_java_date(datetime.now()),'priceUpdatedOn':to_java_date(datetime.now()),'in_stock':instock}}, multi=True)
|
| 68 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice , 'in_stock':instock}}, multi=True)
|
68 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestOfferPrice , 'in_stock':instock}}, multi=True)
|
| 69 |
else:
|
69 |
else:
|
| 70 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':instock,'priceUpdatedOn':to_java_date(now)}}, multi=True)
|
70 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(datetime.now()),'in_stock':instock,'priceUpdatedOn':to_java_date(datetime.now())}}, multi=True)
|
| 71 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':instock}}, multi=True)
|
71 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':instock}}, multi=True)
|
| 72 |
|
72 |
|
| 73 |
try:
|
73 |
try:
|
| 74 |
recomputeDeal(data['skuBundleId'])
|
74 |
recomputeDeal(data['skuBundleId'])
|
| 75 |
except:
|
75 |
except:
|