use Path.home()

This commit is contained in:
2025-06-09 12:39:40 +02:00
parent ffbb2f8583
commit 897c4825da
+23 -20
View File
@@ -15,7 +15,7 @@ DEFAULT_SERIAL_TO_IGNORE = ["47e7e36b", "bitbrowser"]
def upload_contacts_list():
_contacts_to_book = read_contacts(str(Path.home()) + "/Desktop/real_name_contacts_100_gmx_ch_05_04_mac.xlsx")
_contacts_to_book = read_contacts(str(Path.home()) + "/Desktop/contact_list_2025-05-20.xlsx")
return _contacts_to_book
@@ -97,26 +97,26 @@ def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.dat
def generate_valid_contact_list_for_day(segment_number=1):
_collection_name = "2025-04-08"
_collection_name = "2025-06-07"
_valid_contact_list = MONGO_STORE_MANAGER.get_all_successful_items_for_one_day(_collection_name)
_all_contacts = MONGO_STORE_MANAGER.get_all_contacts_to_book()
_contact_to_save = []
for _contact in _valid_contact_list:
if _contact.mail == "wesley_barton477273@aol.com":
print("found")
# _contact.store = "faubourg"
_contact.store = "random"
# if _contact.last_name is None or len(_contact.last_name) == 0:
for _true_contact in _all_contacts:
if _true_contact.mail == _contact.mail:
if _contact.mail == "wesley_barton477273@aol.com":
print("found")
_contact.last_name = _true_contact.last_name
_contact.phone = _true_contact.phone
_contact.passport = _true_contact.passport
_contact.passport = str(_true_contact.resident_card_number)[:9]
_contact.first_name = _true_contact.first_name
_contact.resident_card_number = _true_contact.resident_card_number
_contact.source_from = _true_contact.source_from
_contact.resident_card_number = str(_true_contact.resident_card_number)[:9]
if _true_contact.source_from is not None and len(_true_contact.source_from) > 0:
print(_true_contact.source_from)
_contact.source_from = _true_contact.source_from
else:
print("no source from for " + _contact.mail)
if _contact.url_validated:
if _contact.last_name is not None and len(_contact.last_name) > 0:
@@ -148,17 +148,21 @@ def write_list_with_segment_number(file_name, _contact_to_save_list, segment_num
_mac_list = []
_win_list = []
for _contact in _contact_to_save_list:
if _contact.source_from == "rdv" or _contact.source_from == "lpan" or _contact.source_from == "panlei":
_mac_list.append(_contact)
else:
if _contact.source_from == "panleicim":
_win_list.append(_contact)
else:
_mac_list.append(_contact)
# if _contact.source_from == "rdv" or _contact.source_from == "lpan" or _contact.source_from == "panlei":
# _mac_list.append(_contact)
# else:
# _win_list.append(_contact)
write_new_contacts_to_excel(_mac_list, file_name=file_name + "_mac")
write_new_contacts_to_excel(_win_list, file_name=file_name + "_win")
# for i in range(0, segment_number):
# _step = int(len(_contact_to_save_list) / segment_number)
# _sublist = _contact_to_save_list[i * _step:_step * (i + 1)]
# _file_name = file_name + "_" + str(i + 1)
# write_new_contacts_to_excel(_sublist, file_name=_file_name)
for i in range(0, segment_number):
_step = int(len(_contact_to_save_list) / segment_number)
_sublist = _contact_to_save_list[i * _step:_step * (i + 1)]
_file_name = file_name + "_" + str(i + 1)
write_new_contacts_to_excel(_sublist, file_name=_file_name)
def merge_contact_list_files(file_list: list, final_file_name="merged_contact_list"):
@@ -185,6 +189,8 @@ def generate_all_contact_list():
random.shuffle(_all_contacts)
for _contact in _all_contacts:
_contact.store = "random"
_contact.passport = str(_contact.resident_card_number)[:9]
_contact.resident_card_number = str(_contact.resident_card_number)[:9]
write_new_contacts_to_excel(_all_contacts, file_name="all")
write_list_with_segment_number("all", _all_contacts, 1)
@@ -267,9 +273,6 @@ if __name__ == '__main__':
# print("end at {}".format(datetime.datetime.now()))
# generate_all_contact_list()
# merge_contact_list_files(
# ["/Users/lpan/Desktop/contact_list_2024-11-04.xlsx",
# "/Users/lpan/Desktop/contact_list_2024-11-07.xlsx",
# "/Users/lpan/Desktop/contact_list_2024-11-08.xlsx",
# "/Users/lpan/Desktop/contact_list_2024-11-06.xlsx"
# ])
# fix_phone_number_format(str(Path.home()) + "/Desktop/gmx_ch_100_2024-06-13.xlsx")