Subversion Repositories SmartDukaan

Rev

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

Rev 14214 Rev 14243
Line 1... Line 1...
1
import pysolr
1
import pysolr
2
import pymongo
2
import pymongo
3
import shutil
3
import shutil
4
import json
4
import json
5
import os
5
import os
-
 
6
import optparse
6
 
7
 
7
con=None
8
con=None
8
 
9
 
9
filePath = '/tmp/autosuggest.json'
10
filePath = '/tmp/autosuggest.json'
10
destFilePath = '/home/kshitij/'
11
destFilePath = '/home/kshitij/'
11
 
12
 
12
categoryMap = {3:'Mobiles',5:'Tablets'}
13
categoryMap = {3:'Mobiles',5:'Tablets'}
13
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
14
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
14
xstr = lambda s: s or ""
15
xstr = lambda s: s or ""
15
 
16
 
-
 
17
parser = optparse.OptionParser()
-
 
18
parser.add_option("-m", "--m", dest="mongoHost",
-
 
19
                      default="localhost",
-
 
20
                      type="string", help="The HOST where the mongo server is running",
-
 
21
                      metavar="HOST")
-
 
22
 
-
 
23
(options, args) = parser.parse_args()
-
 
24
 
-
 
25
 
16
class __SkuInfo:
26
class __SkuInfo:
17
    
27
    
18
    def __init__(self, id, skuBundleId, brand, model_name, source_product_name, category_id, category, available_price, mrp, in_stock, \
28
    def __init__(self, id, skuBundleId, brand, model_name, source_product_name, category_id, category, available_price, mrp, in_stock, \
19
                 source_id, store, title, thumbnail, priceUpdatedOn):
29
                 source_id, store, title, thumbnail, priceUpdatedOn):
20
        self.id = id
30
        self.id = id
Line 37... Line 47...
37
solr = pysolr.Solr("http://104.200.25.40:8080/solr/", timeout=10)
47
solr = pysolr.Solr("http://104.200.25.40:8080/solr/", timeout=10)
38
 
48
 
39
def pushData():
49
def pushData():
40
    l = []
50
    l = []
41
    catalogMap = {}
51
    catalogMap = {}
42
    items = get_mongo_connection().Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
52
    items = get_mongo_connection(options.mongoHost).Catalog.MasterData.find({'source_id' : { "$in": SOURCE_MAP.values() } })
43
    print items.count()
53
    print items.count()
44
    for item in items:
54
    for item in items:
45
        title = xstr(item['brand'])+" "+xstr(item['model_name'])
55
        title = xstr(item['brand'])+" "+xstr(item['model_name'])
46
        if not catalogMap.has_key(str(item['skuBundleId'])+" "+title):
56
        if not catalogMap.has_key(str(item['skuBundleId'])+" "+title):
47
            catalogMap[str(item['skuBundleId'])+" "+title] = [title]
57
            catalogMap[str(item['skuBundleId'])+" "+title] = [title]