Skip to main content

Get and email pay slips from PGSS

Project description

Compass Group PGSS Payslip Retriever

This is a Python script that retrieves your pay slips from Compass Group's PGSS website and sends to your email. I wrote this script so I don't have to log onto the stupid site every time I want to get my pay slips. What a stupid way to do things.

I could've just filed an OFI to tell them to just email all the pay slips just like any other normal companies do. Yup, that's gonna work because Compass Group is more than capable of doing that.

Snap image: "Don't do anything that might damage the reputation of Compass Group"

Well, sack me then.

Usage

python3 -m pgssret -f <config>

Where <config> is the path to the yaml configuration file. The sample is located at /docs/configs/sample.yaml.

Setup

Installation

Install the module using PIP.

pip install pgssret

Configuration and Cache Setup

The config format is pretty self-explanatory. I copied and pasted into this doc below for reference.

pgss-ret:
  auth:
    username: USERNAME
    password: PASSWORD
  dir:
    cache: cache
    tmp: tmp
  limits:
    eml-size: 5242880 # 5 MiB
    nb-attachments: 20
  # Initial start up behaviour
  #   0: Attach only one latest pay slip only (recommended)
  #   1: Don't email. Pay slips will be sent on the subsequent launches
  #   2: Email all the pay slips obtainable. A large quantities of pay slips
  #      will be sent in multiple mails
  init-mode: 0
  post:
    subject: Pay Slip from Compass Group
    body: See attached.
    backend: smtplib
    params:
      proto: smtp # or 'smtps' or 'lmtp'
      # from: from@example.com
      # Allow use of unencrypted session. Set to true if using localhost
      # allow-plaintext: false
      # host: smtp.example.com
      # port:
      # tlscert:
      # tlskey:
      # cred: # smtp auth credentials
      #   username:
      #   password:
    recipients:
      # - person@example.com

You won't have to worry about cache and tmp dirs as long as you set the working directory of the process correctly. I recommend preparing following paths for the working directory of the module.

  • Linux
    • ~/.cache/pgssret for tmp and cache
    • ~/.config/pgssret for the config
  • Windows: %appdata%\pgssret for everything

Or you can use arbitrary directories on your machine and set them using absolute paths.

Copy the sample config to a new location. Rename it to pgssret.yaml and edit it. All you will have to change should be the username and password you use to log onto the website. Then test the config by launching the module.

# Linux
cd ~/.cache/pgssret
python3 -m pgssret -f ~/.config/pgssret/pgssret.yaml
# Windows (Powershell or cmd)
cd %appdata%\pgssret
python3 -m pgssret -f %appdata%\pgssret\pgssret.yaml

If you mess up, debug the config and delete the cache file(named as YOUR_EMPLOYEE_NUMBER.json) before relaunching the module. If you manage to get the module to send an email successfully and you've confirmed that the email has reached the inbox, you can move onto setting a scheduled task.

Schedule Module Launch

On Linux, use crond or a Systemd timer to have the module poll your pay slips periodically.

Run crontab -e to edit the user crontab like so.

# To get error reports in the event of failure.
#MAILTO=

# Run pgssret every day at noon. Redirect STDOUT to the null device to get
# reports on errors only.
00 12 *  *  * cd ~/.cache/pgssret && python3 -m pgssret -f ~/.config/pgssret/pgssret.yaml > /dev/null

And make sure crond is running and you're good to go! Forget that you did all this and let your computer get the pay slips for you from now on.

Another options is to make the machine run the module every time it boots up by making a "oneshot" Systemd service or dropping a shell script in rc.d.

On Windows, Task Scheduler can do the trick.

Task Scheduler dialog "General" tab

Task Scheduler dialog "Trigger" tab

Task Scheduler dialog "Action" tab

Task Scheduler dialog "Settings" tab

Gmail Example

If you plan to use an external SMTP rather than a local one and set up a mail filter on your email service[^1], here's the example using Gmail SMTP. You will need to create an App Password for the module.

# ...
    params:
      proto: smtps
      from: you@gmail.com
      host: smtp.gmail.com
      cred:
        username: you@gmail.com
        password: THE_APP_PASSWORD
    recipients:
	  - you@gmail.com

[^1]: which is reasonable considering the fact that SMTP daemon implementations are quite heavy and it's tedious to set up a mail filter so that the mails sent from your local machine are not marked as spam

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgssret-0.0.1.tar.gz (153.6 kB view details)

Uploaded Source

Built Distribution

pgssret-0.0.1-py3-none-any.whl (155.8 kB view details)

Uploaded Python 3

File details

Details for the file pgssret-0.0.1.tar.gz.

File metadata

  • Download URL: pgssret-0.0.1.tar.gz
  • Upload date:
  • Size: 153.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pgssret-0.0.1.tar.gz
Algorithm Hash digest
SHA256 100e13c42a80619acb1a0948648e6127fe65c51610e470aa9ce5cdc3e0bf6467
MD5 c37a5a4dc999e216141d7d7dec08001f
BLAKE2b-256 25a2717541888d0ff9249d2e73aec2f61cabcfd6584e19928206a7d8d707e294

See more details on using hashes here.

File details

Details for the file pgssret-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pgssret-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 155.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for pgssret-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a831c8f19e3c4ce963983ddb762cafb83e645c0e72129b79ca05e5328e28a28
MD5 c2e8bd93bc9ae2d96c20469f224fc9c6
BLAKE2b-256 99240ee52888020992970a97410312ae504673525e253644ec7504455eb3a60a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page