Merge branch 'master' of bitbucket.org:panleicim/appointment_tool

This commit is contained in:
2023-11-08 17:37:07 +01:00
17 changed files with 295 additions and 67 deletions
Regular → Executable
View File
+3 -3
View File
@@ -1,9 +1,9 @@
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.utils.excel_reader import ExcelHelper from src.utils.excel_reader import read_contacts
# 检查联系人表的有邮件有没有在数据库中
if __name__ == '__main__': if __name__ == '__main__':
excel_reader = ExcelHelper() contacts = read_contacts("/Users/panlei/Desktop/yahoo_aol_valid_16.xlsx")
contacts = excel_reader.read_contacts("/Users/lpan/Desktop/yahoo_aol.xlsx")
mail_list = MONGO_STORE_MANAGER.get_destination_emails() mail_list = MONGO_STORE_MANAGER.get_destination_emails()
print("mail_list size is " + str(len(mail_list))) print("mail_list size is " + str(len(mail_list)))
mail_raw_list =[] mail_raw_list =[]
+4 -9
View File
@@ -13,12 +13,6 @@ class MailAddressValidator():
self.login = login self.login = login
self.password = password self.password = password
@staticmethod
def show_folders(imap):
for i in imap.list()[1]:
l = i.decode().split(' "/" ')
print(l[0] + " = " + l[1])
def is_valid_email_address(self) -> bool: def is_valid_email_address(self) -> bool:
# authenticate # authenticate
imap = create_imap(self.login) imap = create_imap(self.login)
@@ -66,9 +60,10 @@ def find_and_update_invalid_emails(mail_list):
if __name__ == '__main__': if __name__ == '__main__':
# remove_invalid_email() remove_invalid_email()
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# excel_reader = ExcelHelper() # excel_reader = ExcelHelper()
# mail_list = excel_reader.read_mails_and_pwd(file_name="/Users/lpan/Downloads/hotmail_list.xlsx") # mail_list = excel_reader.read_mails_and_pwd(file_name="/Users/lpan/Downloads/hotmail_list.xlsx")
# print(email_list) # print(email_list)
find_and_update_invalid_emails(mail_list) # find_and_update_invalid_emails(mail_list)
Regular → Executable
+9 -4
View File
@@ -11,13 +11,14 @@ from src.db.mirgration.migration_tools import migre_accepted_appointment
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.mail.mail_constants import create_imap, show_folders from src.mail.mail_constants import create_imap, show_folders
from src.notification.AcceptedResultPojo import get_accepted_result_from from src.notification.AcceptedResultPojo import get_accepted_result_from
from src.notification.SignalSender import SignalSender
from src.notification.mailer import Mailer from src.notification.mailer import Mailer
from src.pojo.ResultEnum import ResultEnum from src.pojo.ResultEnum import ResultEnum
from src.pojo.mail.mail_pojo import MailPojo from src.pojo.mail.mail_pojo import MailPojo, MailAddress
from src.utils.excel_reader import ExcelHelper from src.utils.excel_reader import ExcelHelper
CONFIRMATION_SUBJECT_FR = 'Votre rendez-vous est' CONFIRMATION_SUBJECT_FR = 'rendez-vous est'
CONFIRMATION_SUBJECT_EN = 'appointment is confirmed' CONFIRMATION_SUBJECT_EN = 'confirmed'
HERMES_EMAIL = "no-reply@hermes.com" HERMES_EMAIL = "no-reply@hermes.com"
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014 date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
@@ -145,10 +146,13 @@ def clean(text):
def accept_appointment_found(accepted_result_list: list): def accept_appointment_found(accepted_result_list: list):
mailer = Mailer() mailer = Mailer()
sginal = SignalSender()
print(accepted_result_list) print(accepted_result_list)
for reserve in accepted_result_list: for reserve in accepted_result_list:
mailer.send_email(get_accepted_result_from(reserve, MONGO_STORE_MANAGER), to_all=True) result = get_accepted_result_from(reserve, MONGO_STORE_MANAGER)
mailer.send_email(result, to_all=False)
MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message) MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message)
sginal.send_result(result)
if len(accepted_result_list) > 0: if len(accepted_result_list) > 0:
migre_accepted_appointment(str(datetime.date.today())) migre_accepted_appointment(str(datetime.date.today()))
@@ -156,6 +160,7 @@ def accept_appointment_found(accepted_result_list: list):
def read_mails_and_find_confirmation_contacts(): def read_mails_and_find_confirmation_contacts():
mail_list = MONGO_STORE_MANAGER.get_destination_emails() mail_list = MONGO_STORE_MANAGER.get_destination_emails()
mail_list.reverse()
# excel_reader = ExcelHelper() # excel_reader = ExcelHelper()
# mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx") # mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx")
# mail_address3 = MailAddress(mail="taibenchragu1978@onet.pl", password="2J)kyfNgyOZ") # mail_address3 = MailAddress(mail="taibenchragu1978@onet.pl", password="2J)kyfNgyOZ")
+28 -1
View File
@@ -15,8 +15,18 @@ DOMAN_AURORA_DTI_NE_JP = "aurora.dti.ne.jp"
DOMAN_GMAIL = "gmail.com" DOMAN_GMAIL = "gmail.com"
DOMAIN_GMX = "gmx.com" DOMAIN_GMX = "gmx.com"
DOMAIN_GMX_FR = "gmx.fr" DOMAIN_GMX_FR = "gmx.fr"
DOMAIN_GMX_US = "gmx.us"
DOMAIN_ONET = "onet.pl" DOMAIN_ONET = "onet.pl"
DOMAIN_NAVER = "naver.com" DOMAIN_NAVER = "naver.com"
DOMAIN_INBOX_LV = "inbox.lv"
DOMAIN_PISS_MAIL = "pissmail.com"
DOMAIN_INCEL_EMAIL = "incel.email"
DOMAIN_SHITPOSTING_EXPERT = "shitposting.expert"
DOMAIN_HATESJE_WS = "hatesje.ws"
DOMAIN_CHILD_PIZZA = "child.pizza"
DOMAIN_GENOCIDE_FUN= "genocide.fun"
DOMAIN_DMC_CHAT= "dmc.chat"
AOL_IMAP_SERVER = "imap.aol.com" AOL_IMAP_SERVER = "imap.aol.com"
IMAP_SERVER_163 = "imap.163.com" IMAP_SERVER_163 = "imap.163.com"
@@ -32,13 +42,26 @@ BTVM_NE_JP = "imap.btvm.ne.jp"
SEREVER_GMAIL = "imap.gmail.com" SEREVER_GMAIL = "imap.gmail.com"
SERVER_IMAGE_ONET = "imap.poczta.onet.pl" SERVER_IMAGE_ONET = "imap.poczta.onet.pl"
SERVER_GMX = "imap.gmx.com" SERVER_GMX = "imap.gmx.com"
SERVER_PISS_MAIL = "mail.pissmail.com"
INBOX_LV = "mail.inbox.lv"
def show_folders(imap) -> list: def show_folders(imap) -> list:
folders = [] folders = []
isImapClient = isinstance(imap, IMAPClient)
if not isImapClient:
for i in imap.list()[1]: for i in imap.list()[1]:
l = i.decode().split(' "/" ') l = i.decode().split(' "/" ')
if len(l)>1:
folders.append(l[1]) folders.append(l[1])
if len(folders)==0:
folders.append('INBOX')
return folders
else:
list = imap.list_folders()
for i in list:
name = i[-1]
folders.append(name)
return folders return folders
@@ -48,7 +71,7 @@ def create_imap(login: str):
imap = IMAPClient(IMAP_SERVER_163, use_uid=True) imap = IMAPClient(IMAP_SERVER_163, use_uid=True)
elif DOMAIN_YAHOO in login: elif DOMAIN_YAHOO in login:
imap = imaplib.IMAP4_SSL(YAHOO_IMAP_SERVER) imap = imaplib.IMAP4_SSL(YAHOO_IMAP_SERVER)
elif DOMAIN_GMX in login or DOMAIN_GMX_FR in login: elif DOMAIN_GMX in login or DOMAIN_GMX_FR in login or DOMAIN_GMX_US in login:
imap = imaplib.IMAP4_SSL(SERVER_GMX) imap = imaplib.IMAP4_SSL(SERVER_GMX)
elif DOMAIN_SINA in login: elif DOMAIN_SINA in login:
# imap = imaplib.IMAP4_SSL(IMAP_SERVER_SINA) # imap = imaplib.IMAP4_SSL(IMAP_SERVER_SINA)
@@ -73,6 +96,10 @@ def create_imap(login: str):
imap = imaplib.IMAP4(MARS_DTI_NE_JP_SERVER, port=143) imap = imaplib.IMAP4(MARS_DTI_NE_JP_SERVER, port=143)
elif DOMAIN_NAVER in login: elif DOMAIN_NAVER in login:
imap = imaplib.IMAP4_SSL(NAVER_SERVER, port=993) imap = imaplib.IMAP4_SSL(NAVER_SERVER, port=993)
elif DOMAIN_INBOX_LV in login:
imap = imaplib.IMAP4_SSL(INBOX_LV, port=993)
elif DOMAIN_PISS_MAIL in login or DOMAIN_CHILD_PIZZA in login or DOMAIN_DMC_CHAT in login or DOMAIN_GENOCIDE_FUN in login or DOMAIN_HATESJE_WS in login or DOMAIN_INCEL_EMAIL in login or DOMAIN_SHITPOSTING_EXPERT in login:
imap = imaplib.IMAP4_SSL(SERVER_PISS_MAIL, port=993)
else: else:
imap = imaplib.IMAP4_SSL(AOL_IMAP_SERVER) imap = imaplib.IMAP4_SSL(AOL_IMAP_SERVER)
return imap return imap
Regular → Executable
+10 -27
View File
@@ -11,7 +11,7 @@ from imapclient import IMAPClient
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.logs.AppLogging import init_logger from src.logs.AppLogging import init_logger
from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap, show_folders
from src.pojo.mail.mail_pojo import MailPojo, MailAddress from src.pojo.mail.mail_pojo import MailPojo, MailAddress
from src.utils.excel_reader import ExcelHelper from src.utils.excel_reader import ExcelHelper
from src.utils.timeutiles import is_time_between from src.utils.timeutiles import is_time_between
@@ -24,7 +24,8 @@ HERMES_EMAIL = "no-reply@hermes.com"
EMAIL_ADDRESS_REGEX = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b' EMAIL_ADDRESS_REGEX = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b'
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014 date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
REDIRECTION_MAILS = "appointment2022@aol.com, chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,lacerdaraffaello@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,caiminwei123@gmail.com,yulingguo086@gmail.com,yingxiaolu086@gmail.com,lijiazhen0035@gmail.com,fangp370@gmail.com,huangyayu10086@gmail.com,fuziyuan110@gmail.com,xinyingdu886@gmail.com,yasiaforever.1971@aol.com,lukaszfidalgo@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com" REDIRECTION_MAILS = "chenpeijun@aol.com,hongjiang176@aol.com,ciyuexie@aol.com,rutger.62@aol.com,ciccidaniel@aol.com,armasgoodman@aol.com,wknd.gemerine@aol.com,rafmail1981@aol.com,tonovichivanenaki@aol.com,hetland.ari@aol.com,mateusiversen@aol.com,lacerdaraffaello@aol.com,anasida76@aol.com,liamolinari@aol.com,sen70zib@aol.com,mezeiderrick@aol.com,stanisl49avchic@aol.com,damcvrobaneuron@aol.com,suyzanna_fleona@aol.com,dxealing.dissa@aol.com,hogg.karen@aol.com,obocharovamarina@aol.com,buchholzjohann@aol.com,orn.cecchini@aol.com,percivaltorgersen@aol.com,candalgudrun@aol.com,filimonis.76@aol.com,bengann_100@aol.com,axelhanne@aol.com,tiffanylarochelle@aol.com,nicoleta.r@aol.com,eichenbaum.1963@aol.com,kotensasharev@aol.com,samognat32@aol.com,edem_headshot@aol.com,kozmakuzmich1960@aol.com,damonsvensson@aol.com,anders.riva@aol.com,caiminwei123@gmail.com,yulingguo086@gmail.com,yingxiaolu086@gmail.com,lijiazhen0035@gmail.com,fangp370@gmail.com,huangyayu10086@gmail.com,fuziyuan110@gmail.com,xinyingdu886@gmail.com,yasiaforever.1971@aol.com,lukaszfidalgo@aol.com,zaichi29@aol.com,prostotakitak.1974@aol.com,mo90nroe@aol.com,blonde.87@aol.com,dimidrol.1969@aol.com,duwei1998@gmx.com"
def check_email_address(email): def check_email_address(email):
# pass the regular expression # pass the regular expression
@@ -56,22 +57,6 @@ class MailReader():
self.login = login self.login = login
self.password = password self.password = password
@staticmethod
def show_folders(imap) -> list:
folders = []
isImapClient = isinstance(imap, IMAPClient)
if not isImapClient:
for i in imap.list()[1]:
l = i.decode().split(' "/" ')
folders.append(l[1])
return folders
else:
list = imap.list_folders()
for i in list:
name = i[-1]
folders.append(name)
return folders
def read_emails(self, mails_messages: list) -> list: def read_emails(self, mails_messages: list) -> list:
imap = create_imap(self.login) imap = create_imap(self.login)
isImapClient = isinstance(imap, IMAPClient) isImapClient = isinstance(imap, IMAPClient)
@@ -87,7 +72,7 @@ class MailReader():
mail_list = [] mail_list = []
print("read mails from {}".format(self.login)) print("read mails from {}".format(self.login))
if not isImapClient: if not isImapClient:
folder_list = self.show_folders(imap) folder_list = show_folders(imap)
for folder in folder_list: for folder in folder_list:
print("folder is {}".format(folder)) print("folder is {}".format(folder))
mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_fr, mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_fr,
@@ -95,7 +80,7 @@ class MailReader():
mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_EN, mail_list.extend(self._get_messages_from_folder(imap, subject=VALIDATION_URL_SUBJECT_EN,
folder=folder)) folder=folder))
else: else:
folder_list = self.show_folders(imap) folder_list = show_folders(imap)
for folder in folder_list: for folder in folder_list:
print("folder is " + folder) print("folder is " + folder)
mail_list.extend(self._get_messages_from_folder_for_imapclient(imap, folder=folder)) mail_list.extend(self._get_messages_from_folder_for_imapclient(imap, folder=folder))
@@ -206,8 +191,6 @@ def need_to_valid_url(url: str, successful_items) -> bool:
parts = url.split('/') parts = url.split('/')
id = parts[5] id = parts[5]
if len(id) == 6: if len(id) == 6:
if id == "CS93VB":
print("found")
for item in successful_items: for item in successful_items:
if item.id == id: if item.id == id:
if item.url_validated is not None: if item.url_validated is not None:
@@ -231,8 +214,6 @@ def need_to_check_email(mail: str, successful_items) -> bool:
# get all the item with the current mail # get all the item with the current mail
filtered_items = list(filter(lambda item: item.email == mail, successful_items)) filtered_items = list(filter(lambda item: item.email == mail, successful_items))
# has validated value # has validated value
if mail == "lakrishstarko@aol.com":
print("found")
if len(filtered_items) > 0: if len(filtered_items) > 0:
validated_items = list(filter( validated_items = list(filter(
lambda filtered_item: filtered_item.url_validated is not None and filtered_item.url_validated is True, lambda filtered_item: filtered_item.url_validated is not None and filtered_item.url_validated is True,
@@ -259,15 +240,17 @@ def need_to_check_email(mail: str, successful_items) -> bool:
def read_mails(): def read_mails():
# check time before start checking emails # check time before start checking emails
if is_time_between(time(7, 30), time(19, 30)): if is_time_between(time(7, 30), time(23, 30)):
# get email address # get email address
mail_list = MONGO_STORE_MANAGER.get_destination_emails() mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# excel_reader = ExcelHelper() # excel_reader = ExcelHelper()
# mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx") # mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx")
# mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq") # mail_address1 = MailAddress(mail="appointment2022@aol.com", password="gyilpmvyyvlcaviq")
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb") # mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce") # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
# mail_list = [mail_address1] # mail_address3 = MailAddress(mail="shenpeiyun@naver.com", password="Rdv@20222021")
# mail_address3 = MailAddress(mail="panleicim@pissmail.com", password="PANLei+1984")
# mail_list = [mail_address3]
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day() successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
mails_messages = [] mails_messages = []
with ThreadPoolExecutor(max_workers=200) as executor: with ThreadPoolExecutor(max_workers=200) as executor:
+1 -2
View File
@@ -12,8 +12,7 @@ from imapclient import IMAPClient
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.logs.AppLogging import init_logger from src.logs.AppLogging import init_logger
from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap
from src.pojo.mail.mail_pojo import MailPojo, MailAddress from src.pojo.mail.mail_pojo import MailPojo
from src.utils.excel_reader import ExcelHelper
from src.utils.timeutiles import is_time_between from src.utils.timeutiles import is_time_between
VALIDATION_URL_SUBJECT_fr = 'Validation de votre demande de rendez-vous' VALIDATION_URL_SUBJECT_fr = 'Validation de votre demande de rendez-vous'
+32
View File
@@ -0,0 +1,32 @@
import requests
from mako.template import Template
from src import config
from src.notification.AcceptedResultPojo import AcceptedResultPojo
class SignalSender:
def __init__(self):
self.group = "group.NjVhb1NrZU43TytWcTV6YUZkQVZjMmhGYUorK0pWUWJOaGhvS1JUMVYwbz0="
def send_message(self, msg):
x = requests.post("http://appointment.lpaconsulting.fr:10086/v2/send", json=
{"message": msg, "number": "+33768562195",
"recipients": ["group.NjVhb1NrZU43TytWcTV6YUZkQVZjMmhGYUorK0pWUWJOaGhvS1JUMVYwbz0="]}
)
print(x.text)
def send_result(self, result: AcceptedResultPojo):
mytemplate = Template(filename=config.ROOT_DIR + "/templates/signal_results.html")
msg = mytemplate.render(result=result)
self.send_message(msg=msg)
if __name__ == '__main__':
acceptedResultPojo = AcceptedResultPojo(msg="测序<br>测试",
url="https://rendezvousparis.hermes.com/client/register/AQ57C9",
slot_position="", sim_position="", passport="test", email="test@test.com",
name="test test", phone="0649614591", ccid="", created_at="",
validated_at="")
SignalSender().send_result(acceptedResultPojo)
+3 -4
View File
@@ -1,11 +1,10 @@
from src.db.mongo_manager import MONGO_STORE_MANAGER from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.utils.excel_reader import ExcelHelper from src.utils.excel_reader import read_contacts
def upload_contacts_list(): def upload_contacts_list():
excel_helper = ExcelHelper() _contacts_to_book = read_contacts("/Users/panlei/Desktop/yahoo_aol_valid_25.xlsx")
contacts_to_book = excel_helper.read_contacts("/Users/lpan/Desktop/yahoo_aol.xlsx") return _contacts_to_book
return contacts_to_book
# 把新的联系人存到网上 # 把新的联系人存到网上
+1 -4
View File
@@ -8,7 +8,7 @@ from src.db.mongo_manager import MongoDbManager
from src.pojo.contact_pojo import ContactPojo from src.pojo.contact_pojo import ContactPojo
from src.utils import excel_reader from src.utils import excel_reader
from src.utils.excel_reader import get_random_fr_phone_numbers, ExcelHelper from src.utils.excel_reader import get_random_fr_phone_numbers, ExcelHelper
from src.utils.generate_random_passport_id import get_random_passport_id_number from src.utils.contacts.generate_random_passport_id import get_random_passport_id_number
def get_ordered_combins(stuff): def get_ordered_combins(stuff):
@@ -150,10 +150,7 @@ def generate_name_from_email(mail_address, pinyin_name_list):
# found_name = check_name(word_to_test=word_to_test, pinyin_name_list=pinyin_name_list) # found_name = check_name(word_to_test=word_to_test, pinyin_name_list=pinyin_name_list)
# if found_name is not None: # if found_name is not None:
# return found_name # return found_name
# if len(word_to_test) >= 7:
# if len(word_to_test) >= 6:
if len(word_to_test) >= 5: if len(word_to_test) >= 5:
# if len(word_to_test) >= 4:
found_name = check_name(word_to_test=word_to_test, pinyin_name_list=pinyin_name_list) found_name = check_name(word_to_test=word_to_test, pinyin_name_list=pinyin_name_list)
if found_name is not None: if found_name is not None:
return found_name return found_name
@@ -2,8 +2,10 @@ import random
import xlsxwriter import xlsxwriter
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.person_name.extract_name_with_pinyinlist import read_pinyin_list_from_file from src.person_name.extract_name_with_pinyinlist import read_pinyin_list_from_file
from src.pojo.mail_creation_pojo import MailCreationPojo from src.pojo.mail_creation_pojo import MailCreationPojo
from src.utils.excel_reader import get_random_fr_phone_numbers
from src.utils.password_generator import generate_password from src.utils.password_generator import generate_password
@@ -12,7 +14,7 @@ def write_mail_creation_pojo_to_excel(valid_contacts: list):
col = 0 col = 0
# Create a workbook and add a worksheet. # Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('mail_contacts_{}.xlsx'.format(len(valid_contacts))) workbook = xlsxwriter.Workbook('mail_contacts_{}.xlsx'.format(len(valid_contacts)))
header_data = ['name', 'password'] header_data = ['name', '邮箱地址', "password", "恢复邮箱", "恢复邮箱密码"]
worksheet = workbook.add_worksheet() worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True}) header_format = workbook.add_format({'bold': True})
@@ -21,19 +23,42 @@ def write_mail_creation_pojo_to_excel(valid_contacts: list):
row = row + 1 row = row + 1
for info in valid_contacts: for info in valid_contacts:
worksheet.write(row, col, "{}".format(info.name)) worksheet.write(row, col, "{}".format(info.name))
worksheet.write(row, col + 1, info.password) worksheet.write(row, col + 1, info.mail_address)
worksheet.write(row, col + 2, info.password)
worksheet.write(row, col + 3, info.recover_mail)
worksheet.write(row, col + 4, info.recover_mail_pwd)
row += 1 row += 1
workbook.close() workbook.close()
def get_recover_mail_list(mail_size: int):
_mail_list = MONGO_STORE_MANAGER.get_destination_emails()
random.shuffle(_mail_list)
return _mail_list[0:mail_size]
def generate_mail_address(name):
_name_splitted = name.split(" ")
_first_name = _name_splitted[1]
_last_name = _name_splitted[0]
_year = random.randint(1990, 2000)
return "{}.{}{}".format(_last_name, _first_name, _year)
if __name__ == '__main__': if __name__ == '__main__':
pinyin_name_list = read_pinyin_list_from_file() pinyin_name_list = read_pinyin_list_from_file()
random.shuffle(pinyin_name_list) random.shuffle(pinyin_name_list)
_name_list = pinyin_name_list[0:100] _size = 500
_name_list = pinyin_name_list[0:_size]
# write to excel # write to excel
_recovery_mail_list = get_recover_mail_list(_size)
_generated_list = [] _generated_list = []
for _name in _name_list: name_mail_list = list(zip(_name_list, _recovery_mail_list))
for _name in name_mail_list:
_password = generate_password() _password = generate_password()
_c = MailCreationPojo(_name, _password) _phone = get_random_fr_phone_numbers()
_mail = generate_mail_address(_name[0])
_c = MailCreationPojo(_name[0], _password, _mail, _name[1].mail, _name[1].password)
_generated_list.append(_c) _generated_list.append(_c)
write_mail_creation_pojo_to_excel(_generated_list) write_mail_creation_pojo_to_excel(_generated_list)
+8
View File
@@ -0,0 +1,8 @@
class MailCreationPojo:
def __init__(self, name, password, mail_address, recover_mail,recover_mail_pwd):
self.name = name
self.password = password
self.mail_address = mail_address
self.recover_mail = recover_mail
self.recover_mail_pwd = recover_mail_pwd
+12
View File
@@ -0,0 +1,12 @@
姓名:${result.name}
电话: ${result.phone}
邮件: ${result.email}, 密码: ${result.mail_password} (用网易邮箱大师登录)
护照: ${result.passport}
约会 url: ${result.url}
邮件内容: ${result.message}
+7
View File
@@ -0,0 +1,7 @@
from src.utils.excel_reader import read_contacts
_contact_list = read_contacts(file_name="/Users/panlei/Desktop/yahoo_aol_valid_23.xlsx")
# print(_contact_list)
for _contact in _contact_list:
if _contact.last_name is None or _contact.first_name is None:
print(_contact.mail)
@@ -57,7 +57,7 @@ def generate_titre_sejour_number(size=10) -> list:
if __name__ == '__main__': if __name__ == '__main__':
# for i in range(1,200): # for i in range(1,200):
# print(get_random_id_number()) # print(get_random_id_number())
# for i in range(1, 501): for i in range(1, 101):
# print(get_random_passport_id_number()) print(get_random_passport_id_number())
for id in generate_titre_sejour_number(3200): # for id in generate_titre_sejour_number(3200):
print(id) # print(id)
+63
View File
@@ -0,0 +1,63 @@
import xlsxwriter
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.utils.excel_reader import read_contacts
class ExportedUser:
def __init__(self, last_name, first_name, password, mail, phone):
self.last_name = last_name
self.first_name = first_name
self.password = password
self.mail = mail
self.phone = phone
def export_registered_users() -> list:
_user_list = MONGO_STORE_MANAGER.get_all_registered_users()
print(len(_user_list))
return _user_list
# for _user in _user_list:
# print(_user)
def read_contacts_to_check():
_contact_list = read_contacts(file_name="/Users/panlei/Desktop/check_names.xlsx")
return _contact_list
def write_to_excel(_to_export_list):
row = 0
col = 0
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('check_names_of_contacts_{}.xlsx'.format(len(_to_export_list)))
header_data = ['Nom/姓', 'Prénom/名', 'phone/电话', 'mail/邮箱', 'mot de pass/密码']
worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True})
for col_num, data in enumerate(header_data):
worksheet.write(row, col_num, data, header_format)
row = row + 1
for info in _to_export_list:
info.phone = info.phone
# Iterate over the data and write it out row by row.
worksheet.write(row, col, info.last_name)
worksheet.write(row, col + 1, info.first_name)
worksheet.write(row, col + 2, "0"+info.phone)
worksheet.write(row, col + 3, info.mail)
worksheet.write(row, col + 4, info.password)
row += 1
workbook.close()
if __name__ == '__main__':
_user_list = export_registered_users()
contact_list = read_contacts_to_check()
_to_export = []
for _user in _user_list:
for contact in contact_list:
if _user.mail == contact.mail:
_export_user = ExportedUser(contact.last_name, contact.first_name, _user.password, contact.mail,
contact.phone)
_to_export.append(_export_user)
write_to_excel(_to_export)
+76
View File
@@ -0,0 +1,76 @@
import colorsys
import json
import random
import numpy as np
import pandas
import matplotlib.patches as mpatches
from matplotlib import pyplot as plt
from src.pojo.ReserveResultPojo import ReserveResultPojo
def read_reserve_pojo_from_excel(file_path: str):
print("read file " + file_path)
contact_list_in_json = pandas.read_excel(file_path)
# .to_json(orient='records'))
plot_bargraph_with_groupings(contact_list_in_json, "source_from", "source_from", "分布", "型号", "数量")
# contact_dict_list = json.loads(contact_list_in_json)
# contact_list = []
# for contact_dict in contact_dict_list:
# last_name = contact_dict['last_name']
# first_name = contact_dict['first_name']
# phone_number = contact_dict['phone']
# source_from = contact_dict['source_from']
# contact = ReserveResultPojo()
# contact.lastName = last_name
# contact.firstName = first_name
# contact.phone = phone_number
# contact.source_from = source_from
# contact_list.append(contact)
# return contact_list
def plot_bargraph_with_groupings(df, groupby, colourby, title, xlabel, ylabel):
"""
Plots a dataframe showing the frequency of datapoints grouped by one column and coloured by another.
df : dataframe
groupby: the column to groupby
colourby: the column to color by
title: the graph title
xlabel: the x label,
ylabel: the y label
"""
randHSVcolors = [(np.random.rand(), 1, 1) for i in range(len(df[colourby].unique()))]
# Convert HSV list to RGB
randRGBcolors = []
for HSVcolor in randHSVcolors:
randRGBcolors.append(colorsys.hsv_to_rgb(HSVcolor[0], HSVcolor[1], HSVcolor[2]))
# Makes a mapping from the unique colourby column items to a random color.
ind_col_map = {x: y for x, y in zip(df[colourby].unique(),
randRGBcolors)}
# Find when the indicies of the soon to be bar graphs colors.
unique_comb = df[[groupby, colourby]].drop_duplicates()
name_ind_map = {x: y for x, y in zip(unique_comb[groupby], unique_comb[colourby])}
values_counts = df[groupby].value_counts()
c = values_counts.index.map(lambda x: ind_col_map[name_ind_map[x]])
# Makes the bargraph.
ax = df[groupby].value_counts().plot(kind='bar',
# figsize=FIG_SIZE,
title=title,
color=[c.values])
# Makes a legend using the ind_col_map
legend_list = []
for key in ind_col_map.keys():
legend_list.append(mpatches.Patch(color=ind_col_map[key], label=key))
# display the graph.
plt.legend(handles=legend_list)
ax.set_xlabel(xlabel)
ax.set_ylabel(ylabel)
if __name__ == '__main__':
read_reserve_pojo_from_excel("/Users/panlei/2023_10_27.xlsx")