refactored code

This commit is contained in:
botlabsDev 2020-06-13 18:34:42 +02:00
parent de282a39e7
commit 4a924fb1cc
5 changed files with 14 additions and 16 deletions

View file

@ -5,7 +5,7 @@
# npkPy # npkPy
The npkPy package module is an unpacking tool for MikroTiks custom NPK container format. The tool is capable The npkPy package module is an unpacking tool for MikroTiks custom NPK container format. The tool is capable
to display to the content of any NPK package and to export all container. to display the content of any NPK package and to export all container.
["NPK stands for MikroTik RouterOS upgrade package"](https://whatis.techtarget.com/fileformat/NPK-MikroTik-RouterOS-upgrade-package) ["NPK stands for MikroTik RouterOS upgrade package"](https://whatis.techtarget.com/fileformat/NPK-MikroTik-RouterOS-upgrade-package)
and since there is no solid unpacking tool for the format available, I want to share my approach of it. and since there is no solid unpacking tool for the format available, I want to share my approach of it.
@ -21,6 +21,12 @@ All recent packages are signed with EC-KCDSA signature,
and there's no way to create a valid npk file unless you know a secret key. and there's no way to create a valid npk file unless you know a secret key.
``` ```
## Installation
```
pip install npkPy
```
## Usage ## Usage
``` ```

View file

@ -11,7 +11,7 @@ if [[ ! -e ${venv} ]]; then
fi fi
git config user.name "botlabsDev" git config user.name "botlabsDev"
git config user.email "git@botlabs.dev" git config user.email "botlabs.dev@botlabs.dev"
echo "--git config--" echo "--git config--"
echo -n "git user:"; git config user.name echo -n "git user:"; git config user.name
echo -n "git email:"; git config user.email echo -n "git email:"; git config user.email

View file

@ -1,11 +1,3 @@
!/bin/bash !/bin/bash
if [ ! -z "$1" ] pytest --cov=npkpy --cov=acceptance_test -v
then
clear; echo "test specific file: $1"
pytest --cov=./ $1 -v
else
clear; echo "test all project files"
pytest --cov=npkpy --cov=acceptance_test -v
fi

View file

@ -23,7 +23,7 @@ setuptools.setup(
], ],
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
"npkPy=npkpy.main:main", "npkpy=npkpy.main:main",
# "npkDownloader=npkpy.download:main", # "npkDownloader=npkpy.download:main",
], ],
}, },

View file

@ -19,12 +19,12 @@ class Test_npkPy(unittest.TestCase):
self.dstFolder.rmdir() self.dstFolder.rmdir()
def test_showAllContainersFromNpkPkg(self): def test_showAllContainersFromNpkPkg(self):
cmd = ["npkPy", "--file", self.pathToNpk, "--showContainer"] cmd = ["npkpy", "--file", self.pathToNpk, "--showContainer"]
output = runCmdInTerminal(cmd) output = runCmdInTerminal(cmd)
self.assertEqual(self.npkContainerList, output) self.assertEqual(self.npkContainerList, output)
def test_exportAllContainerFromNpk(self): def test_exportAllContainerFromNpk(self):
cmd = ["npkPy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportAll"] cmd = ["npkpy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportAll"]
runCmdInTerminal(cmd) runCmdInTerminal(cmd)
@ -42,7 +42,7 @@ class Test_npkPy(unittest.TestCase):
'npkPyExport_gps-6.45.6/009_cnt_CntArchitectureTag.raw'], exportedContainer) 'npkPyExport_gps-6.45.6/009_cnt_CntArchitectureTag.raw'], exportedContainer)
def test_extractSquashFsContainerFromNpk(self): def test_extractSquashFsContainerFromNpk(self):
cmd = ["npkPy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportSquashFs"] cmd = ["npkpy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportSquashFs"]
runCmdInTerminal(cmd) runCmdInTerminal(cmd)
@ -51,7 +51,7 @@ class Test_npkPy(unittest.TestCase):
# #
def test_extractZlibContainerFromNpk_NonExisitngNotExtracted(self): def test_extractZlibContainerFromNpk_NonExisitngNotExtracted(self):
cmd = ["npkPy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportZlib"] cmd = ["npkpy", "--file", self.pathToNpk, "--dstFolder", self.dstFolder.absolute(), "--exportZlib"]
runCmdInTerminal(cmd) runCmdInTerminal(cmd)