Subversion Repositories SmartDukaan

Rev

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

Rev 19092 Rev 19247
Line 44... Line 44...
44
BASE = len(ALPHABET)
44
BASE = len(ALPHABET)
45
SIGN_CHARACTER = '$'
45
SIGN_CHARACTER = '$'
46
 
46
 
47
con=None
47
con=None
48
conDtrData = None
48
conDtrData = None
-
 
49
conCms = None
49
headers = { 
50
headers = { 
50
            'User-agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
51
            'User-agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
51
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
52
            'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',      
52
            'Accept-Language' : 'en-US,en;q=0.8',                     
53
            'Accept-Language' : 'en-US,en;q=0.8',                     
53
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
54
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
Line 85... Line 86...
85
CREDIT_TYPE_APP = "App"
86
CREDIT_TYPE_APP = "App"
86
SUB_CATEGORY_MAP = {7:'Memory Card',8:'Cable',9:'USB Lights',10:"Screen Magnifier",11:"Car Charger",12:"Power Bank",13:"Pendrive",14:"Combo",15:"Charger",16:"Bluetooth Headset",17:"Speaker", \
87
SUB_CATEGORY_MAP = {7:'Memory Card',8:'Cable',9:'USB Lights',10:"Screen Magnifier",11:"Car Charger",12:"Power Bank",13:"Pendrive",14:"Combo",15:"Charger",16:"Bluetooth Headset",17:"Speaker", \
87
                    18:"Adapter",19:"Cases",20:"Screen Guard",21:"Earphone",22:"Card Reader",23:"Mobile Holder",24:"AUX Cable",25:"OTG Cable",26:"Selfie Stick",27:"Back Cover",28:"Tempered Glass",29:"Battery", \
88
                    18:"Adapter",19:"Cases",20:"Screen Guard",21:"Earphone",22:"Card Reader",23:"Mobile Holder",24:"AUX Cable",25:"OTG Cable",26:"Selfie Stick",27:"Back Cover",28:"Tempered Glass",29:"Battery", \
88
                    30:"Usb Hub",31:"Portable Music Player",32:"Smart Watch",33:'Flip Cover'}
89
                    30:"Usb Hub",31:"Portable Music Player",32:"Smart Watch",33:'Flip Cover'}
89
 
90
 
-
 
91
CATEGORY_MAP = {3:'Mobiles',5:'Tablets',6:'Accessories'}
-
 
92
 
90
def get_mongo_connection(host='localhost', port=27017):
93
def get_mongo_connection(host='localhost', port=27017):
91
    global con
94
    global con
92
    if con is None:
95
    if con is None:
93
        print "Establishing connection %s host and port %d" %(host,port)
96
        print "Establishing connection %s host and port %d" %(host,port)
94
        try:
97
        try:
Line 107... Line 110...
107
        except Exception, e:
110
        except Exception, e:
108
            print e
111
            print e
109
            return None
112
            return None
110
    return conDtrData
113
    return conDtrData
111
 
114
 
-
 
115
def get_mongo_connection_cms(host, port=27017):
-
 
116
    global conCms
-
 
117
    if conCms is None:
-
 
118
        print "Establishing connection %s host and port %d" %(host,port)
-
 
119
        try:
-
 
120
            conCms = pymongo.MongoClient(host, port)
-
 
121
        except Exception, e:
-
 
122
            print e
-
 
123
            return None
-
 
124
    return conCms
-
 
125
 
112
def to_java_date(py_timestamp):
126
def to_java_date(py_timestamp):
113
    try:
127
    try:
114
        java_date =  int(time.mktime(py_timestamp.timetuple())) * 1000 + py_timestamp.microsecond / 1000
128
        java_date =  int(time.mktime(py_timestamp.timetuple())) * 1000 + py_timestamp.microsecond / 1000
115
        return java_date
129
        return java_date
116
    except:
130
    except: