Subversion Repositories SmartDukaan

Rev

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

Rev 22307 Rev 22308
Line 16... Line 16...
16
#import pymongo
16
#import pymongo
17
#import pysolr
17
#import pysolr
18
 
18
 
19
 
19
 
20
parser = optparse.OptionParser()
20
parser = optparse.OptionParser()
21
parser.add_option("-d", "--d", dest="hostname",
21
parser.add_option("-d", "--d", dest="dbHost",
22
                      default="localhost",
22
                      default="127.0.0.1",
23
                      type="string", help="The HOST where the mysql server is running",
23
                      type="string", help="The HOST where the mysql server is running",
24
                      metavar="HOST")
24
                      metavar="DBHOST")
25
parser.add_option("-s", "--s", dest="solrPath",
25
parser.add_option("-s", "--s", dest="solrPath",
26
                      default="http://localhost:8983/solr/demo",
26
                      default="http://localhost:8984/solr/collection2",
-
 
27
                      type="string", help="Complete solr path",
-
 
28
                      metavar="SOLRHOST")
-
 
29
parser.add_option("-m", "--m", dest="mongoHost",
-
 
30
                      default="http://localhost:8984/solr/collection2",
27
                      type="string", help="Complete solr path",
31
                      type="string", help="Complete solr path",
28
                      metavar="HOST")
32
                      metavar="HOST")
29
 
33
 
30
(options, args) = parser.parse_args()
34
(options, args) = parser.parse_args()
31
 
35
 
32
 
36
 
33
DataService.initialize(db_hostname=options.hostname)
37
DataService.initialize(db_hostname=options.hostname)
34
 
-
 
35
solr = pysolr.Solr(options.solrPath, timeout=10)
38
solr = pysolr.Solr(options.solrPath, timeout=10)
36
 
39
 
-
 
40
def get_mongo_connection(host='localhost', port=27017):
-
 
41
    global con
-
 
42
    if con is None:
-
 
43
        print "Establishing connection %s host and port %d" %(host,port)
-
 
44
        try:
-
 
45
            con = pymongo.MongoClient(host, port)
-
 
46
        except Exception, e:
-
 
47
            print e
-
 
48
            return None
-
 
49
    return con
37
 
50
 
38
class __SkuInfo:
51
class __SkuInfo:
39
    
52
    
40
    def __init__(self, id, ids, brand, model_name, category_id, subCategoryId,thumbnail, title, brand_synonyms, model_name_synonyms, source_product_names, \
53
    def __init__(self, id, ids, brand, model_name, category_id, subCategoryId,thumbnail, title, brand_synonyms, model_name_synonyms, source_product_names, \
41
                 category, subCategory):
54
                 category, subCategory):
Line 105... Line 118...
105
            data[classkey] = obj.__class__.__name__
118
            data[classkey] = obj.__class__.__name__
106
        return data
119
        return data
107
    else:
120
    else:
108
        return obj
121
        return obj
109
    
122
    
110
def get_mongo_connection(host='localhost', port=27017):
-
 
111
    global con
-
 
112
    if con is None:
-
 
113
        print "Establishing connection %s host and port %d" %(host,port)
-
 
114
        try:
-
 
115
            con = pymongo.MongoClient(host, port)
-
 
116
        except Exception, e:
-
 
117
            print e
-
 
118
            return None
-
 
119
    return con
-
 
120
    
-
 
121
 
123
 
122
def populateTagItems():
124
def populateTagItems():
123
    
125
    
124
    
126
    
125
    tagRankingList = session.query(Tag_Ranking.catalogItemId).order_by(desc(Tag_Ranking.rankPoints)).all()
127
    tagRankingList = session.query(Tag_Ranking.catalogItemId).order_by(desc(Tag_Ranking.rankPoints)).all()