def send_sms_to_contact_no(contact_no, full_msg): msg_chunks = break_msg_into_chunks(full_msg) for chunk_no, chunk in enumerate(msg_chunks): print '\tSending SMS Chunk Number: ' + str(chunk_no+1) + ' ...' is_sent_flag = False while is_sent_flag == False: try: if len(msg_chunks) == 1: send_sms(contact_no, chunk) else: send_sms(contact_no, append_footer_to_msg(chunk, chunk_no, len(msg_chunks))) is_sent_flag = True except SessionExpired: props = ConfigProps(PROPERTIES_FILE_NAME, expectedPropList) login_to_way2sms(props.get_way2sms_username(), props.get_way2sms_password())
def get_matched_contacts_from_user(to_match_name_or_no): props = ConfigProps(PROPERTIES_FILE_NAME, expectedPropList) matched_contacts = [] if is_ten_digit_number(to_match_name_or_no): cell_no = to_match_name_or_no print 'Number detected!' (first_name, last_name) = ask_and_add_to_contacts(cell_no, props.get_contacts_file()) matched_contacts.append(PhoneContact(first_name, last_name, cell_no)) else: name_to_be_matched = to_match_name_or_no contacts = get_contacts_list_from_csv(props.get_contacts_file()) matched_contacts = get_contacts_which_match(contacts, name_to_be_matched) if len(matched_contacts) == 0: print 'No matches of ' + name_to_be_matched + ' found in ' + props.get_contacts_file() to_send_contacts = get_user_confirmed_contacts(matched_contacts) return to_send_contacts
def add_some_more_to_send(to_send_contacts): new_to_send = [] for contact in to_send_contacts: new_to_send.append(contact) to_add_contact_name = raw_input('Enter the name of the contact or the cell no you want to add to the sender\'s list:') if len(to_add_contact_name) != 0: to_send_matched_contacts = get_matched_contacts_from_user(to_add_contact_name) for matched_contact in to_send_matched_contacts: new_to_send.append(matched_contact) else: print 'Empty string contact name search not allowed!!' return new_to_send if __name__ == '__main__': if len(sys.argv) == 2: props = ConfigProps(PROPERTIES_FILE_NAME, expectedPropList) argv1 = sys.argv[1] to_send_contacts = get_matched_contacts_from_user(argv1) if len(to_send_contacts) == 0: print 'No Contacts to send, Exiting.. ' sys.exit() login_to_way2sms(props.get_way2sms_username(), props.get_way2sms_password()) while 1: if len(to_send_contacts) == 0: print 'No Contacts to send, Exiting.. ' sys.exit() message = get_message_from_user(to_send_contacts) if message == None: if (ask_if_confirm_exit() == True): break else: