Subversion Repositories SmartDukaan

Rev

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

Rev 13828 Rev 14257
Line 2... Line 2...
2
from BeautifulSoup import BeautifulSoup
2
from BeautifulSoup import BeautifulSoup
3
import pymongo
3
import pymongo
4
import re
4
import re
5
from dtr.utils.utils import to_java_date
5
from dtr.utils.utils import to_java_date
6
from datetime import datetime
6
from datetime import datetime
-
 
7
import optparse
7
 
8
 
8
con = None
9
con = None
-
 
10
parser = optparse.OptionParser()
-
 
11
parser.add_option("-m", "--m", dest="mongoHost",
-
 
12
                      default="localhost",
-
 
13
                      type="string", help="The HOST where the mongo server is running",
-
 
14
                      metavar="mongo_host")
-
 
15
 
-
 
16
(options, args) = parser.parse_args()
-
 
17
 
9
bestSellers = []
18
bestSellers = []
10
now = datetime.now()
19
now = datetime.now()
11
 
20
 
12
class __RankInfo:
21
class __RankInfo:
13
    
22
    
14
    def __init__(self, identifier, rank):
23
    def __init__(self, identifier, rank):
15
        self.identifier = identifier
24
        self.identifier = identifier
16
        self.rank  = rank
25
        self.rank  = rank
17
 
26
 
18
def get_mongo_connection(host='localhost', port=27017):
27
def get_mongo_connection(host=options.mongoHost, port=27017):
19
    global con
28
    global con
20
    if con is None:
29
    if con is None:
21
        print "Establishing connection %s host and port %d" %(host,port)
30
        print "Establishing connection %s host and port %d" %(host,port)
22
        try:
31
        try:
23
            con = pymongo.MongoClient(host, port)
32
            con = pymongo.MongoClient(host, port)