Subversion Repositories SmartDukaan

Rev

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

Rev 14250 Rev 14256
Line 2... Line 2...
2
from dtr.utils.utils import to_java_date
2
from dtr.utils.utils import to_java_date
3
from datetime import datetime, timedelta
3
from datetime import datetime, timedelta
4
from dtr.utils import AmazonPriceOnlyScraper
4
from dtr.utils import AmazonPriceOnlyScraper
5
from multiprocessing import Pool as ThreadPool
5
from multiprocessing import Pool as ThreadPool
6
from multiprocessing import cpu_count
6
from multiprocessing import cpu_count
-
 
7
import optparse
7
 
8
 
8
con = None
9
con = None
9
 
10
 
-
 
11
parser = optparse.OptionParser()
-
 
12
parser.add_option("-m", "--m", dest="mongoHost",
-
 
13
                      default="localhost",
-
 
14
                      type="string", help="The HOST where the mongo server is running",
-
 
15
                      metavar="mongo_host")
-
 
16
 
-
 
17
(options, args) = parser.parse_args()
-
 
18
 
10
def get_mongo_connection(host='localhost', port=27017):
19
def get_mongo_connection(host=options.mongoHost, port=27017):
11
    global con
20
    global con
12
    if con is None:
21
    if con is None:
13
        print "Establishing connection %s host and port %d" %(host,port)
22
        print "Establishing connection %s host and port %d" %(host,port)
14
        try:
23
        try:
15
            con = pymongo.MongoClient(host, port)
24
            con = pymongo.MongoClient(host, port)