Subversion Repositories SmartDukaan

Rev

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

Rev 14252 Rev 14254
Line 4... Line 4...
4
from dtr.utils.utils import to_java_date
4
from dtr.utils.utils import to_java_date
5
from datetime import datetime, timedelta
5
from datetime import datetime, timedelta
6
import time
6
import time
7
from multiprocessing import Pool as ThreadPool
7
from multiprocessing import Pool as ThreadPool
8
from multiprocessing import cpu_count
8
from multiprocessing import cpu_count
-
 
9
import optparse
9
 
10
 
10
con = None
11
con = None
11
 
12
 
-
 
13
parser = optparse.OptionParser()
-
 
14
parser.add_option("-m", "--m", dest="mongoHost",
-
 
15
                      default="localhost",
-
 
16
                      type="string", help="The HOST where the mongo server is running",
-
 
17
                      metavar="mongo_host")
-
 
18
 
-
 
19
(options, args) = parser.parse_args()
-
 
20
 
-
 
21
 
12
headers = { 
22
headers = { 
13
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
23
           'User-agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
14
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
24
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
15
            'Accept-Language' : 'en-US,en;q=0.8',                     
25
            'Accept-Language' : 'en-US,en;q=0.8',                     
16
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
26
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
17
        }
27
        }
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)