Subversion Repositories SmartDukaan

Rev

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

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