diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index c8aeb66..1bf85c8 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -21,7 +21,7 @@ jobs: - name: Regression test - run: sudo -E ./run_tests + run: sudo -E ./tests/run_tests - name: Coveralls @@ -43,7 +43,7 @@ jobs: - name: Regression test - run: sudo -E ./run_tests + run: sudo -E ./tests/run_tests - name: Coveralls diff --git a/.gitignore b/.gitignore index 96305c8..871b59a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ __pycache__ .coverage *.pyc python2.env +venv +.idea +OQ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 499abee..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -#MOVING TO GITHUB ACTIONS - -# jobs: -# include: -# - os: linux -# dist: xenial -# language: python -# python: 2.7 -# - os: linux -# dist: xenial -# language: python -# python: 3.6 -# - os: linux -# dist: bionic -# language: python -# python: 2.7 -# - os: linux -# dist: bionic -# language: python -# python: 3.6 - - - - -# before_install: -# - sudo apt-get update -# - sudo apt-get install zfsutils-linux - -# script: -# # - sudo -E ./ngrok.sh -# - sudo -E ./run_tests -# # - sudo -E pip --version diff --git a/bin/__init__.py b/bin/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/bin/zfs_autobackup.py b/bin/zfs_autobackup.py deleted file mode 120000 index b05f3ef..0000000 --- a/bin/zfs_autobackup.py +++ /dev/null @@ -1 +0,0 @@ -zfs-autobackup \ No newline at end of file diff --git a/ngrok.sh b/ngrok.sh deleted file mode 100755 index e905ab5..0000000 --- a/ngrok.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -if ! [ -e ngrok ]; then - wget -O ngrok.zip https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip - unzip ngrok.zip -fi -{ - mkfifo pipe - echo "Executing nc" - nc -k -l -v 8888 pipe 2>&1; echo "restarting" ;sleep 1; done ) - killall -SIGINT ngrok && echo "ngrok terminated" -} & -{ - echo "Executing ngrok" - ./ngrok authtoken $NGROK_TOKEN - ./ngrok tcp 8888 --log=stdout -} & -wait diff --git a/release b/scripts/release similarity index 100% rename from release rename to scripts/release diff --git a/releasetest b/scripts/releasetest similarity index 100% rename from releasetest rename to scripts/releasetest diff --git a/setup.py b/setup.py index 6ed1b6c..27dc6e9 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,13 @@ import setuptools -import bin.zfs_autobackup +import zfs_autobackup import os - with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="zfs_autobackup", - version=bin.zfs_autobackup.VERSION, + version=zfs_autobackup.VERSION, author="Edwin Eefting", author_email="edwin@datux.nl", description="ZFS autobackup is used to periodicly backup ZFS filesystems to other locations. It tries to be the most friendly to use and easy to debug ZFS backup tool.", @@ -16,8 +15,14 @@ setuptools.setup( long_description_content_type="text/markdown", url="https://github.com/psy0rz/zfs_autobackup", - scripts=["bin/zfs-autobackup"], + entry_points={ + 'console_scripts': + [ + 'zfs-autobackup = zfs_autobackup:cli', + ] + }, packages=setuptools.find_packages(), + classifiers=[ "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", diff --git a/basetest.py b/tests/basetest.py similarity index 98% rename from basetest.py rename to tests/basetest.py index 11ebad5..11bebeb 100644 --- a/basetest.py +++ b/tests/basetest.py @@ -8,7 +8,7 @@ import unittest2 import subprocess import time from pprint import * -from bin.zfs_autobackup import * +from zfs_autobackup import * from mock import * import contextlib import sys diff --git a/run_tests b/tests/run_tests similarity index 52% rename from run_tests rename to tests/run_tests index c360612..7b2be4e 100755 --- a/run_tests +++ b/tests/run_tests @@ -1,4 +1,8 @@ -#!/bin/bash +#!/bin/bash + +SCRIPTDIR=`dirname $0` + +#cd $SCRIPTDIR || exit 1 if [ "$USER" != "root" ]; then @@ -6,8 +10,6 @@ if [ "$USER" != "root" ]; then exit 1 fi -#reactivate python environment, if any (usefull in Travis) -[ "$VIRTUAL_ENV" ] && source $VIRTUAL_ENV/bin/activate # test needs ssh access to localhost for testing if ! [ -e /root/.ssh/id_rsa ]; then @@ -16,16 +18,11 @@ if ! [ -e /root/.ssh/id_rsa ]; then ssh -oStrictHostKeyChecking=no localhost true || exit 1 fi -coverage run --source bin.zfs_autobackup -m unittest discover -vvvvf $@ 2>&1 + +coverage run --source zfs_autobackup -m unittest discover -vvvvf $SCRIPTDIR $@ 2>&1 EXIT=$? echo coverage report -#this does automatic travis CI/https://coveralls.io/ intergration: -# if which coveralls > /dev/null; then -# echo "Submitting to coveralls.io:" -# coveralls -# fi - exit $EXIT diff --git a/test_destroymissing.py b/tests/test_destroymissing.py similarity index 100% rename from test_destroymissing.py rename to tests/test_destroymissing.py diff --git a/test_executenode.py b/tests/test_executenode.py similarity index 100% rename from test_executenode.py rename to tests/test_executenode.py diff --git a/test_externalfailures.py b/tests/test_externalfailures.py similarity index 100% rename from test_externalfailures.py rename to tests/test_externalfailures.py diff --git a/test_regressions.py b/tests/test_regressions.py similarity index 100% rename from test_regressions.py rename to tests/test_regressions.py diff --git a/test_scaling.py b/tests/test_scaling.py similarity index 99% rename from test_scaling.py rename to tests/test_scaling.py index 8f6df37..ebed49f 100644 --- a/test_scaling.py +++ b/tests/test_scaling.py @@ -1,6 +1,5 @@ from basetest import * import time -from bin.zfs_autobackup import * run_orig=ExecuteNode.run run_counter=0 diff --git a/test_thinner.py b/tests/test_thinner.py similarity index 100% rename from test_thinner.py rename to tests/test_thinner.py diff --git a/test_zfsautobackup.py b/tests/test_zfsautobackup.py similarity index 100% rename from test_zfsautobackup.py rename to tests/test_zfsautobackup.py diff --git a/test_zfsnode.py b/tests/test_zfsnode.py similarity index 100% rename from test_zfsnode.py rename to tests/test_zfsnode.py diff --git a/bin/zfs-autobackup b/zfs_autobackup/__init__.py similarity index 99% rename from bin/zfs-autobackup rename to zfs_autobackup/__init__.py index d4b682f..221c438 100755 --- a/bin/zfs-autobackup +++ b/zfs_autobackup/__init__.py @@ -1915,6 +1915,6 @@ class ZfsAutobackup: return 255 -if __name__ == "__main__": +def cli(): zfs_autobackup = ZfsAutobackup(sys.argv[1:], False) sys.exit(zfs_autobackup.run()) diff --git a/zfs_autobackup/__main__.py b/zfs_autobackup/__main__.py new file mode 100755 index 0000000..ef7b08a --- /dev/null +++ b/zfs_autobackup/__main__.py @@ -0,0 +1,4 @@ +if __name__ == "__main__": + from . import cli + cli() +