From 2bab8cb16646e79200d9cb6c4904eadb0eaaa8fa Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 11:42:45 +0200 Subject: [PATCH 1/6] dest should do the trick, so that sockpath will be stored in socketpath --- gvmtools/parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gvmtools/parser.py b/gvmtools/parser.py index f0799355..cab0b533 100644 --- a/gvmtools/parser.py +++ b/gvmtools/parser.py @@ -259,6 +259,7 @@ def _add_subparsers(self): '--sockpath', nargs='?', default=None, + dest='socketpath', help='Deprecated, use --socketpath instead', ) socketpath_group.add_argument( From 89a805cb1d409b1c31e09fa66e88306264b679f2 Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 11:52:17 +0200 Subject: [PATCH 2/6] Updating the tests --- tests/socket_help.snap | 4 ++-- tests/test_parser.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/socket_help.snap b/tests/socket_help.snap index 0bfe11cf..570b7b49 100644 --- a/tests/socket_help.snap +++ b/tests/socket_help.snap @@ -1,9 +1,9 @@ -usage: gvm-test-cli socket [-h] [--sockpath [SOCKPATH] | --socketpath +usage: gvm-test-cli socket [-h] [--sockpath [SOCKETPATH] | --socketpath [SOCKETPATH]] optional arguments: -h, --help show this help message and exit - --sockpath [SOCKPATH] + --sockpath [SOCKETPATH] Deprecated, use --socketpath instead --socketpath [SOCKETPATH] Path to UNIX Domain socket (default: None) diff --git a/tests/test_parser.py b/tests/test_parser.py index 4e38da93..c6c2c9f1 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -171,8 +171,7 @@ def test_with_unknown_args(self): class SocketParserTestCase(ParserTestCase): def test_defaults(self): args = self.parser.parse_args(['socket']) - self.assertIsNone(args.sockpath) - self.assertEqual(args.socketpath, '/usr/local/var/run/gvmd.sock') + self.assertEqual(args.socketpath, '/usr/local/var/run/gvmd.sock') #TODO def test_connection_type(self): args = self.parser.parse_args(['socket']) @@ -180,7 +179,7 @@ def test_connection_type(self): def test_sockpath(self): args = self.parser.parse_args(['socket', '--sockpath', 'foo.sock']) - self.assertEqual(args.sockpath, 'foo.sock') + self.assertEqual(args.socketpath, 'foo.sock') def test_socketpath(self): args = self.parser.parse_args(['socket', '--socketpath', 'foo.sock']) From 62d36ca302d1a6c7c7c79dfb259e9e6d7abe997c Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 12:14:24 +0200 Subject: [PATCH 3/6] Changed the hardcoded Path ... --- tests/test_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_parser.py b/tests/test_parser.py index c6c2c9f1..f67d7f77 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -171,7 +171,7 @@ def test_with_unknown_args(self): class SocketParserTestCase(ParserTestCase): def test_defaults(self): args = self.parser.parse_args(['socket']) - self.assertEqual(args.socketpath, '/usr/local/var/run/gvmd.sock') #TODO + self.assertEqual(args.socketpath, DEFAULT_UNIX_SOCKET_PATH) def test_connection_type(self): args = self.parser.parse_args(['socket']) From 432e707e402d798dbdb68eb01aff7b395dc52807 Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 12:21:15 +0200 Subject: [PATCH 4/6] Removed deprecated code --- gvmtools/pyshell.py | 7 ------- gvmtools/script.py | 7 ------- 2 files changed, 14 deletions(-) diff --git a/gvmtools/pyshell.py b/gvmtools/pyshell.py index 951f6583..bfa0c7df 100644 --- a/gvmtools/pyshell.py +++ b/gvmtools/pyshell.py @@ -104,13 +104,6 @@ def main(): args = parser.parse_args() - if 'socket' in args.connection_type and args.sockpath: - print( - 'The --sockpath parameter has been deprecated. Please use ' - '--socketpath instead', - file=sys.stderr, - ) - connection = create_connection(**vars(args)) transform = EtreeCheckCommandTransform() diff --git a/gvmtools/script.py b/gvmtools/script.py index 7344026c..280c88e3 100644 --- a/gvmtools/script.py +++ b/gvmtools/script.py @@ -64,13 +64,6 @@ def main(): ) args, script_args = parser.parse_known_args() - if 'socket' in args.connection_type and args.sockpath: - print( - 'The --sockpath parameter has been deprecated. Please use ' - '--socketpath instead', - file=sys.stderr, - ) - connection = create_connection(**vars(args)) transform = EtreeCheckCommandTransform() From d361996ef545c056b0135e89ca4397c6f05f4a7e Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 13:41:15 +0200 Subject: [PATCH 5/6] Changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2d01dcc..b606dfcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ $ cd gvm-tools && git log - Exit with an error, if the `check_gmp.gmp` script is used with an temporary path, that has not the correct permissions. - Fixed `update-task-target.gmp` to create unique target names to support Gmpv8 +- Fixed an error, where the `--sockpath` argument didn't worked as expected [PR 216](https://github.com/greenbone/gvm-tools/pull/216) ### Removed From 1ae301da5d5cfccbb4141d2b474d01aa8f6f9d4b Mon Sep 17 00:00:00 2001 From: jstach Date: Thu, 26 Sep 2019 13:44:15 +0200 Subject: [PATCH 6/6] Removed import --- gvmtools/script.py | 1 - 1 file changed, 1 deletion(-) diff --git a/gvmtools/script.py b/gvmtools/script.py index 280c88e3..fe084b53 100644 --- a/gvmtools/script.py +++ b/gvmtools/script.py @@ -17,7 +17,6 @@ # along with this program. If not, see . import os -import sys from argparse import Namespace