Repository: emibcn/pywisp (language: python)

Issue:
Change project name to something different
There is a popular pyradio project: https://github.com/coderholic/pyradio

So, we could rename ourselves to **PyWisp**, for example.


Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index 89e4d15..1284d62 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ python:
   - "pypy3.5"
 # command to install dependencies
 install:
-  - pip install -r pyradio/requirements.txt
+  - pip install -r pywisp/requirements.txt
   - pip install .
 # command to run tests
 script: pytest
diff --git a/README.md b/README.md
index 9255d47..946e17f 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,21 @@
-[![Build Status](https://travis-ci.com/emibcn/pyradio.svg?branch=master)](https://travis-ci.com/emibcn/pyradio)
+[![Build Status](https://travis-ci.com/emibcn/pywisp.svg?branch=master)](https://travis-ci.com/emibcn/pywisp)
 
 
-# Pyradio installation
-## Install pyradio
+# PyWisp installation
+## Install pywisp
 ```shell
-pip3 install --user git+https://github.com/emibcn/pyradio.git
+pip3 install --user git+https://github.com/emibcn/pywisp.git
 ```
 
-## Configure pyradio
-Then configure as per [~/.pyradio](#pyradio-config-file-pyradio)
+## Configure PyWisp
+Then configure as per [~/.pywisp](#pywisp-config-file-pywisp)
 
 Finally, create the python script which implements the WISP infrastructure and authentication
 mechanisms, as per [wisp.py](#wisp-infrastructure-and-host-authentication-definitions-envhomemywispwisppy)
 
-# Pyradio usage
+# PyWisp usage
 ```
-usage: pyradio [-h] [--conf CONF] {backup_ac,backup_mt,reorder_ac,host} ...
+usage: pywisp [-h] [--conf CONF] {backup_ac,backup_mt,reorder_ac,host} ...
 
 positional arguments:
   {backup_ac,backup_mt,reorder_ac,host}
@@ -27,13 +27,13 @@ positional arguments:
 optional arguments:
   -h, --help            show this help message and exit
   --conf CONF           Reads configuration from this file instead of default
-                        (default: $HOME/.pyradio)
+                        (default: $HOME/.pywisp)
 ```
 
 
 ### Backup all Ubiquiti's devices
 ```
-usage: pyradio backup_ac [-h] [--retries] [PATH]
+usage: pywisp backup_ac [-h] [--retries] [PATH]
 
 positional arguments:
   PATH        Directory in which save backup files (default: None)
@@ -45,7 +45,7 @@ optional arguments:
 
 ### Backup all Mikrotik's devices
 ```
-usage: pyradio backup_mt [-h] [--retries] [PATH]
+usage: pywisp backup_mt [-h] [--retries] [PATH]
 
 positional arguments:
   PATH        Directory in which save backup files (default: None)
@@ -57,7 +57,7 @@ optional arguments:
 
 ### Host lookup and actions
 ```
-usage: pyradio host [-h] [--deep] [--from-br FROM_BR] [--getname] [--getjson]
+usage: pywisp host [-h] [--deep] [--from-br FROM_BR] [--getname] [--getjson]
                     [--getip] [--getid] [--getmac] [--getdhcp] [--getwifi]
                     [--getwifistations] [--getstatus] [--url] [--ssh]
                     [--cmd CMD]
@@ -87,7 +87,7 @@ optional arguments:
 ```
 
 
-# Pyradio config file: `~/.pyradio`
+# PyWisp config file: `~/.pywisp`
 ```
 [wisp]
 path = ${env:HOME}/MyWISP/
@@ -107,9 +107,9 @@ mt = /var/backups/mywisp/mt/
 # WISP infrastructure and host authentication definitions `${env:HOME}/MyWISP/wisp.py`
 In [this example](/examples/Wisp_1.py), we hardcode relations between IPs, some device names, users and passwords. We could be getting those relations from where ever, for example, an SQL database, a secure wallet downloaded from an S3, an spreadsheet at GoogleDocs (sic), an internal REST API, etc. Examples are welcome via pull request.
 
-You can add more types of devices (for example, Mimosa) subclassing [`SSHDevice`](/pyradio/sshdevice.py) and instantiating it correctly from your `wisp.py`. If you do so, I appreciate pull requests ;) 
+You can add more types of devices (for example, Mimosa) subclassing [`SSHDevice`](/pywisp/sshdevice.py) and instantiating it correctly from your `wisp.py`. If you do so, I appreciate pull requests ;) 
 
-You can create a complete subclassed [`Wisp`](/pyradio/wisp.py) object and pass it to `Pyradio` on instantiation. This way you can use Pyradio from within other projects, like from your Django APP or from your Zabbix scripts, mantaining your infrastructure and authentication mechanisms centralized.
+You can create a complete subclassed [`Wisp`](/pywisp/wisp.py) object and pass it to `PyWisp` on instantiation. This way you can use PyWisp from within other projects, like from your Django APP or from your Zabbix scripts, mantaining your infrastructure and authentication mechanisms centralized.
 
 
 # TODO list
diff --git a/bin/pyradio b/bin/pywisp
similarity index 72%
rename from bin/pyradio
rename to bin/pywisp
index 3000728..34bf980 100755
--- a/bin/pyradio
+++ b/bin/pywisp
@@ -1,7 +1,7 @@
 #!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
-from pyradio.pyradio import main
+from pywisp.pywisp import main
 
 if __name__ == "__main__":
    exit(main())
diff --git a/pyradio/__init__.py b/pywisp/__init__.py
similarity index 100%
rename from pyradio/__init__.py
rename to pywisp/__init__.py
diff --git a/pyradio/aircontrol.py b/pywisp/aircontrol.py
similarity index 99%
rename from pyradio/aircontrol.py
rename to pywisp/aircontrol.py
index 25ad3fd..d58aa7c 100644
--- a/pyradio/aircontrol.py
+++ b/pywisp/aircontrol.py
@@ -2,7 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import os, requests, ipaddress, datetime, json
-from pyradio.sshdevice import SSHDevice
+from pywisp.sshdevice import SSHDevice
 
 from pprint import pformat
 
diff --git a/pyradio/interactive.py b/pywisp/interactive.py
similarity index 100%
rename from pyradio/interactive.py
rename to pywisp/interactive.py
diff --git a/pyradio/mikrotik.py b/pywisp/mikrotik.py
similarity index 98%
rename from pyradio/mikrotik.py
rename to pywisp/mikrotik.py
index 2205b25..4ed616e 100644
--- a/pyradio/mikrotik.py
+++ b/pywisp/mikrotik.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-from pyradio.sshdevice import SSHDevice
+from pywisp.sshdevice import SSHDevice
 
 STATUS = {
    "bound": "online",
diff --git a/pyradio/pyradio.py b/pywisp/pywisp.py
similarity index 85%
rename from pyradio/pyradio.py
rename to pywisp/pywisp.py
index 4b46635..22cf7b7 100755
--- a/pyradio/pyradio.py
+++ b/pywisp/pywisp.py
@@ -6,10 +6,10 @@
 from pprint import pprint
 
 # Internal imports
-from pyradio.wisp import Wisp
-from pyradio.sshdevice import backup_devices
+from pywisp.wisp import Wisp
+from pywisp.sshdevice import backup_devices
 
-class Pyradio():
+class PyWisp():
 
    log = None
    args = None
@@ -96,7 +96,7 @@ def parse_arguments(self, parser=argparse.ArgumentParser(formatter_class=MyCusto
       '''Parses arguments passed to program into a dict'''
       
       parser.add_argument("--conf", type=str,
-                          default="{}/{}".format(os.getenv('HOME'), '.pyradio'),
+                          default="{}/{}".format(os.getenv('HOME'), '.pywisp'),
                           help="Reads configuration from this file instead of default")
       
       sp = parser.add_subparsers()
@@ -226,47 +226,47 @@ def parse_configuration(self, file_name):
 
 def main():
    
-   pyradio = Pyradio()
+   pywisp = PyWisp()
    
    # Backup everything!
-   if 'backup_ac_path' in pyradio.args:
-      path = pyradio.args.backup_ac_path
-      if not path and 'backup' in pyradio.config and 'ac' in pyradio.config['backup']:
-         path = pyradio.config['backup']['ac']
+   if 'backup_ac_path' in pywisp.args:
+      path = pywisp.args.backup_ac_path
+      if not path and 'backup' in pywisp.config and 'ac' in pywisp.config['backup']:
+         path = pywisp.config['backup']['ac']
       
-      retries = pyradio.args.retries
-      if not retries and 'backup' in pyradio.config and 'retries' in pyradio.config['backup']:
-         retries = pyradio.config['backup']['retries']
+      retries = pywisp.args.retries
+      if not retries and 'backup' in pywisp.config and 'retries' in pywisp.config['backup']:
+         retries = pywisp.config['backup']['retries']
          
-      pyradio.log.debug('Backup AC devices to %s' % (path))
-      backup_devices(pyradio.wisp.get_ac_devices(), path, retries=retries)
+      pywisp.log.debug('Backup AC devices to %s' % (path))
+      backup_devices(pywisp.wisp.get_ac_devices(), path, retries=retries)
    
-   elif 'backup_mt_path' in pyradio.args:
-      path = pyradio.args.backup_mt_path
-      if not path and 'backup' in pyradio.config and 'mt' in pyradio.config['backup']:
-         path = pyradio.config['backup']['mt']
+   elif 'backup_mt_path' in pywisp.args:
+      path = pywisp.args.backup_mt_path
+      if not path and 'backup' in pywisp.config and 'mt' in pywisp.config['backup']:
+         path = pywisp.config['backup']['mt']
       
-      retries = pyradio.args.retries
-      if not retries and 'backup' in pyradio.config and 'retries' in pyradio.config['backup']:
-         retries = pyradio.config['backup']['retries']
+      retries = pywisp.args.retries
+      if not retries and 'backup' in pywisp.config and 'retries' in pywisp.config['backup']:
+         retries = pywisp.config['backup']['retries']
          
-      pyradio.log.debug('Backup MT devices to %s' % (path))
-      backup_devices(pyradio.wisp.get_mt_devices(), path, retries=retries)
+      pywisp.log.debug('Backup MT devices to %s' % (path))
+      backup_devices(pywisp.wisp.get_mt_devices(), path, retries=retries)
  
    # Reorder AirControl branches
-   elif 'reorder_ac' in pyradio.args:
-      pyradio.log.debug('Reorder branches!')
-      pyradio.wisp.ac_reorder_branches()
+   elif 'reorder_ac' in pywisp.args:
+      pywisp.log.debug('Reorder branches!')
+      pywisp.wisp.ac_reorder_branches()
  
    # Find host and print info about it or perform actions on it     
-   elif 'host' in pyradio.args:
+   elif 'host' in pywisp.args:
       # Optional lower host (insensitive)
-      pyradio.args.host = pyradio.args.host.lower().strip()
+      pywisp.args.host = pywisp.args.host.lower().strip()
       
       # Get devices
-      devices = pyradio.wisp.get_host(pyradio.args.host, deep=pyradio.args.deep, from_br=pyradio.args.from_br)
+      devices = pywisp.wisp.get_host(pywisp.args.host, deep=pywisp.args.deep, from_br=pywisp.args.from_br)
       if devices == None or len(devices) == 0:
-         pyradio.log.error("No devices found: '%s'" % (pyradio.args.host))
+         pywisp.log.error("No devices found: '%s'" % (pywisp.args.host))
          return 1
 
       # If its not a list, convert into it
@@ -275,7 +275,7 @@ def main():
       
       # Apply actions for every device found
       for device in devices:
-         pyradio.parse_device(device)
+         pywisp.parse_device(device)
    
    return 0
 
diff --git a/pyradio/requirements.txt b/pywisp/requirements.txt
similarity index 100%
rename from pyradio/requirements.txt
rename to pywisp/requirements.txt
diff --git a/pyradio/sshdevice.py b/pywisp/sshdevice.py
similarity index 100%
rename from pyradio/sshdevice.py
rename to pywisp/sshdevice.py
diff --git a/pyradio/wisp.py b/pywisp/wisp.py
similarity index 99%
rename from pyradio/wisp.py
rename to pywisp/wisp.py
index c5f2074..42e5b53 100644
--- a/pyradio/wisp.py
+++ b/pywisp/wisp.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-from pyradio.aircontrol import ACSession
+from pywisp.aircontrol import ACSession
 from pprint import pprint
 
 class Wisp():
diff --git a/setup.py b/setup.py
index 217e1f3..580bd04 100644
--- a/setup.py
+++ b/setup.py
@@ -1,22 +1,22 @@
 
 from setuptools import setup, find_packages
 
-VERSION = (0, 0, 2)
+VERSION = (0, 0, 3)
 __version__ = '.'.join(map(str, VERSION))
 
 setup(
-    name = 'pyradio',
+    name = 'pywisp',
     version = __version__,
     description = "Access AirControl2, AirOS & Mikrotik",
     long_description = "Access AirControl2 (API), AirOS (SSH) & Mikrotik (SSH) from the same place",
     author = "Emilio del Giorgio",
     author_email = "https://github.com/emibcn",
-    url = "https://github.com/emibcn/pyradio",
+    url = "https://github.com/emibcn/pywisp",
     license = "GPLv3",
     platforms = ["any"],
-    packages = ['pyradio'],
-    py_modules=['pyradio', 'pyradio/mikrotik', 'pyradio/aircontrol', 'pyradio/sshdevice'],
-    scripts = ["bin/pyradio"],
+    packages = ['pywisp'],
+    py_modules=['pywisp', 'pywisp/mikrotik', 'pywisp/aircontrol', 'pywisp/sshdevice'],
+    scripts = ["bin/pywisp"],
     install_requires = ['requests', 'paramiko', 'termcolor'],
     include_package_data = True,
     classifiers = [


Test patch:
diff --git a/tests/test_pyradio.py b/tests/test_pywisp.py
similarity index 61%
rename from tests/test_pyradio.py
rename to tests/test_pywisp.py
index 4d5d77c..610c6b7 100644
--- a/tests/test_pyradio.py
+++ b/tests/test_pywisp.py
@@ -1,9 +1,9 @@
 #!/usr/bin/python3
 # -*- coding: utf-8 -*-
 
-from pyradio.pyradio import Pyradio
-from pyradio.wisp import Wisp
-from pyradio.mikrotik import MTDevice
+from pywisp.pywisp import PyWisp
+from pywisp.wisp import Wisp
+from pywisp.mikrotik import MTDevice
 
 # Create a WISP Mixin
 class MyWisp(Wisp):
@@ -12,26 +12,26 @@ def get_host(self, name, deep=False, from_br=None):
          name = [name]
       return [MTDevice({}, username="admin", password="PASSWORD", ip=n, name=n) for n in name]
 
-# Instantiate the WISP and PyRadio
-pyradio = Pyradio()
-pyradio.wisp = MyWisp(ac_conf={
+# Instantiate the WISP and PyWisp
+pywisp = PyWisp()
+pywisp.wisp = MyWisp(ac_conf={
       "url": "https://localhost:9082",
       "user": "admin",
       "password": "admin",
-}, getlog=pyradio.setup_logger)
+}, getlog=pywisp.setup_logger)
 
 # Create some phantom arguments
-pyradio.args.host = "10.255.255.2"
-pyradio.args.getip = True
+pywisp.args.host = "10.255.255.2"
+pywisp.args.getip = True
 
 # Get devices
-device = pyradio.wisp.get_host(pyradio.args.host)
+device = pywisp.wisp.get_host(pywisp.args.host)
 assert device != None, 'get_host should have returned a list or a device'
 assert len(device), 'get_host should have returned a list with at least one device'
 
 # Test `get_ip` output
 def test_parse_device(capsys):
-    pyradio.parse_device(device[0])
+    pywisp.parse_device(device[0])
     captured = capsys.readouterr()
-    assert captured.out == pyradio.args.host + "\n"
+    assert captured.out == pywisp.args.host + "\n"