From 697382ddc2a5e88a3417dec7b4cdf19a0d6b731f Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Mon, 30 Mar 2020 18:11:31 +0200 Subject: [PATCH] Update hacking for Python3 The repo is Python 3 now, so update hacking to version 3.0 which supports Python 3. Fix problems found. Update local hacking checks for new flake8. Change-Id: Ib3907677d373ba9a92f9efc807af483c33347c9f --- .../plugins/vanilla/hadoop2/config_helper.py | 1 + sahara_plugin_vanilla/plugins/vanilla/hadoop2/run_scripts.py | 4 ++-- .../tests/unit/plugins/vanilla/hadoop2/test_run_scripts.py | 5 +++-- test-requirements.txt | 2 +- tox.ini | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sahara_plugin_vanilla/plugins/vanilla/hadoop2/config_helper.py b/sahara_plugin_vanilla/plugins/vanilla/hadoop2/config_helper.py index 3fc3398..d7c96fd 100644 --- a/sahara_plugin_vanilla/plugins/vanilla/hadoop2/config_helper.py +++ b/sahara_plugin_vanilla/plugins/vanilla/hadoop2/config_helper.py @@ -229,6 +229,7 @@ def _init_general_configs(): configs.append(ENABLE_DATA_LOCALITY) return configs + PLUGIN_GENERAL_CONFIGS = _init_general_configs() diff --git a/sahara_plugin_vanilla/plugins/vanilla/hadoop2/run_scripts.py b/sahara_plugin_vanilla/plugins/vanilla/hadoop2/run_scripts.py index 31f9504..c99b2bb 100644 --- a/sahara_plugin_vanilla/plugins/vanilla/hadoop2/run_scripts.py +++ b/sahara_plugin_vanilla/plugins/vanilla/hadoop2/run_scripts.py @@ -232,8 +232,8 @@ def _check_datanodes_count(remote, count): LOG.debug("Checking datanode count") exit_code, stdout = remote.execute_command( 'sudo su -lc "hdfs dfsadmin -report" hadoop | ' - 'grep \'Live datanodes\|Datanodes available:\' | ' - 'grep -o \'[0-9]\+\' | head -n 1') + r'grep \'Live datanodes\|Datanodes available:\' | ' + r'grep -o \'[0-9]\+\' | head -n 1') LOG.debug("Datanode count='{count}'".format(count=stdout.rstrip())) return exit_code == 0 and stdout and int(stdout) == count diff --git a/sahara_plugin_vanilla/tests/unit/plugins/vanilla/hadoop2/test_run_scripts.py b/sahara_plugin_vanilla/tests/unit/plugins/vanilla/hadoop2/test_run_scripts.py index 0eb1bd5..d33e917 100644 --- a/sahara_plugin_vanilla/tests/unit/plugins/vanilla/hadoop2/test_run_scripts.py +++ b/sahara_plugin_vanilla/tests/unit/plugins/vanilla/hadoop2/test_run_scripts.py @@ -25,6 +25,7 @@ def mock_event_wrapper(*args, **kwargs): return decorated_function return decorator + from sahara.plugins import edp from sahara.plugins import utils as pu mock.patch('sahara.plugins.utils.event_wrapper', mock_event_wrapper).start() @@ -254,8 +255,8 @@ class RunScriptsTest(base.SaharaTestCase): self.assertEqual(rs._check_datanodes_count(self.r, 1), True) self.r.execute_command.assert_called_once_with( 'sudo su -lc "hdfs dfsadmin -report" hadoop | ' - 'grep \'Live datanodes\|Datanodes available:\' | ' - 'grep -o \'[0-9]\+\' | head -n 1') + r'grep \'Live datanodes\|Datanodes available:\' | ' + r'grep -o \'[0-9]\+\' | head -n 1') def test_hive_create_warehouse_dir(self): rs._hive_create_warehouse_dir(self.r) diff --git a/test-requirements.txt b/test-requirements.txt index 9cffbb1..c572e69 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 bandit>=1.1.0 # Apache-2.0 bashate>=0.5.1 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 1940138..89c878d 100644 --- a/tox.ini +++ b/tox.ini @@ -94,7 +94,8 @@ enable-extensions=H904,H106,H203,H204,H205 # [E402] Module level import not at top of file # [E731] Do not assign a lambda expression, use a def # [W503] Line break occurred before a binary operator -ignore=E123,E226,E402,E731,W503 +# [W504] line break after binary operator +ignore=E123,E226,E402,E731,W503,W504 [testenv:lower-constraints] deps =