Subversion Repositories SmartDukaan

Rev

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

Rev 19256 Rev 19258
Line 96... Line 96...
96
                    traceback.print_exc()
96
                    traceback.print_exc()
97
                    continue
97
                    continue
98
                
98
                
99
                entry = smsToBeSentUsersMap.get(user.id)
99
                entry = smsToBeSentUsersMap.get(user.id)
100
                logging.debug('User Id:- '+str(user.id)+' Notification_Campaign_Id:- '+ str(notificationCampaign.get('_id'))+' Sent Response:- '+ str(response_str))
100
                logging.debug('User Id:- '+str(user.id)+' Notification_Campaign_Id:- '+ str(notificationCampaign.get('_id'))+' Sent Response:- '+ str(response_str))
101
                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':'smssent','sms_timestamp':to_java_date(datetime.now())}})
101
                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':'smssent','sms_timestamp':to_java_date(datetime.now())}})
102
                if "TRAN_SMS" in smstext:
102
                if "TRAN_SMS" in smstext:
103
                    if "Message sent successfully to " in response_str:
103
                    if "Message sent successfully to " in response_str:
104
                        response_str_vals = response_str.split('#')
104
                        response_str_vals = response_str.split('#')
105
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':'smsprocessed','sms_timestamp':to_java_date(datetime.now()),'sms_id':response_str_vals[0]}})
105
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':'smsprocessed','sms_timestamp':to_java_date(datetime.now()),'sms_id':response_str_vals[0]}})
106
                        tranSmsResponseIdMap[user.id] = response_str_vals[0]
106
                        tranSmsResponseIdMap[user.id] = response_str_vals[0]
107
                    else:
107
                    else:
108
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':'smsrejected','sms_timestamp':to_java_date(datetime.now())}})
108
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':'smsrejected','sms_timestamp':to_java_date(datetime.now())}})
109
                else:
109
                else:
110
                    if "mobile no in DND" in response_str:
110
                    if "mobile no in DND" in response_str:
111
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':'smsrejected','sms_timestamp':to_java_date(datetime.now())}})
111
                        get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':'smsrejected','sms_timestamp':to_java_date(datetime.now())}})
112
                    else:
112
                    else:
113
                        response_vals = response_str.split('\n')
113
                        response_vals = response_str.split('\n')
114
                        logging.debug('Desired Response String:- '+str(response_vals[2]))
114
                        logging.debug('Desired Response String:- '+str(response_vals[2]))
115
                        if len(response_vals)==4 and 'SMS Sent successfully to' in response_vals[2]:
115
                        if len(response_vals)==4 and 'SMS Sent successfully to' in response_vals[2]:
116
                            if response_vals[2].split('#')[0]!='null':
116
                            if response_vals[2].split('#')[0]!='null':
117
                                proSmsResponseIdMap[user.id] = response_vals[2].split('#')[0]
117
                                proSmsResponseIdMap[user.id] = response_vals[2].split('#')[0]
118
                                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':'smsprocessed','sms_timestamp':to_java_date(datetime.now()),'sms_id':response_vals[2].split('#')[0]}})
118
                                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':'smsprocessed','sms_timestamp':to_java_date(datetime.now()),'sms_id':response_vals[2].split('#')[0]}})
119
                
119
                
120
                sentSmsUsers.append(user.mobile_number)
120
                sentSmsUsers.append(user.mobile_number)
121
                
121
                
122
        time.sleep(30)
122
        time.sleep(30)
123
        
123
        
Line 143... Line 143...
143
                    elif 'EXP_' in status:
143
                    elif 'EXP_' in status:
144
                        status = 'SMS_EXPIRED'
144
                        status = 'SMS_EXPIRED'
145
                    else:
145
                    else:
146
                        status = 'SMS_'+status
146
                        status = 'SMS_'+status
147
                entry = smsToBeSentUsersMap.get(userId)
147
                entry = smsToBeSentUsersMap.get(userId)
148
                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':status,'sms_timestamp':to_java_date(datetime.now())}})          
148
                get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':status,'sms_timestamp':to_java_date(datetime.now())}})          
149
            except Exception as e:
149
            except Exception as e:
150
                logging.debug('Error while getting response for message id:- '+ msgId)
150
                logging.debug('Error while getting response for message id:- '+ msgId)
151
                traceback.print_exc()
151
                traceback.print_exc()
152
                continue
152
                continue
153
            
153
            
Line 180... Line 180...
180
                except Exception as e:
180
                except Exception as e:
181
                    logging.debug('Error while getting response for message id:- '+ msgId)
181
                    logging.debug('Error while getting response for message id:- '+ msgId)
182
                    traceback.print_exc()
182
                    traceback.print_exc()
183
                    continue
183
                    continue
184
                        
184
                        
185
            get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'smstype':status,'sms_timestamp':to_java_date(datetime.now())}})
185
            get_mongo_connection(host=mongoHost).User.pushnotifications.update({'_id':entry.get('_id')},{"$set":{'sms_type':status,'sms_timestamp':to_java_date(datetime.now())}})
186
        
186
        
187
        logging.debug('Total Sms Sent:- '+str(len(sentSmsUsers)))  
187
        logging.debug('Total Sms Sent:- '+str(len(sentSmsUsers)))  
188
    logging.debug('SMS Blaster Process Completed.....'+str(datetime.now()))  
188
    logging.debug('SMS Blaster Process Completed.....'+str(datetime.now()))  
189
    
189
    
190
    
190