def setFromConfigurationFile(self): #excel_file = "~tempfile.1.xlsx" #myExcel.getDataFromExcel(excel_file) if myConfig.configuration_file_has_been_persisted(): print("The program starts") #print(myConfig.check_data("EMAIL",'subject')) # for key in (myConfig.get_mail_data()): print(key) if myConfig.check_data("EMAIL",'subject'): #print(myConfig.get_mail_data()['subject']) #myConfig.get_mail_data()['subject'] print() print() print() self.line.setText(myConfig.get_saved_data("EXCEL",'file')) # self.line.setText("Hola perro") self.LineSubject.setText(myConfig.get_saved_data("EMAIL",'subject')) self.text_area.setText(myConfig.get_saved_data("EMAIL",'body')) if myConfig.check_data('Automate outlook mailing','auto_run'): if myConfig.get_saved_data('Automate outlook mailing','auto_run') == "True": self.autorun.setChecked(True) self.autorun.setText('Auto Run On') print('Auto Run On') pass else: self.autorun.setChecked(False) self.autorun.setText('Auto Run Off') print('Auto Run Off') pass pass else: print('auto_run not exist') myConfig.configuration_file_create_persist() pass pass else: myConfig.configuration_file_create_persist() pass #myExcel.getDataFromExcel(excel_file,) pass else: print("The program needs to be configured") myConfig.configuration_file_create_persist() pass pass
def clickMethod(self): print('Your name: ' + self.line.text()) if myConfig.configuration_file_has_been_persisted(): print("The program starts") print(myConfig.get_saved_data("EXCEL","subject")) else: print("The program needs to be configured") myConfig.configuration_file_create_persist() pass if self.line.text() != "": myConfig.configuration_file_set_something_to_save("EXCEL","file",self.line.text()) pass if self.LineSubject.text() != "": myConfig.configuration_file_set_something_to_save("EMAIL","subject",self.LineSubject.text()) pass if self.text_area.toPlainText() != "": myConfig.configuration_file_set_something_to_save("EMAIL","body",self.text_area.toPlainText()) pass # print(self.text_area.toPlainText()) #print(myConfig.get_mail_data()['subject']) # myConfig.configuration_file_create_persist() pass """
def the_aim_of_the_program(): if myConfig.configuration_file_has_been_persisted(): print("The program starts") #print(myConfig.check_data("EMAIL",'subject')) # for key in (myConfig.get_mail_data()): print(key) if myConfig.check_data("EMAIL", 'subject'): #print(myConfig.get_mail_data()['subject']) #myConfig.get_mail_data()['subject'] print() print() print() theFile = myConfig.get_saved_data("EXCEL", 'file') theSubject = myConfig.get_saved_data("EMAIL", 'subject') theBody = myConfig.get_saved_data("EMAIL", 'body') theBodyInHTML = "<p>" + myConfig.get_saved_data("EMAIL", 'body') + "</p>" print("the aim") #print(theFile,theSubject,theBody,theBodyInHTML) myExcel.getDataFromExcel(theFile, theSubject, theBody, theBodyInHTML) pass else: print("subject not exist") myConfig.configuration_file_create_persist() pass #myExcel.getDataFromExcel(excel_file,) pass else: print("The program needs to be configured") myConfig.configuration_file_create_persist() pass pass
def get_after_delay(): print(""" GET DELAY """) if myConfig.configuration_file_has_been_persisted(): print("has been persisted") #print(myConfig.check_data("EMAIL",'subject')) # for key in (myConfig.get_mail_data()): print(key) if myConfig.check_data('Automate outlook mailing', "time_after_run"): print("time_after_run exist") data_raw = myConfig.get_saved_data('Automate outlook mailing', "time_after_run") if RepresentsInt(data_raw): print("time_after_run Okey") time_after_run = int(data_raw) print(""" ##################################### """) print(time_after_run) print(""" ##################################### """) pass else: print("time_after_run ValueError") #print(time_to_start) pass else: print("time_after_run not exist") myConfig.configuration_file_create_persist() pass #myExcel.getDataFromExcel(excel_file,) pass else: print("The program needs to be configured") myConfig.configuration_file_create_persist() pass pass
def getDataFromExcel(excel_file_to_load, subject, body, body_in_html): import os #excel_file_to_load = os.path.abspath(str(excel_file_to_load)) file = excel_file_to_load wb = load_workbook(file, data_only=True) #ws = wb['TO_SERVICE-NOW'] sheets = wb.sheetnames CurrentWorksheet = wb[sheets[0]] # CurrentWorksheet = wb.active max_row = CurrentWorksheet.max_row + 1 max_col = CurrentWorksheet.max_column + 1 for y in range(1, max_col): cell_Assignment_Group = CurrentWorksheet.cell(row=1, column=y).value print("column_data_" + cell_Assignment_Group.replace(" ", "_").lower()) #AssignedGroup = cell_Assignment_Group pass for x in range(2, max_row): #REQ_VAR = "" #RITM_VAR = "" #TASK_VAR = "" #GROUP_VALUE = "" #datetime.datetime.now() print("salto de linea -------------------------- " + time.strftime('%Y-%m-%d %H:%M:%S')) print("") # https://www.codespeedy.com/validate-email-in-python/ """ if CurrentWorksheet.cell(row=x, column=3).value == "NO": else: print("ya se hizo") print(CurrentWorksheet.cell(row=x, column=3).value) print("") """ #print(ws.cell(row=x, column=y).value) column_data_first_name = CurrentWorksheet.cell(row=x, column=1).value print(column_data_first_name) column_data_last_name = CurrentWorksheet.cell(row=x, column=2).value print(column_data_last_name) column_data_email = CurrentWorksheet.cell(row=x, column=3).value print(column_data_email) column_data_cell_phone = CurrentWorksheet.cell(row=x, column=4).value print(column_data_cell_phone) column_data_unit = CurrentWorksheet.cell(row=x, column=5).value print(column_data_unit) column_data_arrival = CurrentWorksheet.cell(row=x, column=6).value column_data_arrival = getDateNormaliced(column_data_arrival) print(column_data_arrival) column_data_departure = CurrentWorksheet.cell(row=x, column=7).value column_data_departure = getDateNormaliced(column_data_departure) print(column_data_departure) column_data_code = CurrentWorksheet.cell(row=x, column=8).value print(column_data_code) column_data_company_name = CurrentWorksheet.cell(row=x, column=9).value print(column_data_company_name) column_data_contact = CurrentWorksheet.cell(row=x, column=10).value print(column_data_contact) column_data_maddress = CurrentWorksheet.cell(row=x, column=11).value print(column_data_maddress) column_data_mcity = CurrentWorksheet.cell(row=x, column=12).value print(column_data_mcity) column_data_mstate = CurrentWorksheet.cell(row=x, column=13).value print(column_data_mstate) print("asda") column_data_mzip = CurrentWorksheet.cell(row=x, column=14).value print(column_data_mzip) column_data_memail = CurrentWorksheet.cell(row=x, column=15).value print(column_data_memail) column_data_phone = CurrentWorksheet.cell(row=x, column=16).value print(column_data_phone) column_data_greeting = CurrentWorksheet.cell(row=x, column=17).value print(column_data_greeting) column_data_salutation = CurrentWorksheet.cell(row=x, column=18).value print(column_data_salutation) column_data_link_to_qr = CurrentWorksheet.cell(row=x, column=19).value print(column_data_link_to_qr) #toServiceNow(cell_Assignment_Group.value , cell_Free_Text_Field.value) #CreateUserFreeformRequest("datavision","excuse me, this is a test",True) #CreateUserFreeformRequest(cell_Assignment_Group.value,cell_Free_Text_Field.value,True,x) #self.CreateUserFreeformRequest(cell_Assignment_Group,cell_Free_Text_Field,"NO") #self.CreateUserFreeformRequest() #mark as complete """ CurrentWorksheet.cell(row=x, column=3).value = "YES" CurrentWorksheet.cell(row=x, column=4).value = self.request #REQUEST_VALUE CurrentWorksheet.cell(row=x, column=5).value = self.ritm # RITM_VALUE CurrentWorksheet.cell(row=x, column=6).value = self.task #TASK_VALUE CurrentWorksheet.cell(row=x, column=7).value = datetime.datetime.now() CurrentWorksheet.cell(row=x, column=8).value = self.AssignedGroupFromPage #ASSIGNMENT_GROUP_VALUE """ """ ws.cell(row=x, column=4).value = REQ_VAR #REQUEST_VALUE ws.cell(row=x, column=5).value = RITM_VAR # RITM_VALUE ws.cell(row=x, column=6).value = TASK_VAR #TASK_VALUE ws.cell(row=x, column=7).value = datetime.datetime.now() ws.cell(row=x, column=8).value = GROUP_VALUE #ASSIGNMENT_GROUP_VALUE """ #CurrentWorksheet.cell(row=x, column=7).value = datetime.datetime.now() #print(datetime.datetime.now()) #ws2['F5'] # .splite(" ") qr_image_file = myQRCode.qrcode_create(column_data_code) # word_file_path = './~tempfile.docx' # cs_freeze needs that #qr_image_file = myConfig.getPath(qr_image_file) body_from_template = myWord.create_email_from_html_template( qr_image_file, str(column_data_first_name) + " " + str(column_data_last_name), column_data_greeting, column_data_unit, column_data_arrival, column_data_departure, column_data_salutation, column_data_maddress, column_data_company_name, column_data_phone) #body_from_template = myConfig.getPath(body_from_template) print(type(column_data_email)) if type(column_data_email) == str: import re listOfEmails = re.split('\s+', column_data_email) print(listOfEmails) try: print(column_data_memail.split(" ")) pass except AttributeError as NoneType: pass for email in listOfEmails: print("sending email to : " + email) # myMail.email_send("*****@*****.**","test subject","test body body","<p>my test html body</p>",wordfile) #myMail.email_send(email,"Hello World","test body body","<p>my test html body</p>",word_file_path) #print(email,subject,body,body_in_html,word_file_path) #myMail.email_send(email,subject,body,body_in_html,word_file_path) # send the email with the image if myConfig.check_data('Automate outlook mailing', 'Word_File_Attachement'): if myConfig.get_saved_data( 'Automate outlook mailing', 'Word_File_Attachement') == "True": word_file_path = './document.docx' myWord.word_create_from_template( word_file_path, qr_image_file, str(column_data_first_name) + " " + str(column_data_last_name), column_data_greeting, column_data_unit, column_data_arrival, column_data_departure, column_data_salutation, column_data_maddress, column_data_company_name, column_data_phone) myMail.email_send(email, subject, body, body_from_template, qr_image_file, word_file_path) print('Word File Attachement On') pass else: print('Word File Attachement Off') myMail.email_send(email, subject, body, body_from_template, qr_image_file) pass pass else: print('auto_run not exist') myConfig.configuration_file_create_persist() pass pass #,subject,body,body_in_html pass pass else: print("not email allowed") pass print("") print("mark as complete") print("") #ws['A10'] = datetime.datetime.now() #save escel #text_temp = "successfully_excel_" #sleep(15) pass wb.save(file) #sleep(120) #driver.close() #https://stackoverflow.com/questions/21191494/how-to-open-an-excel-file-with-python-to-display-its-content #https://www.w3schools.com/python/python_file_remove.asp pass # getDataFromExcel("~tempfile.1.xlsx")
def the_aim_of_the_program_with_delay(): if myConfig.configuration_file_has_been_persisted(): print("The program starts with delay") #print(myConfig.check_data("EMAIL",'subject')) # for key in (myConfig.get_mail_data()): print(key) if myConfig.check_data('Automate outlook mailing', "auto_run"): print("delay exist") if myConfig.get_saved_data('Automate outlook mailing', "auto_run") == 'True': print("auto_run is True") # time.sleep(10) ############################ print("Process starts") print("delay starts") get_delay() time.sleep(time_to_start) print("delay passed") print(""" ######################################### Automated Process started ######################################### """) the_aim_of_the_program() print(""" ######################################### Automated Process finished ######################################### """) get_after_delay() print("after delay starts") time.sleep(time_after_run) print("after delay passed") print("Process finished") ############################ print("bye guy") myShutdown() pass else: print("auto_run is False") # myConfig.configuration_file_create_persist() pass pass else: print("auto_run not exist") myConfig.configuration_file_create_persist() pass #myExcel.getDataFromExcel(excel_file,) pass else: print("The program needs to be configured") myConfig.configuration_file_create_persist() pass pass