Subversion Repositories SmartDukaan

Rev

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

Rev 15166 Rev 15182
Line 16... Line 16...
16
            'Accept-Language' : 'en-US,en;q=0.8',                     
16
            'Accept-Language' : 'en-US,en;q=0.8',                     
17
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
17
            'Accept-Charset' : 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
18
            'Connection':'keep-alive',
18
            'Connection':'keep-alive',
19
            'Accept-Encoding' : 'gzip,deflate,sdch'
19
            'Accept-Encoding' : 'gzip,deflate,sdch'
20
        }
20
        }
21
PROXY_URL = "http://192.161.160.203:8800/"
21
PROXY_URL = "http://173.234.194.37:8800/"
22
PROXY_LIST = ['192.161.160.203:8800','173.234.194.214:8800', \
22
PROXY_LIST = ['192.161.160.203:8800','173.234.194.214:8800', \
23
              '192.161.160.13:8800','173.208.39.246:8800','192.161.160.212:8800', \
23
              '192.161.160.13:8800','173.208.39.246:8800','192.161.160.212:8800', \
24
              '173.234.194.37:8800','173.208.39.67:8800','192.161.163.249:8800', \
24
              '173.208.39.67:8800','192.161.163.249:8800', \
25
              '192.161.163.60:8800']
25
              '192.161.163.60:8800']
26
 
26
 
27
PUSH_NOTIFICATION_URL='http://api.profittill.com/admin/users/push'
27
PUSH_NOTIFICATION_URL='http://api.profittill.com/admin/users/push'
28
DTR_API_BASIC_AUTH = base64.encodestring('%s:%s' % ("dtr", "dtr18Feb2015")).replace('\n', '')
28
DTR_API_BASIC_AUTH = base64.encodestring('%s:%s' % ("dtr", "dtr18Feb2015")).replace('\n', '')
29
 
29
 
Line 136... Line 136...
136
def toTimeStamp(dateTimeObj):
136
def toTimeStamp(dateTimeObj):
137
    return int(time.mktime(dateTimeObj.timetuple()))
137
    return int(time.mktime(dateTimeObj.timetuple()))
138
def fromTimeStamp(timestamp):
138
def fromTimeStamp(timestamp):
139
    return datetime.fromtimestamp(timestamp)
139
    return datetime.fromtimestamp(timestamp)
140
 
140
 
-
 
141
def getNlcPoints(item, minNlc, maxNlc, available_price):
-
 
142
    if not(minNlc and maxNlc):
-
 
143
        raise
-
 
144
    if item.get('status') == 2:
-
 
145
        eolWeight = .60
-
 
146
    else:
-
 
147
        eolWeight = 1.0
-
 
148
    if item.get('category_id') == 3:
-
 
149
        basePointPercentage = 5.0
-
 
150
        maxNlcPoints = 200
-
 
151
    elif item.get('category_id') == 5:
-
 
152
        basePointPercentage = 8.0
-
 
153
        maxNlcPoints = 150
-
 
154
    else:
-
 
155
        basePointPercentage = 10.0
-
 
156
        maxNlcPoints = 150
-
 
157
    discFromMinNlc = float((minNlc - (available_price)))/(available_price) *100
-
 
158
    discFromMaxNlc = float((maxNlc - (available_price)))/(available_price) *100
-
 
159
    print discFromMinNlc
-
 
160
    print discFromMaxNlc
-
 
161
    if discFromMinNlc > 0:
-
 
162
        nlcPoints = 100/basePointPercentage * discFromMinNlc
-
 
163
    elif discFromMinNlc < 0 and discFromMaxNlc > 0:
-
 
164
        nlcPoints = 0
-
 
165
    else:
-
 
166
        nlcPoints = 100/basePointPercentage * discFromMinNlc
-
 
167
    if (min(nlcPoints,maxNlcPoints)) > 0:
-
 
168
        nlcPoints = (min(nlcPoints,maxNlcPoints)) * eolWeight
-
 
169
    else:
-
 
170
        nlcPoints = (min(nlcPoints,maxNlcPoints))
-
 
171
 
-
 
172
    return nlcPoints
-
 
173
    return datetime.fromtimestamp(timestamp)
-
 
174
 
141
def getLogger(filePath):
175
def getLogger(filePath):
142
    lgr = logging.getLogger()
176
    lgr = logging.getLogger()
143
    lgr.setLevel(logging.DEBUG)
177
    lgr.setLevel(logging.DEBUG)
144
    fh = logging.FileHandler(filePath)
178
    fh = logging.FileHandler(filePath)
145
    fh.setLevel(logging.INFO)
179
    fh.setLevel(logging.INFO)