Bladeren bron

support dotenv file

Karl Hudgell 6 maanden geleden
bovenliggende
commit
0ad1f4f8ad
4 gewijzigde bestanden met toevoegingen van 22 en 2 verwijderingen
  1. 1 0
      .gitignore
  2. 5 1
      main.py
  3. 15 1
      poetry.lock
  4. 1 0
      pyproject.toml

+ 1 - 0
.gitignore

@@ -1,2 +1,3 @@
 .vscode/launch.json
 **/*.pyc
+.env

+ 5 - 1
main.py

@@ -1,8 +1,11 @@
 import os
 import sys
 import json
+from dotenv import load_dotenv
 from lib.mqtt import create_client, update_disc, control_player, create_config
 
+load_dotenv()
+
 # Define the MQTT server details
 broker = os.environ.get("broker")
 port = int(os.environ.get("port"))
@@ -30,4 +33,5 @@ else:
     print("No JSON argument passed, running default control_player action.")
     
 # You can still have the default behavior if no JSON is passed
-control_player(client, "EJECT")
+# control_player(client, "EJECT")
+

+ 15 - 1
poetry.lock

@@ -14,7 +14,21 @@ files = [
 [package.extras]
 proxy = ["pysocks"]
 
+[[package]]
+name = "python-dotenv"
+version = "1.0.1"
+description = "Read key-value pairs from a .env file and set them as environment variables"
+optional = false
+python-versions = ">=3.8"
+files = [
+    {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"},
+    {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"},
+]
+
+[package.extras]
+cli = ["click (>=5.0)"]
+
 [metadata]
 lock-version = "2.0"
 python-versions = "^3.8"
-content-hash = "6c033a93847eceeaa0c39046b8cf5ddd3b31e00b768adae8c60d059d3003b2f5"
+content-hash = "a464e018da3c243fd5b889dddee79b9f4d25f520855325f8478224b55eebbbcc"

+ 1 - 0
pyproject.toml

@@ -8,6 +8,7 @@ readme = "README.md"
 [tool.poetry.dependencies]
 python = "^3.8"
 paho-mqtt = "^2.1.0"
+python-dotenv = "^1.0.1"
 
 
 [build-system]