RTG-Datauploader

Script for uploading files to AWS S3 Bucket

Prerequisites

Installation

Linux

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Windows

python -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt

on newer systems, python is replaced by py if you already have python installed.

py -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt

Making an executable

It's tricky installing the requirements for each machine and running it. for scenarios where we just want to run it, we'll use pyinstaller. This library creates an executable on the platform you're using (e.g. Windows to windows, MacOS to MacOs).

Windows

  1. Do the initial installation above
  2. Install pyinstaller: pip install pyinstaller
  3. Run pyinstaller {flags} --hidden-import=configparser upload-to-s3.py
    1. Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
      1. --onedir if you want the resulting executable to be under a folder with the executable inside. Dependencies it needs are not bundled inside the executable file.
      2. --onefile if you want everything bundled into the resulting executable file
    2. for python 3.10 or if the result of command shows ImportError: No module named _bootlocale: include the following flag --exclude-module _bootlocale
  4. Upon completion, the resulting executable should be inside a dist folder generated by pyinstaller.

Usage

Non executable

python upload-to-s3.py --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY

Executable (windows)

 /path/to/upload-to-s3.exe --source /path/to/file --bucket aws-bucket-name --access-key=AWSACCESSKEYID --secret-key=SECRETKEY