Reference

class api.API(env_suffixes=[''])

Class for the SchoolMint API connection.

_post_demand_export(endpoint)

Post request to SchoolMint API. This triggers report generation and upload to FTP associated with the report.

Parameters

api_token (String) – API token for the report.

request_reports()

Demand export for each API token.

class ftp.FTP

Class for the local FTP connection.

_add_hostkeys()

Adds sftp host key to known_hosts to prevent man in the middle attacks. Requires FTP_KEY be included in .env. Key can be acquired using OpenSSH: ssh-keyscan {sftp_url}

_archive_file(file)

Place the file in an ‘archive’ folder within its directory.

Parameters

file (String) – Path and name of the file that will be archived.

_delete_old_file(file)

Find the age limit based on the env variable and delete files older than this limit.

Parameters

file (String) – Path and name of the file

_do_nothing(file)

Used for files and unknown file types.

Parameters

file (String) – Path and name of the file that will be ignored.

archive_remote_files(remotedir)

Archive all of the files in the specified remote directory.

Parameters

remotedir (String) – Path of the remote directory (ie. the FTP directory)

delete_old_archive_files(remotedir)

Delete old files from the archive folder.

Parameters

remotedir (String) – Path of the remote directory (ie. the FTP directory)

download_dir(remotedir, localdir)

Download all files from the remote directory to the local directory.

Parameters
  • remotedir (String) – Path of the remote directory that we are getting files from (ie. the FTP directory)

  • localdir (String) – Path of the local directory that we are saving files to

class mailer.Mailer

Class to send email notifications about the job status.

_body_text()

Generate email body message based on job status.

Returns

Email body with results or error message

Return type

String

_message()

Build the email message body.

Returns

Message text

Return type

MIMEText object

_subject_line()

Return success/error in subject based on job status.

Returns

Job name and success/error status

Return type

String

notify(results=None, success=True, error_message=None)

Send the notification message.

Parameters
  • results (String) – contains the logger messages

  • success (Boolean) – True if the job was successful, False if there was an error

  • error_message (String) – contains stack trace if there is one