Subversion Repositories SmartDukaan

Rev

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

Rev 16734 Rev 16735
Line 9... Line 9...
9
 
9
 
10
AFFILIATE_ID = 1
10
AFFILIATE_ID = 1
11
DEVICE_ID = "SpiceRetail"
11
DEVICE_ID = "SpiceRetail"
12
RETAILER_CODE = 123
12
RETAILER_CODE = 123
13
ACTIVE_OFFERS = []
13
ACTIVE_OFFERS = []
-
 
14
GOT_RESPONSE = False
14
 
15
 
15
DataService.initialize(db_hostname='localhost' )
16
DataService.initialize(db_hostname='localhost' )
16
 
17
 
17
def _sendAlertForNewApp(packageName, appName):
18
def _sendAlertForNewApp(packageName, appName):
18
    m = Email('localhost')
19
    m = Email('localhost')
Line 30... Line 31...
30
    m.send()
31
    m.send()
31
 
32
 
32
 
33
 
33
def dumpOffers():
34
def dumpOffers():
34
    global ACTIVE_OFFERS
35
    global ACTIVE_OFFERS
-
 
36
    global GOT_RESPONSE
35
    offer_url =  AFFILIATE_OFFER_API.get(AFFILIATE_ID)%(DEVICE_ID,RETAILER_CODE)
37
    offer_url =  AFFILIATE_OFFER_API.get(AFFILIATE_ID)%(DEVICE_ID,RETAILER_CODE)
36
    response = fetchResponseUsingProxy(offer_url, proxy=False)
38
    response = fetchResponseUsingProxy(offer_url, proxy=False)
37
    input_json = json.loads(response)
39
    input_json = json.loads(response)
38
    if input_json['status'].strip()=='ok' and input_json['message'] =="Success":
40
    if input_json['status'].strip()=='ok' and input_json['message'] =="Success":
-
 
41
        GOT_RESPONSE = True
39
        offers = (input_json['payload'])['offers']
42
        offers = (input_json['payload'])['offers']
40
        if offers is not None and len(offers) >0:
43
        if offers is not None and len(offers) >0:
41
            for offer in offers:
44
            for offer in offers:
42
                ACTIVE_OFFERS.append(str(offer['offerId']))
45
                ACTIVE_OFFERS.append(str(offer['offerId']))
43
            
46
            
Line 200... Line 203...
200
    
203
    
201
 
204
 
202
def main():
205
def main():
203
    try:
206
    try:
204
        dumpOffers()
207
        dumpOffers()
-
 
208
        print 'GOT_RESPONSE', GOT_RESPONSE
-
 
209
        if GOT_RESPONSE:
205
        markOfferAsInactive()
210
            markOfferAsInactive()
206
    finally:
211
    finally:
207
        session.close()
212
        session.close()
208
 
213
 
209
if __name__ == '__main__':
214
if __name__ == '__main__':
210
    main()
215
    main()
211
216