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
- Do the initial installation above
- Install pyinstaller:
pip install pyinstaller
- Run
pyinstaller {flags} --hidden-import=configparser upload-to-s3.py
- Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
--onedir
if you want the resulting executable to be under a folder with the executable inside. Dependencies it needs are not bundled inside theexecutable
file.--onefile
if you want everything bundled into the resultingexecutable
file
- for python 3.10 or if the result of command shows
ImportError: No module named _bootlocale
: include the following flag--exclude-module _bootlocale
- Depending on your choice, add the following flags For further explanation of the flags, refer to the docs here
- 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