From baff7687abae5a7b92e230230e7a2060dfe2c192 Mon Sep 17 00:00:00 2001 From: thevickypedia Date: Sat, 11 Feb 2023 21:21:50 -0600 Subject: [PATCH] Support `.env` file to load env vars --- README.md | 6 ++++++ docs/README.html | 20 +++++++++++++------- docs/_sources/README.md.txt | 20 +++++++++++++------- docs/searchindex.js | 2 +- pyproject.toml | 4 ++-- pywifi/__init__.py | 2 +- pywifi/model.py | 5 +++++ release_notes.rst | 4 ++++ 8 files changed, 45 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 77e2e63..1536c2a 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,16 @@ ControlPeripheral().disable() # Turn off Wi-Fi ```python from pywifi import ControlConnection +# Arguments passed during object instantiation +controller = ControlConnection(wifi_ssid='ssid', wifi_password='password') +controller.wifi_connector() + +# Argument values taken from env vars ControlConnection().wifi_connector() ``` ### Arguments +Environment variables are loaded from a `.env` file. - **wifi_ssid** - SSID of the Wi-Fi connection. - **wifi_password** - Password for the Wi-Fi connection. diff --git a/docs/README.html b/docs/README.html index 192c32d..a29a80c 100644 --- a/docs/README.html +++ b/docs/README.html @@ -45,14 +45,14 @@

Navigation

Platform Supported

Generic badge

Deployments

-

pages-build-deployment -pypi-publish

+

pages-build-deployment +pypi-publish

PyWiFi-controls

Python module to control WiFi on Linux, Windows and macOS

Installation

-
python -m pip install pynotification
+
python -m pip install pywifi-controls
 
@@ -68,19 +68,25 @@

Usage

Connect to a Wi-Fi SSID

from pywifi import ControlConnection
 
+# Arguments passed during object instantiation
+controller = ControlConnection(wifi_ssid='ssid', wifi_password='password')
+controller.wifi_connector()
+
+# Argument values taken from env vars
 ControlConnection().wifi_connector()
 

Arguments

+

Environment variables are loaded from a .env file.

-

Release Notes

+

Release Notes

Requirement

python -m pip install changelog-generator
 
@@ -105,17 +111,17 @@

Linting

Pypi Package

pypi-module

-

https://pypi.org/project/pynotification/

+

https://pypi.org/project/pywifi-controls/

Runbook

made-with-sphinx-doc

-

https://thevickypedia.github.io/pynotification/

+

https://thevickypedia.github.io/pywifi-controls/

diff --git a/docs/_sources/README.md.txt b/docs/_sources/README.md.txt index 02abc8f..1536c2a 100644 --- a/docs/_sources/README.md.txt +++ b/docs/_sources/README.md.txt @@ -4,15 +4,15 @@ **Deployments** -[![pages-build-deployment](https://github.com/thevickypedia/pynotification/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/thevickypedia/pynotification/actions/workflows/pages/pages-build-deployment) -[![pypi-publish](https://github.com/thevickypedia/pynotification/actions/workflows/python-publish.yml/badge.svg)](https://github.com/thevickypedia/pynotification/actions/workflows/python-publish.yml) +[![pages-build-deployment](https://github.com/thevickypedia/pywifi-controls/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/thevickypedia/pywifi-controls/actions/workflows/pages/pages-build-deployment) +[![pypi-publish](https://github.com/thevickypedia/pywifi-controls/actions/workflows/python-publish.yml/badge.svg)](https://github.com/thevickypedia/pywifi-controls/actions/workflows/python-publish.yml) # PyWiFi-controls Python module to control `WiFi` on Linux, Windows and macOS ### Installation ```shell -python -m pip install pynotification +python -m pip install pywifi-controls ``` ### Usage @@ -28,14 +28,20 @@ ControlPeripheral().disable() # Turn off Wi-Fi ```python from pywifi import ControlConnection +# Arguments passed during object instantiation +controller = ControlConnection(wifi_ssid='ssid', wifi_password='password') +controller.wifi_connector() + +# Argument values taken from env vars ControlConnection().wifi_connector() ``` ### Arguments +Environment variables are loaded from a `.env` file. - **wifi_ssid** - SSID of the Wi-Fi connection. - **wifi_password** - Password for the Wi-Fi connection. -## [Release Notes](https://github.com/thevickypedia/pynotification/blob/main/release_notes.rst) +## [Release Notes](https://github.com/thevickypedia/pywifi-controls/blob/main/release_notes.rst) **Requirement** ```shell python -m pip install changelog-generator @@ -62,15 +68,15 @@ pre-commit run --all-files ## Pypi Package [![pypi-module](https://img.shields.io/badge/Software%20Repository-pypi-1f425f.svg)](https://packaging.python.org/tutorials/packaging-projects/) -[https://pypi.org/project/pynotification/](https://pypi.org/project/pynotification/) +[https://pypi.org/project/pywifi-controls/](https://pypi.org/project/pywifi-controls/) ## Runbook [![made-with-sphinx-doc](https://img.shields.io/badge/Code%20Docs-Sphinx-1f425f.svg)](https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html) -[https://thevickypedia.github.io/pynotification/](https://thevickypedia.github.io/pynotification/) +[https://thevickypedia.github.io/pywifi-controls/](https://thevickypedia.github.io/pywifi-controls/) ## License & copyright © Vignesh Rao -Licensed under the [MIT License](https://github.com/thevickypedia/pynotification/blob/main/LICENSE) +Licensed under the [MIT License](https://github.com/thevickypedia/pywifi-controls/blob/main/LICENSE) diff --git a/docs/searchindex.js b/docs/searchindex.js index a4c6510..b773f9a 100644 --- a/docs/searchindex.js +++ b/docs/searchindex.js @@ -1 +1 @@ -Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyWiFi-controls", "Welcome to PyWiFi Controls\u2019s documentation!"], "terms": {"platform": 0, "support": 0, "deploy": 0, "python": 0, "modul": 0, "wifi": 0, "linux": [0, 1], "window": [0, 1], "maco": [0, 1], "m": 0, "pip": 0, "pynotif": 0, "enabl": [0, 1], "disabl": [0, 1], "wi": [0, 1], "fi": [0, 1], "from": 0, "import": 0, "controlperipher": [0, 1], "turn": 0, "off": [0, 1], "connect": 0, "ssid": [0, 1], "controlconnect": [0, 1], "wifi_connector": [0, 1], "_": 0, "password": [0, 1], "requir": [0, 1], "changelog": 0, "gener": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": 0, "precommit": 0, "ensur": 0, "doc": 0, "creation": 0, "ar": 0, "run": 0, "everi": 0, "commit": 0, "sphinx": 0, "5": 0, "1": 0, "pre": 0, "recommonmark": 0, "all": [0, 1], "file": 0, "http": 0, "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "instal": 1, "usag": 1, "argument": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "disconnect": 1, "class": 1, "control_connect": 1, "wifi_ssid": 1, "option": 1, "str": 1, "none": 1, "wifi_password": 1, "logger": 1, "wrapper": 1, "instanti": 1, "object": 1, "paramet": 1, "bring": 1, "your": 1, "own": 1, "darwin_connector": 1, "bool": 1, "us": 1, "env": 1, "var": 1, "linux_connector": 1, "win_connector": 1, "win_create_new_connect": 1, "establish": 1, "new": 1, "xml": 1, "config": 1, "store": 1, "o": 1, "agnost": 1, "toggl": 1, "control_peripher": 1, "get_connection_info": 1, "target": 1, "get": 1, "inform": 1, "about": 1, "network": 1, "return": 1, "ethernet": 1, "name": 1, "type": 1, "initi": 1, "take": 1, "darwin_en": 1, "noreturn": 1, "darwin_dis": 1, "linux_en": 1, "linux_dis": 1, "win_en": 1, "win_dis": 1, "model": 1, "process_err": 1, "error": 1, "union": 1, "calledprocesserror": 1, "subprocesserror": 1, "log": 1, "along": 1, "code": 1, "output": 1, "base": 1, "ani": 1, "one": 1, "multipl": 1, "subprocess": 1, "decod": 1, "version": 1, "messag": 1, "an": 1, "empti": 1, "string": 1, "set": 1, "load": 1, "arg": 1, "index": 1, "search": 1, "page": 1}, "objects": {"pywifi": [[1, 0, 0, "-", "control_connection"], [1, 0, 0, "-", "control_peripheral"], [1, 0, 0, "-", "model"]], "pywifi.control_connection": [[1, 1, 1, "", "ControlConnection"]], "pywifi.control_connection.ControlConnection": [[1, 2, 1, "", "darwin_connector"], [1, 2, 1, "", "linux_connector"], [1, 2, 1, "", "wifi_connector"], [1, 2, 1, "", "win_connector"], [1, 2, 1, "", "win_create_new_connection"]], "pywifi.control_peripheral": [[1, 1, 1, "", "ControlPeripheral"], [1, 3, 1, "", "get_connection_info"]], "pywifi.control_peripheral.ControlPeripheral": [[1, 2, 1, "", "darwin_disable"], [1, 2, 1, "", "darwin_enable"], [1, 2, 1, "", "disable"], [1, 2, 1, "", "enable"], [1, 2, 1, "", "linux_disable"], [1, 2, 1, "", "linux_enable"], [1, 2, 1, "", "win_disable"], [1, 2, 1, "", "win_enable"]], "pywifi.model": [[1, 1, 1, "", "Settings"], [1, 3, 1, "", "process_err"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method", "3": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"], "3": ["py", "function", "Python function"]}, "titleterms": {"pywifi": [0, 1], "control": [0, 1], "instal": 0, "usag": 0, "argument": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "read": 1, "me": 1, "connect": 1, "peripher": 1, "modul": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file +Search.setIndex({"docnames": ["README", "index"], "filenames": ["README.md", "index.rst"], "titles": ["PyWiFi-controls", "Welcome to PyWiFi Controls\u2019s documentation!"], "terms": {"platform": 0, "support": 0, "deploy": 0, "python": 0, "modul": 0, "wifi": 0, "linux": [0, 1], "window": [0, 1], "maco": [0, 1], "m": 0, "pip": 0, "enabl": [0, 1], "disabl": [0, 1], "wi": [0, 1], "fi": [0, 1], "from": 0, "import": 0, "controlperipher": [0, 1], "turn": 0, "off": [0, 1], "connect": 0, "ssid": [0, 1], "controlconnect": [0, 1], "pass": 0, "dure": 0, "object": [0, 1], "instanti": [0, 1], "wifi_ssid": [0, 1], "wifi_password": [0, 1], "password": [0, 1], "wifi_connector": [0, 1], "valu": 0, "taken": 0, "env": [0, 1], "var": [0, 1], "environ": 0, "variabl": 0, "ar": 0, "load": [0, 1], "file": 0, "_": 0, "requir": [0, 1], "changelog": 0, "gener": 0, "revers": 0, "f": 0, "release_not": 0, "rst": 0, "t": 0, "precommit": 0, "ensur": 0, "doc": 0, "creation": 0, "run": 0, "everi": 0, "commit": 0, "sphinx": 0, "5": 0, "1": 0, "pre": 0, "recommonmark": 0, "all": [0, 1], "http": 0, "org": 0, "project": 0, "thevickypedia": 0, "github": 0, "io": 0, "vignesh": 0, "rao": 0, "under": 0, "mit": 0, "instal": 1, "usag": 1, "argument": 1, "releas": 1, "note": 1, "lint": 1, "pypi": 1, "packag": 1, "runbook": 1, "licens": 1, "copyright": 1, "disconnect": 1, "class": 1, "control_connect": 1, "option": 1, "str": 1, "none": 1, "logger": 1, "wrapper": 1, "paramet": 1, "bring": 1, "your": 1, "own": 1, "darwin_connector": 1, "bool": 1, "us": 1, "linux_connector": 1, "win_connector": 1, "win_create_new_connect": 1, "establish": 1, "new": 1, "xml": 1, "config": 1, "store": 1, "o": 1, "agnost": 1, "toggl": 1, "control_peripher": 1, "get_connection_info": 1, "target": 1, "get": 1, "inform": 1, "about": 1, "network": 1, "return": 1, "ethernet": 1, "name": 1, "type": 1, "initi": 1, "take": 1, "darwin_en": 1, "noreturn": 1, "darwin_dis": 1, "linux_en": 1, "linux_dis": 1, "win_en": 1, "win_dis": 1, "model": 1, "process_err": 1, "error": 1, "union": 1, "calledprocesserror": 1, "subprocesserror": 1, "log": 1, "along": 1, "code": 1, "output": 1, "base": 1, "ani": 1, "one": 1, "multipl": 1, "subprocess": 1, "decod": 1, "version": 1, "messag": 1, "an": 1, "empti": 1, "string": 1, "set": 1, "arg": 1, "index": 1, "search": 1, "page": 1}, "objects": {"pywifi": [[1, 0, 0, "-", "control_connection"], [1, 0, 0, "-", "control_peripheral"], [1, 0, 0, "-", "model"]], "pywifi.control_connection": [[1, 1, 1, "", "ControlConnection"]], "pywifi.control_connection.ControlConnection": [[1, 2, 1, "", "darwin_connector"], [1, 2, 1, "", "linux_connector"], [1, 2, 1, "", "wifi_connector"], [1, 2, 1, "", "win_connector"], [1, 2, 1, "", "win_create_new_connection"]], "pywifi.control_peripheral": [[1, 1, 1, "", "ControlPeripheral"], [1, 3, 1, "", "get_connection_info"]], "pywifi.control_peripheral.ControlPeripheral": [[1, 2, 1, "", "darwin_disable"], [1, 2, 1, "", "darwin_enable"], [1, 2, 1, "", "disable"], [1, 2, 1, "", "enable"], [1, 2, 1, "", "linux_disable"], [1, 2, 1, "", "linux_enable"], [1, 2, 1, "", "win_disable"], [1, 2, 1, "", "win_enable"]], "pywifi.model": [[1, 1, 1, "", "Settings"], [1, 3, 1, "", "process_err"]]}, "objtypes": {"0": "py:module", "1": "py:class", "2": "py:method", "3": "py:function"}, "objnames": {"0": ["py", "module", "Python module"], "1": ["py", "class", "Python class"], "2": ["py", "method", "Python method"], "3": ["py", "function", "Python function"]}, "titleterms": {"pywifi": [0, 1], "control": [0, 1], "instal": 0, "usag": 0, "argument": 0, "releas": 0, "note": 0, "lint": 0, "pypi": 0, "packag": 0, "runbook": 0, "licens": 0, "copyright": 0, "welcom": 1, "": 1, "document": 1, "read": 1, "me": 1, "connect": 1, "peripher": 1, "modul": 1, "indic": 1, "tabl": 1}, "envversion": {"sphinx.domains.c": 2, "sphinx.domains.changeset": 1, "sphinx.domains.citation": 1, "sphinx.domains.cpp": 6, "sphinx.domains.index": 1, "sphinx.domains.javascript": 2, "sphinx.domains.math": 2, "sphinx.domains.python": 3, "sphinx.domains.rst": 2, "sphinx.domains.std": 2, "sphinx": 56}}) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 30f1fa7..1c85ec6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ keywords = ["pywifi", "display-settings", "brightness-control"] requires-python = ">=3" dependencies = [ - "Jinja2==3.1.2", "pyobjc; platform_system=='Darwin'" + "python-dotenv>=0.21.0", "Jinja2==3.1.2", "pyobjc; platform_system=='Darwin'" ] [tool.setuptools] @@ -27,7 +27,7 @@ packages = ["pywifi"] version = {attr = "pywifi.version"} [build-system] -requires = ["setuptools", "wheel", "Jinja2==3.1.2"] +requires = ["setuptools", "wheel", "Jinja2==3.1.2", "python-dotenv>=0.21.0"] build-backend = "setuptools.build_meta" [project.optional-dependencies] diff --git a/pywifi/__init__.py b/pywifi/__init__.py index 85067f8..a20f170 100644 --- a/pywifi/__init__.py +++ b/pywifi/__init__.py @@ -3,4 +3,4 @@ from .control_connection import ControlConnection # noqa: F401 from .control_peripheral import ControlPeripheral # noqa: F401 -version = "0.0.4" +version = "0.0.5" diff --git a/pywifi/model.py b/pywifi/model.py index f0b7374..01c1b76 100644 --- a/pywifi/model.py +++ b/pywifi/model.py @@ -4,6 +4,11 @@ import subprocess from typing import Tuple, Union +import dotenv + +if os.path.isfile(".env"): + dotenv.load_dotenv(dotenv_path=".env") + ERRORS: Tuple = (subprocess.CalledProcessError, subprocess.SubprocessError, FileNotFoundError,) diff --git a/release_notes.rst b/release_notes.rst index 02035c6..ed4e7f6 100644 --- a/release_notes.rst +++ b/release_notes.rst @@ -1,6 +1,10 @@ Release Notes ============= +0.0.5 (02/11/2023) +------------------ +- Support `.env` file to load env vars + 0.0.4 (02/11/2023) ------------------ - Onboard a stable release version