Skip to content

new_hire is a Python 3 script and set of functions that intergrates with the Hutch's Toolbox system

License

Notifications You must be signed in to change notification settings

Chilliwack/new_hire_part_deux

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

new_hire

new_hire is a Python 3 script and set of functions that intergrates with the Hutch's Toolbox system to make it easier to identify new users for additional support.

Installation

  1. Download or copy the new_hire repo
  2. Locate the new_hire.py script and set it up to run as a weekly CRON job
  3. Below discusses some of it's default parameters.

By default it is setup to retrieve the new users from Toolbox that have been added since the last time it ran. The "last time it ran" defaults to 7 days before it's current runtime. Therefore, if set up as a weekly CRON job it'll always be looking for new users over a 7-day timespan.

  1. The script also ingests a config.txt file that is in the same directory as the script and contains a dictionary of key/values you can use to set key variables in the script such as.
"test_filepath": FILEPATH TO TEST FILE,
"send_from": SEND FROM EMAIL ADDRESS,
"subject": “EMAIL SUBJECT LINE,
"message": EMAIL MESSAGE,
"test_send_to": SEND TO TEST ADDRESS}
  1. The script must also be executed behind the firewall

Overview

This script interacts with Toolbox and more information on what Toolbox is can be found here.

The new_hire.py script utilizes the following functions to query, filter, and extract data from Toolbox. It then compiles an email and sends an email based on the retrieved data to certain users.

  • get_employees() - takes a Toolbox csv filepath, retrieves and prunes it, and exports it as a dataframe

  • new_hires() - take a dataframe and filters it based on date i.e. supplied last_runtime

  • hires_by_deptID() and hires_by_jobTitle() - queries a dataframe and returns rows. Currently these are coded to query for certain deptIDs and jobTitles specified by project sponsors but they can be easily altered.

  • send_mail() - compiles and sends the emails with the desired data

  • run_process() - runs the whole process and has a test parameter currently defaulted to True which sets up an environment to test/debug. You can start a local SMTP debugging server by typing the following in shell python -m smtpd -c DebuggingServer -n localhost:1025 and set server to localhost in the send_mail()

The script is designed to run weekly, grabbing the latest data from Toolbox, then querying, filtering, and extracting the data requested. Based on that data it compiles and sends electronic communications. The output of the script is successful sends of electionic communications with the required data so no file or data is exported. There is a log file which shows script start time, end time, toolbox output for each run, as well as any errors from toolbox functionality or email.

About

new_hire is a Python 3 script and set of functions that intergrates with the Hutch's Toolbox system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages