Skip to content

Commit

Permalink
Use full path for commands
Browse files Browse the repository at this point in the history
Update pypi-publish workflow
Fix linting and update runbook
  • Loading branch information
dormant-user committed Aug 23, 2024
1 parent ee9e308 commit 6f81cb6
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 45 deletions.
62 changes: 35 additions & 27 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
# This workflow will upload a Python Package using Twine when a release is created

name: pypi-publish

# Controls when the workflow will run
on:
workflow_dispatch: {}
release:
types: [ published ]
types:
- published
push:
branches:
- main
paths:
- '**/*.py'
- 'pyproject.toml'
workflow_dispatch:
inputs:
dry_run:
type: choice
description: Dry run mode
required: true
options:
- "true"
- "false"

jobs:
deploy:

runs-on: ubuntu-latest

pypi-publisher:
runs-on: thevickypedia-lite
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Create packages
run: python -m build
- name: Run twine check
run: twine check dist/*
- name: Upload to pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USER }}
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload dist/*.whl
- name: Set dry-run
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "::notice title=DryRun::Setting dry run to ${{ inputs.dry_run }} for '${{ github.event_name }}' event"
echo "dry_run=${{ inputs.dry_run }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "push" ]]; then
echo "::notice title=DryRun::Setting dry run to true for '${{ github.event_name }}' event"
echo "dry_run=true" >> $GITHUB_ENV
else
echo "::notice title=DryRun::Setting dry run to false for '${{ github.event_name }}' event"
echo "dry_run=false" >> $GITHUB_ENV
fi
- uses: thevickypedia/pypi-publisher@v3
with:
token: ${{ secrets.PYPI_TOKEN }}
dry-run: ${{ env.dry_run }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__/
.env
.idea
venv
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fail_fast: true
repos:
-
repo: https://github.com/PyCQA/flake8
Expand Down
19 changes: 18 additions & 1 deletion docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1 id="index">Index</h1>
| <a href="#G"><strong>G</strong></a>
| <a href="#L"><strong>L</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#W"><strong>W</strong></a>
Expand All @@ -55,10 +56,12 @@ <h1 id="index">Index</h1>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pywifi.control_connection.ControlConnection">ControlConnection (class in pywifi.control_connection)</a>
<li><a href="index.html#pywifi.model.Commands">Commands (class in pywifi.model)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pywifi.control_connection.ControlConnection">ControlConnection (class in pywifi.control_connection)</a>
</li>
<li><a href="index.html#pywifi.control_peripheral.ControlPeripheral">ControlPeripheral (class in pywifi.control_peripheral)</a>
</li>
</ul></td>
Expand Down Expand Up @@ -127,6 +130,20 @@ <h2 id="M">M</h2>
</ul></td>
</tr></table>

<h2 id="N">N</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pywifi.model.Commands.netsh">netsh (pywifi.model.Commands attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#pywifi.model.Commands.networksetup">networksetup (pywifi.model.Commands attribute)</a>
</li>
<li><a href="index.html#pywifi.model.Commands.nmcli">nmcli (pywifi.model.Commands attribute)</a>
</li>
</ul></td>
</tr></table>

<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
Expand Down
24 changes: 24 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,30 @@ <h1>Welcome to PyWiFi Controls’s documentation!<a class="headerlink" href="#we
</dl>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="pywifi.model.Commands">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pywifi.model.</span></span><span class="sig-name descname"><span class="pre">Commands</span></span><a class="headerlink" href="#pywifi.model.Commands" title="Permalink to this definition"></a></dt>
<dd><p>Wrapper for OS specific commands.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">Commands</span>
</pre></div>
</div>
<dl class="py attribute">
<dt class="sig sig-object py" id="pywifi.model.Commands.nmcli">
<span class="sig-name descname"><span class="pre">nmcli</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'/usr/bin/nmcli'</span></em><a class="headerlink" href="#pywifi.model.Commands.nmcli" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pywifi.model.Commands.networksetup">
<span class="sig-name descname"><span class="pre">networksetup</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'/usr/sbin/networksetup'</span></em><a class="headerlink" href="#pywifi.model.Commands.networksetup" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pywifi.model.Commands.netsh">
<span class="sig-name descname"><span class="pre">netsh</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">'C:\\Windows\\System32\\netsh.exe'</span></em><a class="headerlink" href="#pywifi.model.Commands.netsh" title="Permalink to this definition"></a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="pywifi.model.Settings">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">pywifi.model.</span></span><span class="sig-name descname"><span class="pre">Settings</span></span><a class="headerlink" href="#pywifi.model.Settings" title="Permalink to this definition"></a></dt>
Expand Down
6 changes: 2 additions & 4 deletions docs/objects.inv
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
# Project: PyWiFi Controls
# Version:
# The remainder of this file is compressed using zlib.
xڵ��n�0 ��<E��
Z��M]'�P ��Q\��( j��5�z{�*L�N�?ƶ��|�#&�j)���,�HT5/dZ
τc
�(��x������:��>�И�ƐYv#%J��s�r�nL��ezWp,�c��)�8T�� ���uh�r�Tܾ<Gmg.Ю[�s�nyRn���O_����B��8�9,#[��q�N0�{G����V�q'kЮDl�P�p���jң5X�13����+-����M},_^WKbl:O%#��H�A�j��x�vo� ��7��n]#N�E����Zl/c����m�N�|~�ehi��!p�QSUa��+�5}���Y\���Pm�j��>�5k�� ���
xڵ�Mn�0����U�5��4�����E��1�j��6"�z�^�'���@����U��{�<㙼*��L�QRD��.���<�q!�<�1��d����'�{�1o�p�ŀ�՚����� ����i�jB�Ie|Wp,��ck�=�x'�j B(���erP<OAQ1~x�.\8�]6<�(���\ӭvͽ�S'�N�q�pnY&�����k��� ��nEw��
t�v eFlU#��b����P ��.j�����g)էS��2&����\|�\IZG���/��|y]-�6�<���3�*���Ն�q�}b�%���� ���e]�y���A�b{�&3 F�H;����[k(2@C�����?=���t�F�u���n�5P�ҡ�՜g��C��� �G1
Expand Down
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.

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.7"
version = "0.8-a"
7 changes: 4 additions & 3 deletions pywifi/control_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def darwin_connector(self) -> bool:

def linux_connector(self) -> bool:
"""Connects to Wi-Fi using SSID and password in env vars for Linux."""
cmd = f"nmcli d wifi connect '{self.wifi_ssid}' password '{self.wifi_password}'"
cmd = f"{settings.nmcli} d wifi connect '{self.wifi_ssid}' password '{self.wifi_password}'"
try:
result = subprocess.check_output(cmd, shell=True)
except ERRORS as error:
Expand All @@ -90,7 +90,8 @@ def linux_connector(self) -> bool:
def win_connector(self) -> bool:
"""Connects to Wi-Fi using SSID and password in env vars for Windows."""
self.logger.info(f'Connecting to {self.wifi_ssid} in WiFi range')
command = "netsh wlan connect name=\"" + self.wifi_ssid + "\" ssid=\"" + self.wifi_ssid + \
command = f"{settings.netsh} wlan connect name=\"" + self.wifi_ssid + \
"\" ssid=\"" + self.wifi_ssid + \
"\" interface=Wi-Fi"
try:
output = subprocess.check_output(command, shell=True)
Expand All @@ -109,7 +110,7 @@ def win_create_new_connection(self) -> bool:
"""Establish a new connection using a xml config for Windows."""
import jinja2 # windows specific
self.logger.info(f"Establishing a new connection to {self.wifi_ssid}")
command = "netsh wlan add profile filename=\"" + self.wifi_ssid + ".xml\"" + " interface=Wi-Fi"
command = f"{settings.netsh} wlan add profile filename=\"" + self.wifi_ssid + ".xml\"" + " interface=Wi-Fi"
rendered = jinja2.Template(settings.win_wifi_xml).render(WIFI_SSID=self.wifi_ssid,
WIFI_PASSWORD=self.wifi_password)
with open(f'{self.wifi_ssid}.xml', 'w') as file:
Expand Down
Loading

0 comments on commit 6f81cb6

Please sign in to comment.