From 23472e8d1c06cd0ddcaadadd787464eb6c394231 Mon Sep 17 00:00:00 2001 From: Gabriel Brascher Date: Thu, 25 Feb 2021 03:49:27 -0300 Subject: [PATCH] Fix indentation issues and use python3 when running pycodestyle checker --- systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py | 2 +- systemvm/debian/root/health_checks/memory_usage_check.py | 6 +++--- .../debian/root/health_checks/router_version_check.py | 8 ++++---- systemvm/test/runtests.sh | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py b/systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py index e39595dd1c2..16799707062 100755 --- a/systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py +++ b/systemvm/debian/opt/cloud/bin/cs/CsNetfilter.py @@ -28,7 +28,7 @@ class CsChain(object): self.count = {} def add(self, table, chain): - if table not in list(self.chain.keys()): + if table not in list(self.chain.keys()): self.chain.setdefault(table, []).append(chain) else: self.chain[table].append(chain) diff --git a/systemvm/debian/root/health_checks/memory_usage_check.py b/systemvm/debian/root/health_checks/memory_usage_check.py index 20b56532f26..08b73df0d3b 100644 --- a/systemvm/debian/root/health_checks/memory_usage_check.py +++ b/systemvm/debian/root/health_checks/memory_usage_check.py @@ -28,7 +28,7 @@ def main(): data = entries[0] if "maxMemoryUsage" not in data: - print("Missing maxMemoryUsage in health_checks_data " + \ + print("Missing maxMemoryUsage in health_checks_data " + "systemThresholds, skipping") exit(0) @@ -39,10 +39,10 @@ def main(): if pout.wait() == 0: currentUsage = float(pout.communicate()[0].strip()) if currentUsage > maxMemoryUsage: - print("Memory Usage " + str(currentUsage) + \ + print("Memory Usage " + str(currentUsage) + "% has crossed threshold of " + str(maxMemoryUsage) + "%") exit(1) - print("Memory Usage within limits with current at " + \ + print("Memory Usage within limits with current at " + str(currentUsage) + "%") exit(0) else: diff --git a/systemvm/debian/root/health_checks/router_version_check.py b/systemvm/debian/root/health_checks/router_version_check.py index b65aca43f49..1ec37e90b7c 100644 --- a/systemvm/debian/root/health_checks/router_version_check.py +++ b/systemvm/debian/root/health_checks/router_version_check.py @@ -53,10 +53,10 @@ def main(): releaseFile = "/etc/cloudstack-release" found = getFirstLine(releaseFile) if found is None: - print("Release version not yet setup at " + releaseFile +\ + print("Release version not yet setup at " + releaseFile + ", skipping.") elif expected != found: - print("Template Version mismatch. Expected: " + \ + print("Template Version mismatch. Expected: " + expected + ", found: " + found) templateVersionMatches = False @@ -65,10 +65,10 @@ def main(): sigFile = "/var/cache/cloud/cloud-scripts-signature" found = getFirstLine(sigFile) if found is None: - print("Scripts signature is not yet setup at " + sigFile +\ + print("Scripts signature is not yet setup at " + sigFile + ", skipping") if expected != found: - print("Scripts Version mismatch. Expected: " + \ + print("Scripts Version mismatch. Expected: " + expected + ", found: " + found) scriptVersionMatches = False diff --git a/systemvm/test/runtests.sh b/systemvm/test/runtests.sh index b5a27041c25..01c55e14c12 100644 --- a/systemvm/test/runtests.sh +++ b/systemvm/test/runtests.sh @@ -22,8 +22,8 @@ export PYTHONPATH="../debian/opt/cloud/bin/" export PYTHONDONTWRITEBYTECODE=False echo "Running pycodestyle to check systemvm/python code for errors" -python -m pycodestyle --max-line-length=179 *py -python -m pycodestyle --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py` +python3 -m pycodestyle --max-line-length=179 *py +python3 -m pycodestyle --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py` if [ $? -gt 0 ] then echo "pycodestyle failed, please check your code"