Package: routerscraper
READMERouter ScraperDetailsThis project aims at providing a python package to interact with different
routers.Getting startedImport the required class from therouterscraperpackage:fastgate_dn8245f2.pyfor the Fastgate Huawei DN8245f2technicolor_tg789vacv2.pyfor the Technicolor TG789vac v2tplink_m7000.pyfor the TP-Link M7000The constructor needs the following parametershost: the hostname (or IP address) of the routeruser: the username to log in the routerpassword: the password to log in the routerThen you can get relevant information with:listDevices(): get the list of connected devicesgetSmsList(): get the list of SMS present on the deviceThe functions automatically issue a login request if necessary.Supported functionsNot all functions are supported by all devices. See table below for supported
functions:FunctionlistDevices()getSmsList()Fastgate Huawei DN8245f2XTechnicolor TG789vac v2XTP-Link M7000XSaving and restoring sessionsIt is possible to export the sessions to later restore them; this can be used
to avoid having to login every time.To do this, you can export the current status throughexportSessionStatus,
which returns a string (base64 encoded JSON dict) that can be saved. TherestoreSessionStatusfunction restores the status from that string.Supported routersAt present the package was tested with the following routers firmwaresFastgate Huawei DN8245f2 - software 1.0.1bTechnicolor TG789vac v2 - software 16.3.7636TP-Link M7000 - software 1.0.10 Build 211230 Rel.1026nDeveloper notesHere are some additional notes for developing the library (not just using it).Project layoutREADME.md: This fileREADME.md.license: License information for this filepyproject.toml: Configuration file for build environmentsetup.py: Fallback file for editable installsMakefile: Makefile to help running development scriptssrc/routerscraper: Folder with the scraping packagebasescraper.py: Contains the base class implementationrequestscraper.py: Contains the base class for scrapers using requestsseleniumscraper.py: Contains the base class for scrapers using SeleniumdataTypes.py: Module to group data types used in the functionsfastgate_dn8245f2.py: Contains the implementation for the Fastgate
Huawei DN8245f2technicolor_tg789vacv2.py: Contains the implementation for the
Technicolor TG789vac v2tplink_m7000.py: Contains the implementation for the TP-Link M7000tests: Folder with the unit tests. Each test file in this folder
implements tests linked to the corresponding file in therouterscraperfolder; if necessary, helper files group
functions needed by the corresponding test file.files_*folder contains files needed by the test files.helpers_common.pyimplements some classes useful for all the
tests.examples: Folder with example codefastgate_dn8245f2.py: Contains an example implementation for the
Fastgate Huawei DN8245f2technicolor_tg789vacv2.py: Contains an example implementation for the
Technicolor TG789vac v2tplink_m7000.py: Contains an example implementation for the TP-Link
M7000LICENSES: Folder with the licenses statementsExamplesAll example scripts behave in the same way. They will connect to the router and
print the list of connected devices (or the received SMS, in the case of the
TP-Link).Call the script with three parameters:URL of the routerUSERNAMEPASSWORDMakefileFor development purposes there is a Makefile to automate the different actions.The available targets are:all: Build the package (equal to make dist); this is the goal (i.e.
target executed when calling make without targets)clean: Clean the project (removing all the .pyc files)dist: Build the package (both .tar.gz and .whl archives)deploy: Upload the package on PyPI.venv/bin/activate: Target to create the virtual environmentcreate_venv: Easier to remember PHONY to create the virtual environmentclean_venv: Remove the virtual environmentcode_review: Run the commands to review the code (flake8 and reuse)tests: Run the tests on the libraryrelease-tests: Execute all the checks for a release; this target is
automatically executed by the otherrelease-targets.release-major: Release the current version bumping the major index. This
target needs that the GIT has no uncommitted changes and
must be run from the main branch only.release-minor: Release the current version bumping the minor index. This
target needs that the GIT has no uncommitted changes and
must be run from the main branch only.release-patch: Release the current version bumping the patch index. This
target needs that the GIT has no uncommitted changes and
must be run from the main branch only.check-git-clean: Helper recipe that tests if GIT repo is cleancheck-git-on-main: Helper recipe that tests if GIT repo is on main branchNote:boldtargets are PHONY,italicones are files.All the operations will happen in a virtual environment. The virtual
environment folder is set in environment variable VENV, which defaults to.venv.NOTE: if you change the prerequisites in the pyproject.toml, remember to runmake clean_venvto recreate the virtual environment with the new data.Release procedureIn order to release a new version, everything shall be already committed to the
GIT repo (since the process requires a clean GIT repo); in addition, the repo
shall be on main branch. If this is not true, the process will fail.After having committed the last modifications, issue the following commands:make clean
make release-XXXThe release target shall berelease-major,release-minororrelease-patch,
according to which part of the software version shall be increased.If everything is correct, runmake deployto upload the files to PyPI.Setup the repositoryClone the repository fromgit@github.com:fra87/RouterScraper.git