mirror of https://github.com/Bunsly/JobSpy
fixed env
parent
3c091b846d
commit
8657f7cacf
|
@ -1,25 +1,16 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic import Field
|
||||||
|
from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
if not os.getenv("ENV"):
|
if not os.environ.get("ENV"):
|
||||||
raise ValueError("Invalid environment. Set the 'ENV' variable (e.g., export ENV=dev).")
|
raise ValueError("Invalid environment. Set the 'ENV' variable (e.g., export ENV=dev).")
|
||||||
|
|
||||||
dotenv_file = os.path.join(os.path.dirname(__file__), ".env." + os.environ.get("ENV"))
|
|
||||||
|
|
||||||
if not os.path.exists(dotenv_file):
|
|
||||||
raise FileNotFoundError(f"Environment file not found: {dotenv_file}")
|
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
env: str
|
telegram_api_token: str = Field(alias="telegram_api_token")
|
||||||
telegram_api_token: str
|
mongo_uri: str = Field(alias="mongo_uri")
|
||||||
mongo_uri: str
|
mongo_db_name: str = Field(alias="mongo_db_name")
|
||||||
mongo_db_name: str
|
|
||||||
print(f"Loading environment from: {dotenv_file}")
|
|
||||||
model_config = SettingsConfigDict(
|
|
||||||
env_file=dotenv_file
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
|
Loading…
Reference in New Issue