Subversion Repositories SmartDukaan

Rev

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

Rev 19132 Rev 19259
Line 32... Line 32...
32
    timeCondition = datetime.now()-timedelta(hours=2)
32
    timeCondition = datetime.now()-timedelta(hours=2)
33
    eligibleSmsNotficationCampaigns = list(get_mongo_connection(host=mongoHost).User.notificationcampaigns.find({'smsprocessed':1,'created':{'$lte':to_java_date(timeCondition)}}))
33
    eligibleSmsNotficationCampaigns = list(get_mongo_connection(host=mongoHost).User.notificationcampaigns.find({'smsprocessed':1,'created':{'$lte':to_java_date(timeCondition)}}))
34
    for notificationCampaign in eligibleSmsNotficationCampaigns:
34
    for notificationCampaign in eligibleSmsNotficationCampaigns:
35
        logging.debug('Notification_Campign_Id:- '+str(notificationCampaign.get('_id')))
35
        logging.debug('Notification_Campign_Id:- '+str(notificationCampaign.get('_id')))
36
        
36
        
37
        jsonSentList = list(get_mongo_connection(host=mongoHost).User.pushnotificationsnew.find({'notification_campaign_id':str(notificationCampaign.get('_id')),'smstype':'SMS_SENT_OPERATOR'}))
37
        jsonSentList = list(get_mongo_connection(host=mongoHost).User.pushnotificationsnew.find({'notification_campaign_id':notificationCampaign.get('_id'),'smstype':'SMS_SENT_OPERATOR'}))
38
        
38
        
39
        for smsResponse in jsonSentList:
39
        for smsResponse in jsonSentList:
40
            del_det_params = {'user' : 'srlsaholicP', 'password' : 'srp8oct' , 'apimsgid' : smsResponse.get('sms_id')}
40
            del_det_params = {'user' : 'srlsaholicP', 'password' : 'srp8oct' , 'apimsgid' : smsResponse.get('sms_id')}
41
            encoded_del_det_params = urllib.urlencode(del_det_params)
41
            encoded_del_det_params = urllib.urlencode(del_det_params)
42
            del_det_url = 'http://103.15.179.45:8085/MessagingGateway/http/querymsg?' + encoded_del_det_params
42
            del_det_url = 'http://103.15.179.45:8085/MessagingGateway/http/querymsg?' + encoded_del_det_params
Line 59... Line 59...
59
                    elif 'EXP_' in status:
59
                    elif 'EXP_' in status:
60
                        status = 'SMS_EXPIRED'
60
                        status = 'SMS_EXPIRED'
61
                    else:
61
                    else:
62
                        status = 'SMS_'+status
62
                        status = 'SMS_'+status
63
                
63
                
64
                get_mongo_connection(host=mongoHost).User.pushnotificationsnew.update({'_id':smsResponse.get('_id')},{"$set":{'smstype':status,'sms_timestamp':to_java_date(datetime.now())}})
64
                get_mongo_connection(host=mongoHost).User.pushnotificationsnew.update({'_id':smsResponse.get('_id')},{"$set":{'sms_type':status,'sms_timestamp':to_java_date(datetime.now())}})
65
                
65
                
66
            except Exception as e:
66
            except Exception as e:
67
                logging.debug('Error while getting response for message id:- '+ str(smsResponse.get("sms_id")))
67
                logging.debug('Error while getting response for message id:- '+ str(smsResponse.get("sms_id")))
68
                traceback.print_exc()
68
                traceback.print_exc()
69
                continue
69
                continue
70
        
70
        
71
        jsonSentList = list(get_mongo_connection(host=mongoHost).User.pushnotificationsnew.find({'notification_campaign_id':str(notificationCampaign.get('_id')),'smstype':'SMS_INPROCESS'}))
71
        jsonSentList = list(get_mongo_connection(host=mongoHost).User.pushnotificationsnew.find({'notification_campaign_id':notificationCampaign.get('_id'),'smstype':'SMS_INPROCESS'}))
72
        
72
        
73
        for smsResponse in jsonSentList:
73
        for smsResponse in jsonSentList:
74
            del_det_params = {'uname' : 'srlsaholic', 'passwd' : 'sr18mar' , 'messageid' : str(smsResponse.get('sms_id'))}
74
            del_det_params = {'uname' : 'srlsaholic', 'passwd' : 'sr18mar' , 'messageid' : str(smsResponse.get('sms_id'))}
75
            encoded_del_det_params = urllib.urlencode(del_det_params)
75
            encoded_del_det_params = urllib.urlencode(del_det_params)
76
            del_det_url = 'http://103.15.179.45:8085/SMSGateway/getApiReport?' + encoded_del_det_params
76
            del_det_url = 'http://103.15.179.45:8085/SMSGateway/getApiReport?' + encoded_del_det_params
Line 90... Line 90...
90
                elif "Submitted to SMSC" in del_response_str:
90
                elif "Submitted to SMSC" in del_response_str:
91
                    status = 'SMS_INPROCESS'
91
                    status = 'SMS_INPROCESS'
92
                else:
92
                else:
93
                    status = 'SMS_FAILED'
93
                    status = 'SMS_FAILED'
94
                
94
                
95
                get_mongo_connection(host=mongoHost).User.pushnotificationsnew.update({'_id':smsResponse.get('_id')},{"$set":{'smstype':status,'sms_timestamp':to_java_date(datetime.now())}})
95
                get_mongo_connection(host=mongoHost).User.pushnotificationsnew.update({'_id':smsResponse.get('_id')},{"$set":{'sms_type':status,'sms_timestamp':to_java_date(datetime.now())}})
96
                
96
                
97
            except Exception as e:
97
            except Exception as e:
98
                logging.debug('Error while getting response for message id:- '+ str(smsResponse.get("sms_id")))
98
                logging.debug('Error while getting response for message id:- '+ str(smsResponse.get("sms_id")))
99
                traceback.print_exc()
99
                traceback.print_exc()
100
                continue          
100
                continue