GCS File Dependency Monitor is a Python library designed to wait for a specific file to appear in a Google Cloud Storage (GCS) bucket. If the file does not appear within a specified number of tries, it sends warning and error emails to a specified email address.
Features
- Monitors a GCS bucket for the presence of a specific file.
- Supports checking for files with names that include the current date.
- Sends warning emails after a certain number of unsuccessful tries.
- Sends an error email if the file does not appear after the maximum number of tries.
- Supports sending emails with optional attachments.
Requirements
- Python 3.x
- Google Cloud Storage client library
- smtplib for sending emails
Installation Install the package via pip:
pip install gcs-file-dependency-monitor
Dependencies
Make sure to have these installed using:
pip install google-cloud-storage
pip install datetime
Example Usage:
from gcs_file_dependency_monitor import gcs_file_dependency_monitor
gcs_file_dependency_monitor(
dependent_file='path/to/your/file',
dependent_file_bucket='your-bucket-name',
number_of_tries=10,
num_of_tries_before_warn_email=5,
time_interval=60,
warn_email_content='Warning: File not found yet.',
warn_email_subject='File Not Found Warning',
email_address='recipient@example.com',
error_email_content='Error: File not found after maximum tries.',
error_email_subject='File Not Found Error',
SMTP_SERVER='smtp.example.com',
SMTP_PORT=587,
SMTP_USER='your-smtp-user',
SMTP_PASSWORD='your-smtp-password',
dependent_file_name_has_current_date=True
)
Parameters: gcs_file_dependency_monitor This function waits for a specific file to appear in a GCS bucket and sends emails based on the result.
Parameters:
- dependent_file (str): The file to wait for.
- dependent_file_bucket (str): The GCS bucket containing the file.
- number_of_tries (int): The number of attempts to check for the file.
- num_of_tries_before_warn_email (int): The number of tries before sending a warning email.
- time_interval (int): The time interval (in seconds) between attempts.
- warn_email_content (str): The content of the warning email.
- warn_email_subject (str): The subject of the warning email.
- email_address (str): The recipient email address.
- error_email_content (str): The content of the error email.
- error_email_subject (str): The subject of the error email.
- SMTP_SERVER (str): The SMTP server for sending emails.
- SMTP_PORT (int): The port for the SMTP server.
- SMTP_USER (str): The SMTP server user.
- SMTP_PASSWORD (str): The SMTP server password.
- dependent_file_name_has_current_date (bool, optional): Whether the dependent file name includes the current date. Default is False.
Metadata
Release files for Gcs-file-dependency-monitor 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| Gcs_file_dependency_monitor-0.1.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Gcs_file_dependency_monitor-0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / Gcs_file_dependency_monitor-0.1.tar.gz
| Download URL | Gcs_file_dependency_monitor-0.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c94b7edfa7a3c0b6fb530b70d7de43ace87ce0a89374810c35589f4dc233ac9e
|
|
BLAKE2b-256 checksum How to use checksums |
378519e5e7b895cc11f613e8e7ea8586de848599df397febcedbcc166f813818
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / Gcs_file_dependency_monitor-0.1-py3-none-any.whl
| Download URL | Gcs_file_dependency_monitor-0.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fe4e3931755649c9847820f7e725031a098faeef4405bc7984faf04feefc946
|
|
BLAKE2b-256 checksum How to use checksums |
090047ad7bc1b2bb38c12593ae9926ab421d632880d5ade02ad7f8007d8e001e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|