From 3e81ab82429e380675c7ba1b83d594369ebb807e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rgen=20Krau=C3=9F?= Date: Thu, 11 Jul 2024 11:16:26 +0200 Subject: [PATCH] fixing environmental vars --- job-api/job_fetcher.py | 19 ++++++++++++------- job-api/main.py | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/job-api/job_fetcher.py b/job-api/job_fetcher.py index ff9c803..c30b571 100644 --- a/job-api/job_fetcher.py +++ b/job-api/job_fetcher.py @@ -3,11 +3,19 @@ from pathlib import Path class JobFetcher: + client_id:str|None + password:str|None + api_path:str|None + base_url:str|None = "https://api.softgarden.io" + def __init__(self, csv_path = None, client_id = None, password = None, api_path = None): - self.client_id = client_id # os.getenv("CLIENT_ID") - self.password = password # os.getenv("PASSWORD") - self.api_path = api_path # os.getenv("API_PATH") - self.base_url = "https://api.softgarden.io" + self.client_id = client_id + self.password = password + self.api_path = api_path + + if not all([self.client_id, self.password, self.api_path, self.base_url]): + raise ValueError('Check your .env variables!') + self.job_or_trainee_mappings = { "2": "Auszubildendenstelle", "6": "Festanstellung", @@ -26,9 +34,6 @@ def __init__(self, csv_path = None, client_id = None, password = None, api_path "1b4f51fe628c4119a2d7a581557d0944": "mit Berufserfahrung" } - if not all([self.client_id, self.password, self.api_path]): - raise ValueError('Check your .env variables!') - if csv_path is None: p = Path(__file__).parent.resolve() csv_path = p / "jobs.csv" diff --git a/job-api/main.py b/job-api/main.py index a38c2f1..dee2deb 100644 --- a/job-api/main.py +++ b/job-api/main.py @@ -12,9 +12,9 @@ p = Path(__file__).parent.resolve() jf = job_fetcher.JobFetcher( p / "jobs.csv", - os.getenv("CLIENT_ID"), - os.getenv("PASSWORD"), - os.getenv("API_PATH") + os.environ.get("CLIENT_ID"), + os.environ.get("PASSWORD"), + os.environ.get("API_PATH") ) converter = markdown_converter.JobMarkdownConverter(p / "jobs.csv") ftp = ftp_uploader.FTPUploader(