Subversion Repositories SmartDukaan

Rev

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

Rev 13913 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
asin_regex = r'/([A-Z0-9]{10})'
-
 
9
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
 
-
 
18
 
-
 
19
asin_regex = r'/([A-Z0-9]{10})'
10
bestSellers = []
20
bestSellers = []
11
now = datetime.now()
21
now = datetime.now()
12
 
22
 
13
class __RankInfo:
23
class __RankInfo:
14
    
24
    
15
    def __init__(self, identifier, rank):
25
    def __init__(self, identifier, rank):
16
        self.identifier = identifier
26
        self.identifier = identifier
17
        self.rank  = rank
27
        self.rank  = rank
18
 
28
 
19
def get_mongo_connection(host='localhost', port=27017):
29
def get_mongo_connection(host=options.mongoHost, port=27017):
20
    global con
30
    global con
21
    if con is None:
31
    if con is None:
22
        print "Establishing connection %s host and port %d" %(host,port)
32
        print "Establishing connection %s host and port %d" %(host,port)
23
        try:
33
        try:
24
            con = pymongo.MongoClient(host, port)
34
            con = pymongo.MongoClient(host, port)