def main(): csv.dowload_csv() list_of_localities = pd.get_locality_list_from_db() list_of_email_recipients = pd.get_recipient_list_from_db() pd.create_localities(list_of_localities) pd.read_data() for locality in pd.tracking_localities: html.create_html(locality,7) for recipient in list_of_email_recipients: locality_obj = pd.return_locality_obj(recipient.locality) es.send_mail(locality_obj, recipient.email) es.send_admin_email("*****@*****.**")
def main(req: func.HttpRequest) -> func.HttpResponse: name = req.params.get('name') email = req.params.get('email') password = req.params.get('password') if not name: try: req_body = req.get_json() except ValueError: pass else: name = req_body.get('name') if not email: try: req_body = req.get_json() except ValueError: pass else: email = req_body.get('email') if not password: try: req_body = req.get_json() except ValueError: pass else: password = req_body.get('password') if name and password and email: add_profile_query = "EXEC Profile_Add " + "@Full_Name='" + name + "'" + " , @Email='" + email + "'" + " , @Password='******';" response = query_handler.exec_query_with_message(add_profile_query) data = json.loads(response)[0] if "profile_id" in data: profile_id = data['profile_id'] # sms_client = SMS_Client() # sms_client.send_verification_message(profile_id) to_email, message = email_sender.generate_verification_message( profile_id) email_sender.send_mail(to_email, message) return func.HttpResponse(json.dumps(data), mimetype="application/json") else: return func.HttpResponse( "There is a missing parameter in your request", status_code=200)
def main(req: func.HttpRequest) -> func.HttpResponse: email = req.params.get('email') password = req.params.get('password') if not email: try: req_body = req.get_json() except ValueError: pass else: email = req_body.get('email') if not password: try: req_body = req.get_json() except ValueError: pass else: password = req_body.get('password') response = {'message': "There is a missing parameter in your request"} if password and email: profile_authentication_query = "EXEC validate_profile @Email='" + email + "'" + " , @Password='******';" response = query_handler.exec_query_with_message( profile_authentication_query) data = json.loads(response)[0] if not data["valid"]: return func.HttpResponse(json.dumps({'valid': False}), mimetype="application/json") if "profile_id" in data: profile_id = data['profile_id'] response = {'message': "Please verify your account"} if profile_is_verified(profile_id): to_email, message = email_sender.generate_auth_message( profile_id) email_sender.send_mail(to_email, message) response = data return func.HttpResponse(json.dumps(response), mimetype="application/json")
def send_email(config_file='parameters.config'): with open(config_file) as data_file: parameters = json.load(data_file) urls = start_ngrok(parameters['PATH'], parameters['auth-token'], parameters['connection_type'], parameters['port']) subject = "NGROK started at " + parameters['machine'] #time = strftime("%d/%m/%Y at %H:%M:%S", gmtime()) time = formatdate(localtime=True) msg = parameters[ 'user'] + ",\nThe ngrok process were set in " + parameters[ 'machine'] + " at " + time msg += "\nThe available URLs are above:\n" for url in urls: url = url['public_url'] msg += url + "\n" msg += "Current port: " + parameters['port'] print(msg) print(subject) email_sender.send_mail(parameters['email-from'], parameters['email-to'], subject, msg, parameters['password'])
def enter_to_db(email, password, age): try: conn = sqlite3.connect('usersdb.db') cur = conn.cursor() name_u = email.split('@')[0] cur.execute( '''INSERT INTO User (email, password, age, profile, name) VALUES (?, ?, ?, ?, ?)''', (email, password, age, send_base64(), name_u)) conn.commit() conn.close() msg = ''' Hey Buddy.. Thanks For registering... From now you are die hard fan of Pranava Adiga.. you can post now in our website. Try it now.''' email_sender.send_mail(email, msg, subject="Successfully Registered") return (True, "Registered Successfully") except: return (False, "Can't Registered due to some internal issue")
def main(): logger.info("job started") with open('filters.json') as f: filters = json.load(f) f.close() for filter_val in filters: location_val = filter_val["location_val"] distance_val = filter_val["distance_val"] postal_val = filter_val["postal_val"] auto_make_model_val = filter_val["auto_make_model_val"] min_auto_year_val = filter_val["min_auto_year_val"] max_auto_year_val = filter_val["max_auto_year_val"] max_auto_miles_val = filter_val["max_auto_miles_val"] auto_title_status_val = filter_val["auto_title_status_val"] c_scraper = scraper.CraiglistScraper( location=location_val, distance=distance_val, postal=postal_val, auto_make_model=auto_make_model_val, min_auto_year=min_auto_year_val, max_auto_year=max_auto_year_val, max_auto_miles=max_auto_miles_val, auto_title_status=auto_title_status_val) data = c_scraper.extract_post_data() sms = slack_msg_sender.SlackMsgSender(channel=auto_make_model_val) for post in data: sms.send_slack_msg(msg_text=post["post_title"]) send_mail(email_subject=post["post_title"], body_text=post["post_url"]) # wait 1 second before sending out emails and slack msgs time.sleep(1) # wait 5 seconds before starting next filter set time.sleep(5)
client_email: {cl_email} web_link: {link} Body:{body} Greetings, {cond_1} My name is Karim and I am looking forward to fostering a long-term relationship with you or become your go-to service provider for any related future inquiries. {formatted_pay} {formatted_tutoring} {formatted_sample} {formatted_pay_method} {formatted_contract_type} If interested or have any further questions, feel free to reach me at your earliest convenience and by your preferred mean of communication. Sincerely, Karim [email protected] (408) 393-4260 """ send_mail(formatted_subject, generated_email, "*****@*****.**", "CastirlaCorte56", "*****@*****.**") print(generated_email) else: print("NO NEW INFORMATION WAS EXTRACTED")
# Visualization of the results of a detection. vis_util.visualize_boxes_and_labels_on_image_array( image_np, np.squeeze(boxes), np.squeeze(classes).astype(np.int32), np.squeeze(scores), category_index, use_normalized_coordinates=True, line_thickness=8) if ix % 5 == 0: if np.squeeze(classes)[0] == 1: with open('sending_details.txt') as file: content = file.readlines() content = [x.strip() for x in content] sent_from = content[0] password = content[1] send_to = content[2:] cv2.imwrite('images\log.png', image_np) send_mail(sent_from, password, send_to, 'Caught', 'Caught', files=['images\log.png']) ix += 1 cv2.imshow('object detection', cv2.resize(image_np, (800, 600))) if cv2.waitKey(25) & 0xFF == ord('q'): cv2.destroyAllWindows() break
elif 'learn graphical user interface' in query: a.speak( "Opening Code With Harry's Python GUI with Tkinter playlist..." ) access_web( "https://www.youtube.com/playlist?list=PLu0W_9lII9ajLcqRcj4PoEihkukF_OTzA" ) elif 'send email' in query: a.speak("Alright to whom? Type the email address") to = input("Email address: ") a.speak("What's the subject of the mail?") subject = command() a.speak("a.speak the body of the mail?") body = command() send_mail(to, subject, body) elif 'joke' in query: a.speak("Fetching one...") r = requests.get( "https://sv443.net/jokeapi/v2/joke/Programming,Miscellaneous,Pun?blacklistFlags=nsfw,religious,political,racist,sexist" ).text parse = json.loads(r) if parse['type'] == 'single': a.speak(f"{parse['joke']}") else: a.speak(f"{parse['setup']}") a.speak(f"{parse['delivery']}") elif 'start a timer' in query or 'set a timer' in query: if timer_counter % 2 == 0:
try: file_name = f"sent_Nfile{Nfile_index+1}.csv" try: Nfiles_sent = pd.read_csv(file_name) except: Nfiles_sent = pd.DataFrame(columns=["text&link"]) Nfiles_sent.to_csv(file_name, index=False) for text, link in zip(Nfile_df["field1_Text_Text"], Nfile_df["field1_Link_Link"]): if text + link in Nfiles_sent.values: print("Breaking because already sent") continue else: Nfiles_sent = pd.DataFrame(Nfiles_sent['text&link'].append( pd.Series(text + link), ignore_index=True), columns=["text&link"]) Nfiles_sent.to_csv(file_name, index=False) body = """Title: {}\nLink: {}""".format(text, link) for receiver in receivers: send_mail("Iron glove and fletcher", body, sender_email, password, receiver) except: print(f"couldn't send Nfile{Nfile_index+1}") raise
def distribute_actions(jo): """ this is the 'entry' function that then distributes work to the subsequent functions """ # check if valid session # check login log.log_info("in distribute_actions") rj = {} result = "" action = jo["action"] log.log_info("action is: " + str(action)) if action == "addOneWord": session = jo["session"] elif action == "addText": # todo: is this anywhere used ??? text = jo["text"] language = jo["language"] # the input language elif action == "adVocFromUrl": log.log_info("in distribute_actions adVocFromUrl") session = jo["session"] user_id = dbs.get_user_id_from_session(session) time_stamp = int(time.time()) dbac.add_one_word_txt(user_id, jo["language"], jo["word"], jo["translationLanguage"], jo["translationWord"], True, "", "", time_stamp) dbac.add_one_word_txt(user_id, jo["translationLanguage"], jo["translationWord"], jo["language"], jo["word"], False, "", "", time_stamp) # now test if it arrived log.log_info("in distribute_actions preparing response") rj['action'] = "adVocFromUrl" rj['result'] = "successfully inserted " result = json.dumps(rj) elif action == "loadWord": # ATTENTION !!! this is probably not used anymore !!! log.log_logic(" ") log.log_logic(" ") log.log_logic(" ") log.log_logic( "===============================================================================" ) log.log_logic( "=========================== ROUTE loadWord ====================================" ) log.log_logic( "===============================================================================" ) log.log_info("loading new word") log.log_info(jo) wordId = jo["wordId"] answer = jo["answer"] session = jo["session"] log.log_info("answer was " + answer) log.log_info("wordId was " + str(wordId)) log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) log.log_info("user_id is " + str(user_id)) success, experiment, once_learned = dbl.process_answer( str(wordId), user_id, answer) log.log_info("process_answer done -------------------------------") new_id = dbl.get_next_word_id(user_id, str(wordId)) log.log_info("get_next_word_id done") id, l1, w1, l2, w2 = dbl.get_word(new_id) #get a random word from the words already learned learned_id = dbl.get_learned_random(user_id) rnd_id, rnd_l1, rnd_w1, rnd_l2, rnd_w2 = dbl.get_word(learned_id) rj['action'] = action rj["wordId"] = id rj["language1"] = dbac.get_language_label(l1) rj["word1"] = w1 rj["language2"] = dbac.get_language_label(l2) rj["word2"] = w2 rj['error'] = False rj['error_description'] = "" rj['success'] = success rj['experiment'] = experiment rj['once_learned'] = once_learned rj["rnd_wordId"] = rnd_id rj["rnd_language1"] = dbac.get_language_label(rnd_l1) rj["rnd_word1"] = rnd_w1 rj["rnd_language2"] = dbac.get_language_label(rnd_l2) rj["rnd_word2"] = rnd_w2 rj["rnd_frequency"] = 15 #todo: convert to algorithm depending on % learned and size of vocabulary result = json.dumps(rj) log.log_info("distribute_actions(jo) result for new word " + result) elif action == "loadWordArray": log.log_logic(" ") log.log_logic(" ") log.log_logic(" ") log.log_logic( "===============================================================================" ) log.log_logic( "=========================== ROUTE loadWordArray ====================================" ) log.log_logic( "===============================================================================" ) log.log_info("loading new word array") log.log_info(jo) wordId = jo["wordId"] answer = jo["answer"] session = jo["session"] log.log_info("answer was " + answer) log.log_info("wordId was " + str(wordId)) log.log_info("session was " + str(session)) if len(str(wordId).strip()) > 0: xxxx, yyyy, w1, zzzz, w2 = dbl.get_word(wordId) log.log_logic("answer was " + answer) log.log_logic("wordId was " + str(wordId)) log.log_logic("w1 was " + str(w1)) log.log_logic("w2 was " + str(w2)) user_id = dbs.get_user_id_from_session(session) log.log_info("user_id is " + str(user_id)) # January 2019 we change this logic now using a ordered list avoiding random #success, experiment, once_learned = dbl.process_answer(str(wordId), user_id, answer) success, experiment, once_learned = dbl.process_answer_with_sorted_array( str(wordId), user_id, answer) log.log_logic("was experiment? " + str(experiment)) log.log_logic("was success? " + str(success)) log.log_logic("once learned? " + str(once_learned)) log.log_logic( "***** processing uf user answer done, now prepare response *****" ) # January 2019 trying out a new algorithm using a logic that does not use random, but ordered by logic #new_id_array = dbl.get_next_word_id_array(user_id, str(wordId)) new_id_array = dbl.get_next_word_id_array_ordered_position( user_id, str(wordId)) word_arr = [] # ToDo: this is here very inefficient code that creates a lot of traffic on database. Integrate in previous function call for new_id in new_id_array: row_j = {} id, l1, w1, l2, w2 = dbl.get_word(new_id[0]) row_j["wordId"] = id row_j["language1"] = dbac.get_language_label(l1) row_j["word1"] = w1 row_j["language2"] = dbac.get_language_label(l2) row_j["word2"] = w2 row_j["position"] = new_id[1] log_str = str(row_j["wordId"]) + ", " log_str += str(row_j["position"]) + ", " log_str += str(row_j["word1"]) + ", " log_str += str(row_j["word2"]) + ", " log.log_logic(log_str) word_arr.append(row_j) rj['action'] = action rj['error'] = False rj['error_description'] = "" rj['success'] = success rj['bucket-sizes'] = 3 rj['bucket-distribution'] = [0.6, 0.9] rj['experiment'] = experiment rj['once_learned'] = once_learned rj["words"] = word_arr log.log_logic("sending to client success = " + str(success)) log.log_logic("sending to client experiment = " + str(experiment)) # get a random word from the words already learned # this is to repeat words and to create a better training set learned_id = dbl.get_learned_random(user_id) rnd_id, rnd_l1, rnd_w1, rnd_l2, rnd_w2 = dbl.get_word(learned_id) rj["rnd_wordId"] = rnd_id rj["rnd_language1"] = dbac.get_language_label(rnd_l1) rj["rnd_word1"] = rnd_w1 rj["rnd_language2"] = dbac.get_language_label(rnd_l2) rj["rnd_word2"] = rnd_w2 rj["rnd_frequency"] = 10 #todo: convert to algorithm depending on % learned and size of vocabulary log.log_logic("sending to client extra random word: " + rnd_w1 + " == " + rnd_w2) result = json.dumps(rj) log.log_info("distribute_actions(jo) result for new word " + result) elif action == "editWord": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) fromWord = jo["fromWord"] toWord = jo["toWord"] word_id = jo["wordId"] dbc.update_word_by_id(user_id, fromWord, toWord, word_id) log.log_info("update word done") rj['action'] = action rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "report": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) new_words, learned_words, ratio_learned = dbr.get_simple_report( user_id) c1, c2, c3, c4 = dbr.get_report_charts(user_id) log.log_info("c1 = " + str(c1)) log.log_info("c2 = " + str(c2)) log.log_info("c3 = " + str(c3)) log.log_info("c4 = " + str(c4)) log.log_info("done getting data for charts") rj['action'] = action rj['newWords'] = new_words rj['learnedWords'] = learned_words rj['ratioLearned'] = ratio_learned rj['c1'] = c1 rj['c2'] = c2 rj['c3'] = c3 rj['c4'] = c4 rj['html'] = "" rj['error'] = False rj['error_description'] = "" log.log_info("converting to json") try: result = json.dumps(rj) except Exception as ex: log.log_error("error in making report: " + str(ex)) rj = {} rj['action'] = action rj['error'] = True rj['error_description'] = "error in making report: " + str(ex) result = json.dumps(rj) log.log_info("distribute_actions(jo) result for report = " + result) elif action == "readerSaveText": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) # user_id, language, url, text rj['text_id'], err = db_reader.save_text(user_id, jo["language"], jo["url"], jo["text"]) rj['action'] = action if len(err) > 0: rj['error'] = True rj['error_description'] = err else: rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "readerLoadTextTitles": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) rj['titles'] = db_reader.get_text_titles(user_id) rj['action'] = action rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "readerLoadOneText": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) rj['text'], rj['text_id'] = db_reader.get_one_text(jo["id"], user_id) rj['action'] = action rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "readerSetTextRead": session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) db_reader.set_text_read(jo["id"], user_id) rj['action'] = action rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "logIn": # login and create session user = jo["user"].strip() password = jo["password"].strip() rj['action'] = "logIn" password = password.strip() password = password.replace(" ", "") user = user.lower() user = user.strip() user = user.replace(" ", "") if dbs.check_login(user, password) > 0: rj['success'] = True rj['result'] = "success" rj['session'] = dbs.make_save_session(user) # we need to register the session in the MASTER's database register_user_and_session_at_master(rj['session'], user) else: rj['success'] = False rj['result'] = "failure" rj['session'] = "" log.log_info("result - " + str(rj)) result = json.dumps(rj) elif action == "logout": # ToDo # logfiles out by destroying session and or cookie? session = jo["session"] elif action == "checkSession": # check if session is valid session = jo["session"] rj['action'] = "checkSession" if dbs.check_session(session) > 0: log.log_info("valid session " + session) rj['sessionValid'] = True else: log.log_info("invalid session " + session) rj['sessionValid'] = False result = json.dumps(rj) elif action == "getLanguages": rj['action'] = action rj['labels'] = [ "English", "German", "Russian", "Franch", "Italian", "Spanish", "Portuguese" ] rj['values'] = [ "english", "german", "russian", "franch", "italian", "spanish", "portuguese" ] rj['error'] = False rj['error_description'] = "" result = json.dumps(rj) elif action == "resetPassword": rj['action'] = action # ToDo # reset password and send new password to user by email user = jo["user"] user = user.lower() user = user.strip() user = user.replace(" ", "") if dbs.check_user(user) > 0: p = dbs.random_string_simple(6) dbs.update_password(user, p) # ToDo: put in a separate thread to prevent slow down of process # ToDo: make nice test in mail email_sender.send_mail(user, "resetPassword", "Password: "******"success" rj['success'] = True log.log_info("success in resetting password for " + user) else: rj['result'] = "failure" rj['success'] = False log.log_info( "failure in resetting password because user not existing " + user) result = json.dumps(rj) elif action == "registerUser": rj['action'] = action # ToDo # reset password and send new password to user by email user = jo["user"] user = user.lower() user = user.strip() user = user.replace(" ", "") if dbs.check_user(user) < 1: p = dbs.random_string_simple(4) dbs.register_user(user, p) # ToDo: put in a separate thread to prevent slow down of process # ToDo: make nice test in mail email_sender.send_mail(user, "registerUser", "password: "******"", user) log.log_info("registering user " + user) rj['result'] = "success" rj['success'] = True else: log.log_info("user already exists: " + user) rj['result'] = "failure" rj['success'] = False result = json.dumps(rj) elif action == "getSettings": session = jo["session"] rj['action'] = action rj['settings'] = settings.get_settings(session) rj['result'] = "success" rj['success'] = True result = json.dumps(rj) elif action == "setSettings": session = jo["session"] data = jo["settings"] settings.set_settings(session, data) rj['action'] = action rj['result'] = "success" rj['success'] = True result = json.dumps(rj) elif action == "bulkAddVoc": table_text = jo["text"] session = jo["session"] log.log_info("session was " + str(session)) user_id = dbs.get_user_id_from_session(session) dbac.add_words_bulk(user_id, table_text) rj['action'] = action rj['result'] = "success" rj['success'] = True result = json.dumps(rj) else: # then we have a problem because we do not know the request and we need to throw an error log.log_error("unknown method for processing JSON") xxx = 111 return result
def main(req: func.HttpRequest) -> func.HttpResponse: name = req.params.get('name') email = req.params.get('email') password = req.params.get('password') encrypted_vault = req.params.get('encrypted_vault') if not name: try: req_body = req.get_json() except ValueError: pass else: name = req_body.get('name') if not email: try: req_body = req.get_json() except ValueError: pass else: email = req_body.get('email') if not password: try: req_body = req.get_json() except ValueError: pass else: password = req_body.get('password') if not encrypted_vault: try: req_body = req.get_json() except ValueError: pass else: encrypted_vault = req_body.get('encrypted_vault') response = {"message":"There is a missing parameter in your request"} if name and password and email and encrypted_vault: add_profile_query = "EXEC Profile_Add "+"@Full_Name='"+name+"'"+" , @Email='"+email+"'"+" , @Password='******';" response = query_handler.exec_query_with_message(add_profile_query) data = json.loads(response)[0] response = data logging.info(response) # response = {'message': "error: try again later"} if "profile_id" in response: profile_id = response['profile_id'] create_vault_query = "EXEC Vault_create "+"@Profile_id ='"+str(profile_id)+"'"+" , @Encrypted_vault='"+encrypted_vault+"';" query_handler.exec_query_with_no_response(create_vault_query) # sms_client = SMS_Client() # sms_client.send_verification_message(profile_id) to_email , message = email_sender.generate_verification_message(profile_id) email_sender.send_mail( to_email , message) response = data return func.HttpResponse( json.dumps(response) , mimetype="application/json" )