Skip to content

Commit

Permalink
Support .env file to load env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Feb 12, 2023
1 parent 52caa6e commit baff768
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 18 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
20 changes: 13 additions & 7 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ <h3>Navigation</h3>
<p><strong>Platform Supported</strong></p>
<p><img alt="Generic badge" src="https://img.shields.io/badge/Platform-Linux%7CMacOS%7CWindows-1f425f.svg" /></p>
<p><strong>Deployments</strong></p>
<p><a class="reference external" href="https://github.com/thevickypedia/pynotification/actions/workflows/pages/pages-build-deployment"><img alt="pages-build-deployment" src="https://github.com/thevickypedia/pynotification/actions/workflows/pages/pages-build-deployment/badge.svg" /></a>
<a class="reference external" href="https://github.com/thevickypedia/pynotification/actions/workflows/python-publish.yml"><img alt="pypi-publish" src="https://github.com/thevickypedia/pynotification/actions/workflows/python-publish.yml/badge.svg" /></a></p>
<p><a class="reference external" href="https://github.com/thevickypedia/pywifi-controls/actions/workflows/pages/pages-build-deployment"><img alt="pages-build-deployment" src="https://github.com/thevickypedia/pywifi-controls/actions/workflows/pages/pages-build-deployment/badge.svg" /></a>
<a class="reference external" href="https://github.com/thevickypedia/pywifi-controls/actions/workflows/python-publish.yml"><img alt="pypi-publish" src="https://github.com/thevickypedia/pywifi-controls/actions/workflows/python-publish.yml/badge.svg" /></a></p>
<section id="pywifi-controls">
<h1>PyWiFi-controls<a class="headerlink" href="#pywifi-controls" title="Permalink to this heading"></a></h1>
<p>Python module to control <code class="docutils literal notranslate"><span class="pre">WiFi</span></code> on Linux, Windows and macOS</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h2>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>pynotification
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>pywifi-controls
</pre></div>
</div>
</section>
Expand All @@ -68,19 +68,25 @@ <h2>Usage<a class="headerlink" href="#usage" title="Permalink to this heading">
<p><strong>Connect to a Wi-Fi SSID</strong></p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pywifi</span> <span class="kn">import</span> <span class="n">ControlConnection</span>

<span class="c1"># Arguments passed during object instantiation</span>
<span class="n">controller</span> <span class="o">=</span> <span class="n">ControlConnection</span><span class="p">(</span><span class="n">wifi_ssid</span><span class="o">=</span><span class="s1">&#39;ssid&#39;</span><span class="p">,</span> <span class="n">wifi_password</span><span class="o">=</span><span class="s1">&#39;password&#39;</span><span class="p">)</span>
<span class="n">controller</span><span class="o">.</span><span class="n">wifi_connector</span><span class="p">()</span>

<span class="c1"># Argument values taken from env vars</span>
<span class="n">ControlConnection</span><span class="p">()</span><span class="o">.</span><span class="n">wifi_connector</span><span class="p">()</span>
</pre></div>
</div>
</section>
<section id="arguments">
<h2>Arguments<a class="headerlink" href="#arguments" title="Permalink to this heading"></a></h2>
<p>Environment variables are loaded from a <code class="docutils literal notranslate"><span class="pre">.env</span></code> file.</p>
<ul class="simple">
<li><p><strong>wifi_ssid</strong> - SSID of the Wi-Fi connection.</p></li>
<li><p><strong>wifi_password</strong> - Password for the Wi-Fi connection.</p></li>
</ul>
</section>
<section id="release-notes">
<h2><a class="reference external" href="https://github.com/thevickypedia/pynotification/blob/main/release_notes.rst">Release Notes</a><a class="headerlink" href="#release-notes" title="Permalink to this heading"></a></h2>
<h2><a class="reference external" href="https://github.com/thevickypedia/pywifi-controls/blob/main/release_notes.rst">Release Notes</a><a class="headerlink" href="#release-notes" title="Permalink to this heading"></a></h2>
<p><strong>Requirement</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>changelog-generator
</pre></div>
Expand All @@ -105,17 +111,17 @@ <h2>Linting<a class="headerlink" href="#linting" title="Permalink to this headin
<section id="pypi-package">
<h2>Pypi Package<a class="headerlink" href="#pypi-package" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://packaging.python.org/tutorials/packaging-projects/"><img alt="pypi-module" src="https://img.shields.io/badge/Software%20Repository-pypi-1f425f.svg" /></a></p>
<p><a class="reference external" href="https://pypi.org/project/pynotification/">https://pypi.org/project/pynotification/</a></p>
<p><a class="reference external" href="https://pypi.org/project/pywifi-controls/">https://pypi.org/project/pywifi-controls/</a></p>
</section>
<section id="runbook">
<h2>Runbook<a class="headerlink" href="#runbook" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://www.sphinx-doc.org/en/master/man/sphinx-autogen.html"><img alt="made-with-sphinx-doc" src="https://img.shields.io/badge/Code%20Docs-Sphinx-1f425f.svg" /></a></p>
<p><a class="reference external" href="https://thevickypedia.github.io/pynotification/">https://thevickypedia.github.io/pynotification/</a></p>
<p><a class="reference external" href="https://thevickypedia.github.io/pywifi-controls/">https://thevickypedia.github.io/pywifi-controls/</a></p>
</section>
<section id="license-copyright">
<h2>License &amp; copyright<a class="headerlink" href="#license-copyright" title="Permalink to this heading"></a></h2>
<p>© Vignesh Rao</p>
<p>Licensed under the <a class="reference external" href="https://github.com/thevickypedia/pynotification/blob/main/LICENSE">MIT License</a></p>
<p>Licensed under the <a class="reference external" href="https://github.com/thevickypedia/pywifi-controls/blob/main/LICENSE">MIT License</a></p>
</section>
</section>

Expand Down
20 changes: 13 additions & 7 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

&copy; 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)
2 changes: 1 addition & 1 deletion docs/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pywifi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions pywifi/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,)


Expand Down
4 changes: 4 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit baff768

Please sign in to comment.