python PyQt5 implements the demo of email reminder after vivado completes the implementation

Keywords: Python PyQt5 vivado

1 function

ug904 mentioned that if you want to use a remote host to start one or more job s, select "start and run on the remote host (Linux only)". If I want to use another windows host to run programs, I need to open remote control to monitor the operation or check it often. In order to solve this problem, I implemented a simple demo with python pyqt5.

Realized function: monitor the log file of vivado implementation at an interval of 1 minute. If there is information in the log: [common 17-206] exiting vivado at XXX, send some previous key steps and the searched time to the received email address.

2 code

2.1 introduction

import sys
import re
import threading
import time
import win32ui
import smtplib
from email.mime.text import MIMEText

def fun_sendmail(list_info):
    print("entry fun_sendmail")
    #Set up the information required by the server
    #163 mailbox server address
    mail_host = ''  
    #163 user name
    mail_user = '137xxxxxxxx'  
    #Password (some mailboxes are IMAP/SMTP authorization codes) 
    mail_pass = 'xxxxxxxxxxxxxx'   
    #Email address of mail sender
    sender = ''  
    #The email address of the mail recipient. Note that [] packages are required, which means you can write multiple email addresses for mass sending
    receivers = ['']  

    #Set email information
    #Mail content settings
    text_str = ''.join(list_info)
    message = MIMEText(text_str,'plain','utf-8')
    #Mail subject       
    message['Subject'] = "The program is finished!" 
    #sender information 
    message['From'] = sender 
    #Recipient information     
    message['To'] = receivers[0]   
    #Sign in and send mail
        smtpObj = smtplib.SMTP() 
        #Connect to server
        #Log in to the server
        #send out
        #sign out
    except smtplib.SMTPException as e:

def fun_serch_keyword(path):
    print("entry fun_serch_keyword")
    global list_info
    file = open(path, mode = 'r')
    info_index = 0
    info_num = len(list_info)
    time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    line = file.readline()
    while line:
        line = file.readline() 
        if(re.findall('Starting|Ending|Exiting', line)):
            info_index += 1
            if info_index > info_num:
        if(re.findall('Exiting', line)):

def fun_timer():
    print("entry fun_timer")
    global timer
    timer = threading.Timer(60, fun_timer)

list_info = []
dlg = win32ui.CreateFileDialog(1) 
impl_runme_log_path = dlg.GetPathName()
timer = threading.Timer(1, fun_timer)

Program logic:

  1. Open the file dialog box and select the path of the runme.log file.
  2. Nested instantiated 60s timers to complete keyword search of runme.log file every 60s.
  3. Save the information containing "Starting|Ending|Exiting".
  4. If there is information about the "Exiting" keyword, send an email.
  5. Send the keyword information to the receiving mailbox.

Change the email information to your own. Environmental Science:

  • Python 3.8.8
  • PyQt5

2.2 use

Here are the steps to get the IMAP/SMTP authorization code from the 163 mailbox tested:

3 packaging and publishing

In order to facilitate the use of hosts without an installation environment, I wrote an interface using PyQt5 and packaged it. Because I am also Xiaobai, the program may have many bug s. At present, I have only tested it a few times. The procedure is described as follows:

  • The email authorization code is encrypted with AES algorithm. In fact, it's OK to use it without encryption. In order to learn python, I added it.
  • The parameter storage is implemented using qssettings and stored in "config.ini" under the path of the running file. If you need to enter parameters for the first run, it will be loaded automatically, and only the authorization code is encrypted.
  • Operation logic
    • First, click Select path to select the path of the current implementation
    • Click start to store the parameters, and query whether there is runme.log under the selected path. If not, create a new blank document. Because if you haven't run implementation, or didn't run at the beginning.
    • If the log file cannot be created, it indicates that it has started to run. At this time, directly start to query the keywords every 60s.
    • If exiting vivado is found, an email is sent. The contents of the email are as follows:

4 attachments

Extraction code: open

Posted by maxat on Thu, 25 Nov 2021 18:07:16 -0800