Lab2

docx

School

San Jose State University *

*We aren’t endorsed by this school

Course

104

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

docx

Pages

29

Uploaded by CountWolfMaster424

Report
San Jose State University Department of Electrical Engineering EE104, Fall 2022, Pham Laboratory Assignment #2 Objectives This lab introduces you the art of integration a few tools that you are already familiar to provide a business solution that you can use in the real life application. In this lab, we will implement a COVID-19 registration GUI using a new method, a simple database application using Excel, an email method to send a reminder emails for the 2 nd vaccination shot, and a text method to send a reminder text message to a given phone number for the 2 nd vaccination shot. Grading Refer to the section Python Programming for grading criteria. Bibliography I would like to acknowledge the Python open-source community and respective suppliers for making the material available. Jose Estrada Ramirez from EE104 Spring 2021 contributed some parts to this lab. References: https://www.simplifiedpython.net/python-gui-login/ https://stackoverflow.com/questions/46268167/how-to-search-for-data-in-an-xlsx-file-using-python-3 https://pythonguides.com/python-tkinter-label/ https://stackoverflow.com/questions/42491486/setting-an-image-as-a-tkinter-window-background https://www.geeksforgeeks.org/python-simple-registration-form-using-tkinter/?ref=rp https://riptutorial.com/tkinter/example/29713/grid--#:~:text=tkinter%20grid()&text=The%20grid()%20geometry%20manager,%2C%20row%20%2C %20rowspan%20and%20sticky%20 . https://stackoverflow.com/questions/17267140/python-pack-and-grid-methods-together https://northernlights.imanet.org/home?ssopc=1 https://www.freecodecamp.org/news/exception-handling-python/ https://www.twilio.com/docs/sms/quickstart/python https://medium.com/paul-zhao-projects/sending-emails-with-python-c084b55a2857 High-level Process It is time for a person to receive a COVID19 vaccination. The following is a typical process in the Santa Clara County. 1. IT staff creates 2 databases. One for medical staff admins, and one for patient records. 2. IT staff creates an admin record for a medical staff and save the information to the staff database. 3. The medical staff creates a patient record and saves in the patient database with name, DOB, phone number, email, etc. 4. The medical staff administer a vaccination shot for the patient, and log in today’s date. a. At this time, the patient database saves the first shot record, and automatically schedule the 2 nd shot for 21 days later. b. An IT automated messaging service sends the first text message to the patient congratulating on the 1 st vaccination, and show the date for the 2 nd shot. c. An IT automated email service sends the first email to the patient congratulating on the 1 st vaccination, and show the date for the 2 nd shot. 5. Three days before the 2 nd appointment: a. An IT automated messaging service sends the reminding text message to the patient for the 2 nd shot date. b. An IT automated email service sends the reminding email to the patient for the 2 nd shot date Of course the process continues for the 3 rd and 4 th shots, but we will stop at Step 5 above because when you know how to do it to this point, you can extend the program to any number of steps. Because of the text messaging and email services, you will need to leverage 3 rd party tools. Continue to the next sections below. 1
Download, Installation, and Licensing 1. Install necessary Python packages You will need to PIP INSTALL the followings: pip install twilio Reference to https://www.twilio.com/the-current/what-is-twilio-how-does-it-work , we will use Twilio to send SMS phone messages. Invoke Anaconda Powershell Prompt Type pip install twilio at the prompt. 1. Procedure to create a free-trial Twilio Account Overview WITH TWILIO YOU CAN BUILD: SMS marketing Omnichannel contact center Call tracking Web chat Push notifications Alerts and notifications Phone verification 2
Application: Lab 2 to send SMS text messages Procedure to create a free-trial Twilio account Go to https://www.twilio.com/try-twilio and fill out the form: You will receive an email with a link to confirm your email. Click on the link or copy and paste the URL into a browser to confirm: Then you can log in Now you must provide a phone number to start the free trial: 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Enter the number Twilio texts to your phone and submit to start the trial. On the next screen, select the choices as 4
5
After you click on the blue button above, you will see this screen Copy the Account SID and AUTH TOKEN to your Lab2 Python code: There are one location in the code that you must change to your own SID and AUTH TOKEN: You will also get a Twilio phone number: Press the button Choose this Number 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
7
Now go to this screen to grab the Python code that you can use to send a test message to your phone: I have created a sample file for you to modify and send a test text message to your phone. Download subfolder Twilio from Canvas and modify the source code accordingly to send a test message to your phone. 8
Then use that number in your Lab2 code. There is one location in the code that you need to replace the phone number: That’s it! Enjoy! 2. Set up a Gmail account for test emails Follow the instruction from this URL to set up a Gmail account for development. https://medium.com/paul-zhao-projects/sending-emails-with-python-c084b55a2857 Create a Gmail account as regular. You can call it anything you want. This email will be used for the EE104 lab purposes only. In order for Python to send email from your Gmail account, you will follow the steps from here: https://towardsdatascience.com/automate-sending-emails-with-gmail-in-python-449cc0c3c317 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
10
Then click Next on the confirmation screen. Now go back to this screen, and click on App passwords Authenticate as being requested, and you will see this screen, click on Other (Custom name) 11
Name it Python , then click the GENERATE button. 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Then you will get a new app password. Copy and save the 16-character password without space, e.g. watrmvxhvujcxuus , to use in your Python script. You will see 1 password in your screen below: 13
Now pip install yagmail Download the content from the folder yagmail from Canvas Make change accordingly using your own email and app password: And execute the file in Spyder or from your command line 14
From the command line: Validate that you get 2 emails, one from Spyder, and one from the command line execution: 15
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
OTHER METHODS There is also another method using OAuth2 authorization framework. You can read for yourself here: https://developers.google.com/gmail/api/quickstart/python Sample Excel Files There are three Excel files: File Name File Type Purpose Simple_Registration_Database.xlsx Microsoft Excel Worksheet Capture personal information of vaccine patron Registration_UserName_Password.xlsx Microsoft Excel Worksheet Store the UserName and Password of the vaccine patron COVID_Vaccine_Database.csv Microsoft Excel Comma Separated Value File For Python to record the 1 st vaccination date, calculate the 2 nd date for the 2 nd dose, and send text and/or email to remind the patron 16
GUI File There is only one background picture file for Graphic User Interface (GUI). The file name is BackgroundPicture.PNG. You actually can have it in any other picture format such as JPG, etc. Try it out for yourself. Sample Python Program The file GUI_Login_Registration_Form_Database_Email_Text_Reminders.py is provided to you. Here are some highlights. Sequence of execution and related Python code: Code to produce the GUI above: 17
18
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
19
20
21
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
22
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
23
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
By now you should get the idea and can trace down the GUI actions to the code using the same method by searching for texts and match those in the code. The key actions after registering a user and entering his/her personal information and the first date of vaccination is to send the email and/or text to remind this person to come 21 days later for the second shot. Here are the functions. 24
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
25
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
26
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
We can go over the entire operation in the lab session. You should not miss the lab if you cannot read the code yourself yet. 27
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Python Programming Lab Submission Once you learn the process and the code associate with each step in the process, you will be able to customize the program to do the followings. Program or Requirement Use Case Earned Score / Max Score README file This is a brief user guide so that the user can install the proper python packages and knows how to execute your program. The README file can contain sample screenshots with explanation. _____ / 10 Documentation Write a technical document so that other developers can understand your code and develop it better of fix any bugs that you may introduce. _____ / 10 Minimum 3 different background pictures Design and use your own background for important GUI steps. _____ / 15 Customized Gmail To send and receive emails from Python _____ / 15 Text messaging Send text successfully to a designated phone number _____ / 15 Customize the Excel database Add a minimum 3 more fields to the User Database _____ / 15 End-to-end execution Successful end-to-end execution of your modified program and a successful video recording showing clearly the code being executed, the outputs from all receiving media such as the computer, the cell phone, etc., professional and clear voice narration. You can post it on a YouTube and share the link if you want to do so. _____ / 20 TOTAL 100% That’s all for this lab. Hopefully you found it useful and increase your interest in the Python world! See you in Lab 3. 28
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Laboratory Hand-In Requirements Once you have completed a working design, prepare for the submission process. Turn in your archive to Canvas along with a narrated video capturing the screen of your computer and your phone running your program demonstration. You are also required to submit an archive of your project in the form of a ZIP file. Use 7-Zip option to create the ZIP file. Name the archive lab#_yourlastname_yourfirstname.zip . Refer to Lab 1 for detail instructions. You will submit your zip file to the instructor through Canvas by the due date and time. If the class will be on campus, then you will expect to demonstrate in the classroom. If we ever have to go back to an online mode, turn in your archive to Canvas along with a narrated video capturing the screen of your computer running your program demonstration. If your program is not completely functional by the due date, you should demonstrate and turn in what you have accomplished to receive partial credit. See the syllabus for the late penalty guideline 29
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help