bened commited on
Commit
c2f7124
·
verified ·
1 Parent(s): 2583940

Upload config.py

Browse files
Files changed (1) hide show
  1. config.py +45 -0
config.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) 2025 Stephen G. Pope
2
+ #
3
+ # This program is free software; you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation; either version 2 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License along
14
+ # with this program; if not, write to the Free Software Foundation, Inc.,
15
+ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16
+
17
+
18
+
19
+ import os
20
+ import logging
21
+
22
+ # Retrieve the API key from environment variables
23
+ API_KEY = os.environ.get('API_KEY')
24
+ if not API_KEY:
25
+ raise ValueError("API_KEY environment variable is not set")
26
+
27
+ # Storage path setting
28
+ LOCAL_STORAGE_PATH = os.environ.get('LOCAL_STORAGE_PATH', '/tmp')
29
+
30
+ # GCP environment variables
31
+ GCP_SA_CREDENTIALS = os.environ.get('GCP_SA_CREDENTIALS', '')
32
+ GCP_BUCKET_NAME = os.environ.get('GCP_BUCKET_NAME', '')
33
+
34
+ def validate_env_vars(provider):
35
+
36
+ """ Validate the necessary environment variables for the selected storage provider """
37
+ required_vars = {
38
+ 'GCP': ['GCP_BUCKET_NAME', 'GCP_SA_CREDENTIALS'],
39
+ 'S3': ['S3_ENDPOINT_URL', 'S3_ACCESS_KEY', 'S3_SECRET_KEY', 'S3_BUCKET_NAME', 'S3_REGION'],
40
+ 'S3_DO': ['S3_ENDPOINT_URL', 'S3_ACCESS_KEY', 'S3_SECRET_KEY']
41
+ }
42
+
43
+ missing_vars = [var for var in required_vars[provider] if not os.getenv(var)]
44
+ if missing_vars:
45
+ raise ValueError(f"Missing environment variables for {provider} storage: {', '.join(missing_vars)}")