Subversion Repositories SmartDukaan

Rev

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

Rev 14142 Rev 14258
Line 4... Line 4...
4
from shop2020.model.v1.catalog.impl.DataService import Item
4
from shop2020.model.v1.catalog.impl.DataService import Item
5
from shop2020.clients.InventoryClient import InventoryClient
5
from shop2020.clients.InventoryClient import InventoryClient
6
from dtr.utils.utils import to_java_date
6
from dtr.utils.utils import to_java_date
7
from datetime import datetime, timedelta
7
from datetime import datetime, timedelta
8
import time
8
import time
-
 
9
import optparse
9
 
10
 
-
 
11
parser = optparse.OptionParser()
-
 
12
parser.add_option("-h", "--host", dest="hostname",
-
 
13
                      default="localhost",
-
 
14
                      type="string", help="The HOST where the DB server is running",
-
 
15
                      metavar="host")
-
 
16
parser.add_option("-m", "--m", dest="mongoHost",
-
 
17
                      default="localhost",
-
 
18
                      type="string", help="The HOST where the mongo server is running",
-
 
19
                      metavar="mongo_host")
-
 
20
 
-
 
21
(options, args) = parser.parse_args()
10
DataService.initialize(db_hostname='localhost')
22
DataService.initialize(db_hostname=options.hostname)
11
 
23
 
12
con = None
24
con = None
13
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
25
SOURCE_MAP = {'AMAZON':1,'FLIPKART':2,'SNAPDEAL':3,'SAHOLIC':4}
14
DISCOUNT_TYPE = {'MRP':1,'DP':2}
26
DISCOUNT_TYPE = {'MRP':1,'DP':2}
15
LATEST_UPDATED_ITEMS = []
27
LATEST_UPDATED_ITEMS = []
Line 41... Line 53...
41
        self.in_stock = in_stock
53
        self.in_stock = in_stock
42
        self.maxprice = maxprice
54
        self.maxprice = maxprice
43
        self.brand = brand
55
        self.brand = brand
44
 
56
 
45
 
57
 
46
def get_mongo_connection(host='localhost', port=27017):
58
def get_mongo_connection(host=options.mongoHost, port=27017):
47
    global con
59
    global con
48
    if con is None:
60
    if con is None:
49
        print "Establishing connection %s host and port %d" %(host,port)
61
        print "Establishing connection %s host and port %d" %(host,port)
50
        try:
62
        try:
51
            con = pymongo.MongoClient(host, port)
63
            con = pymongo.MongoClient(host, port)