Commit 37d20e3e authored by Grant, Josh's avatar Grant, Josh
Browse files

updates

parent 2829e190
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"

[packages]
common-package = {editable = true, path = "./src"}
common-package = {editable = true, path = "./src", extras = ["dev", "minio"]}
twine = "*"

[dev-packages]
@@ -15,6 +15,7 @@ flake8 = "*"
pylint = "*"
tox = "*"
twine = "*"
moto = {extras = ["all"], version = "*"}

[scripts]
lint = "tox -e lint"
+859 −277

File changed.

Preview size limit exceeded, changes collapsed.

+35 −0
Original line number Diff line number Diff line
"""Provides a Minio Mixin"""


from minio import Minio
from minio.error import S3Error

from common.env import check_environment as ce
from common.logz import create_logger


class MinioMixin:
    def __init__(self):
        self.minio = self.get_minio_client()
        self.bucket_name = ce("MINIO_BUCKET_NAME")
        self.logger = create_logger()

    @staticmethod
    def get_minio_client():
        return Minio(
            endpoint=ce('MINIO_ENDPOINT'),
            access_key=ce('MINIO_ACCESS_KEY'),
            secret_key=ce("MINIO_SECRET_KEY"),
        )

    def upload_file(self, file_path: str, object_name: str):
        try:
            self.minio.fput_object(self.bucket_name, object_name, file_path)
        except S3Error as exc:
            self.logger.info(f"Error uploading file to Minio: {exc}")

    def retrieve_file(self, object_name: str, file_path: str):
        try:
            self.minio.fget_object(self.bucket_name, object_name, file_path)
        except S3Error as exc:
            self.logger.info(f"Error retrieving file from Minio: {exc}")
 No newline at end of file
+11 −1
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ scrapers = [
    "beautifulsoup4~=4.10.0",
    "websocket~=0.2.1"
]
minio = [
    "minio~=7.1.0"
]
all = [
    "psycopg2-binary==2.9.9",
    "pymssql==2.2.11",
@@ -67,7 +70,14 @@ all = [
    "beautifulsoup4~=4.10.0",
    "websocket~=0.2.1",
    "ldap3==2.9.1",
    "flask>=2.0.2"
    "flask>=2.0.2",
    "minio~=7.1.0",
]
dev = [
    "ruff==0.5.4",
    "pytest==8.3.1",
    "pytest-cov==5.0.0",
    "moto==5.0.11",
]


tests/data/test.txt

0 → 100644
+1 −0
Original line number Diff line number Diff line
content
 No newline at end of file
Loading