You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2018/04/18 16:07:43 UTC
[cloudstack] branch 4.11 updated: Fix Python code checkstyle
execute by "systemvm\test\runtests.sh" (#2576)
This is an automated email from the ASF dual-hosted git repository.
rafael pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new bfe4cb0 Fix Python code checkstyle execute by "systemvm\test\runtests.sh" (#2576)
bfe4cb0 is described below
commit bfe4cb0c41fa9772031d902ca3eaf66eb726fbbe
Author: Rafael Weingärtner <ra...@gmail.com>
AuthorDate: Wed Apr 18 13:07:37 2018 -0300
Fix Python code checkstyle execute by "systemvm\test\runtests.sh" (#2576)
* dependencies update
* Add extra blank line required by ...!?
* fix W605 invalid escape sequence and more blank lines
* print all installed python packages versions
---
systemvm/debian/opt/cloud/bin/configure.py | 7 ++++---
systemvm/debian/opt/cloud/bin/cs/CsProcess.py | 6 +++---
systemvm/debian/opt/cloud/bin/cs/CsRedundant.py | 4 ++--
systemvm/debian/opt/cloud/bin/line_edit.py | 1 +
systemvm/debian/opt/cloud/bin/update_config.py | 1 +
systemvm/debian/opt/cloud/bin/vmdata.py | 1 +
systemvm/test/TestCsAddress.py | 1 +
systemvm/test/TestCsApp.py | 1 +
systemvm/test/TestCsCmdLine.py | 1 +
systemvm/test/TestCsConfig.py | 1 +
systemvm/test/TestCsDatabag.py | 1 +
systemvm/test/TestCsDhcp.py | 1 +
systemvm/test/TestCsFile.py | 1 +
systemvm/test/TestCsGuestNetwork.py | 1 +
systemvm/test/TestCsHelper.py | 1 +
systemvm/test/TestCsInterface.py | 1 +
systemvm/test/TestCsNetfilter.py | 1 +
systemvm/test/TestCsProcess.py | 1 +
systemvm/test/TestCsRedundant.py | 1 +
systemvm/test/TestCsRoute.py | 1 +
systemvm/test/TestCsRule.py | 1 +
systemvm/test/runtests.sh | 6 +++---
tools/travis/before_install.sh | 6 +++++-
23 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/systemvm/debian/opt/cloud/bin/configure.py b/systemvm/debian/opt/cloud/bin/configure.py
index a3b7674..b94333f 100755
--- a/systemvm/debian/opt/cloud/bin/configure.py
+++ b/systemvm/debian/opt/cloud/bin/configure.py
@@ -196,7 +196,7 @@ class CsAcl(CsDataBag):
egressIpsetStr = ''
if sflag and dflag:
egressIpsetStr = " -m set --match-set %s src " % sourceIpsetName + \
- " -m set --match-set %s dst " % destIpsetName
+ " -m set --match-set %s dst " % destIpsetName
elif sflag:
egressIpsetStr = " -m set --match-set %s src " % sourceIpsetName
elif dflag:
@@ -204,10 +204,10 @@ class CsAcl(CsDataBag):
if rule['protocol'] == "icmp":
fwr += egressIpsetStr + " -p %s " % rule['protocol'] + " -m %s " % rule['protocol'] + \
- " --icmp-type %s" % icmp_type
+ " --icmp-type %s" % icmp_type
elif rule['protocol'] != "all":
fwr += egressIpsetStr + " -p %s " % rule['protocol'] + " -m %s " % rule['protocol'] + \
- " %s" % rnge
+ " %s" % rnge
elif rule['protocol'] == "all":
fwr += egressIpsetStr
@@ -1052,5 +1052,6 @@ def main(argv):
red.set()
return 0
+
if __name__ == "__main__":
main(sys.argv)
diff --git a/systemvm/debian/opt/cloud/bin/cs/CsProcess.py b/systemvm/debian/opt/cloud/bin/cs/CsProcess.py
index 6155f30..c3a42e5 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsProcess.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsProcess.py
@@ -42,10 +42,10 @@ class CsProcess(object):
self.pid = []
for i in CsHelper.execute("ps aux"):
items = len(self.search)
- proc = re.split("\s+", i)[items*-1:]
+ proc = re.split(r"\s+", i)[items*-1:]
matches = len([m for m in proc if m in self.search])
if matches == items:
- self.pid.append(re.split("\s+", i)[1])
+ self.pid.append(re.split(r"\s+", i)[1])
logging.debug("CsProcess:: Searching for process ==> %s and found PIDs ==> %s", self.search, self.pid)
return self.pid
@@ -61,5 +61,5 @@ class CsProcess(object):
def grep(self, str):
for i in CsHelper.execute("ps aux"):
if i.find(str) != -1:
- return re.split("\s+", i)[1]
+ return re.split(r"\s+", i)[1]
return -1
diff --git a/systemvm/debian/opt/cloud/bin/cs/CsRedundant.py b/systemvm/debian/opt/cloud/bin/cs/CsRedundant.py
index 29b5028..7fc2020 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsRedundant.py
@@ -127,7 +127,7 @@ class CsRedundant(object):
"%s/%s" % (self.CS_TEMPLATES_DIR, "checkrouter.sh.templ"), "/opt/cloud/bin/checkrouter.sh")
CsHelper.execute(
- 'sed -i "s/--exec\ \$DAEMON;/--exec\ \$DAEMON\ --\ --vrrp;/g" /etc/init.d/keepalived')
+ 'sed -i "s/--exec $DAEMON;/--exec $DAEMON -- --vrrp;/g" /etc/init.d/keepalived')
# checkrouter.sh configuration
check_router = CsFile("/opt/cloud/bin/checkrouter.sh")
check_router.greplace("[RROUTER_LOG]", self.RROUTER_LOG)
@@ -319,7 +319,7 @@ class CsRedundant(object):
logging.info("Adding gateway ==> %s to device ==> %s" % (gateway, dev))
if dev == CsHelper.PUBLIC_INTERFACES[self.cl.get_type()]:
route.add_defaultroute(gateway)
- except:
+ except Exception:
logging.error("ERROR getting gateway from device %s" % dev)
else:
logging.error("Device %s was not ready could not bring it up" % dev)
diff --git a/systemvm/debian/opt/cloud/bin/line_edit.py b/systemvm/debian/opt/cloud/bin/line_edit.py
index 5918883..ee6d818 100755
--- a/systemvm/debian/opt/cloud/bin/line_edit.py
+++ b/systemvm/debian/opt/cloud/bin/line_edit.py
@@ -193,6 +193,7 @@ class LineEditingFile(object):
os.unlink(changed_filename)
return changes
+
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
import doctest
diff --git a/systemvm/debian/opt/cloud/bin/update_config.py b/systemvm/debian/opt/cloud/bin/update_config.py
index c22aea0..f79e74c 100755
--- a/systemvm/debian/opt/cloud/bin/update_config.py
+++ b/systemvm/debian/opt/cloud/bin/update_config.py
@@ -112,6 +112,7 @@ def is_guestnet_configured(guestnet_dict, keys):
return exists
+
# If the command line json file is unprocessed process it
# This is important or, the control interfaces will get deleted!
if jsonFilename != "cmd_line.json" and os.path.isfile(jsonPath % "cmd_line.json"):
diff --git a/systemvm/debian/opt/cloud/bin/vmdata.py b/systemvm/debian/opt/cloud/bin/vmdata.py
index 65f5278..5cf22eb 100755
--- a/systemvm/debian/opt/cloud/bin/vmdata.py
+++ b/systemvm/debian/opt/cloud/bin/vmdata.py
@@ -164,5 +164,6 @@ def unflock(file):
sys.exit(1)
return True
+
if __name__ == "__main__":
main(sys.argv[1:])
diff --git a/systemvm/test/TestCsAddress.py b/systemvm/test/TestCsAddress.py
index 15e4e14..0ad9ae8 100644
--- a/systemvm/test/TestCsAddress.py
+++ b/systemvm/test/TestCsAddress.py
@@ -38,5 +38,6 @@ class TestCsAddress(unittest.TestCase):
def test_get_guest_netmask(self):
self.assertTrue(self.csaddress.get_guest_netmask() == "255.255.255.0")
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsApp.py b/systemvm/test/TestCsApp.py
index c5ea7a1..9296cf4 100644
--- a/systemvm/test/TestCsApp.py
+++ b/systemvm/test/TestCsApp.py
@@ -34,5 +34,6 @@ class TestCsApp(unittest.TestCase):
csapp = CsApp(csip)
self.assertTrue(csapp is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsCmdLine.py b/systemvm/test/TestCsCmdLine.py
index b89d65d..a945f39 100644
--- a/systemvm/test/TestCsCmdLine.py
+++ b/systemvm/test/TestCsCmdLine.py
@@ -42,5 +42,6 @@ class TestCsCmdLine(unittest.TestCase):
self.cscmdline.set_guest_gw(tval)
self.assertTrue(self.cscmdline.get_guest_gw() == tval)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsConfig.py b/systemvm/test/TestCsConfig.py
index c24700e..02f65a2 100644
--- a/systemvm/test/TestCsConfig.py
+++ b/systemvm/test/TestCsConfig.py
@@ -29,5 +29,6 @@ class TestCsConfig(unittest.TestCase):
csconfig = CsConfig()
self.assertTrue(csconfig is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsDatabag.py b/systemvm/test/TestCsDatabag.py
index bff4fe5..bd791c8 100644
--- a/systemvm/test/TestCsDatabag.py
+++ b/systemvm/test/TestCsDatabag.py
@@ -29,5 +29,6 @@ class TestCsDatabag(unittest.TestCase):
csdatabag = CsDataBag("koffie")
self.assertTrue(csdatabag is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsDhcp.py b/systemvm/test/TestCsDhcp.py
index 348f078..339fc6a 100644
--- a/systemvm/test/TestCsDhcp.py
+++ b/systemvm/test/TestCsDhcp.py
@@ -33,5 +33,6 @@ class TestCsDhcp(unittest.TestCase):
csdhcp = CsDhcp("dhcpentry", {})
self.assertTrue(csdhcp is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsFile.py b/systemvm/test/TestCsFile.py
index aeed8f2..8d12368 100644
--- a/systemvm/test/TestCsFile.py
+++ b/systemvm/test/TestCsFile.py
@@ -29,5 +29,6 @@ class TestCsFile(unittest.TestCase):
csfile = CsFile("testfile")
self.assertTrue(csfile is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsGuestNetwork.py b/systemvm/test/TestCsGuestNetwork.py
index 06e2d16..dd095e3 100644
--- a/systemvm/test/TestCsGuestNetwork.py
+++ b/systemvm/test/TestCsGuestNetwork.py
@@ -41,5 +41,6 @@ class TestCsGuestNetwork(unittest.TestCase):
dns = csguestnetwork.get_dns()
self.assertTrue(len(dns) == 2)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsHelper.py b/systemvm/test/TestCsHelper.py
index bae38e0..c3be13c 100644
--- a/systemvm/test/TestCsHelper.py
+++ b/systemvm/test/TestCsHelper.py
@@ -31,5 +31,6 @@ class TestCsHelper(unittest.TestCase):
result = CsHelper.execute("/bin/false")
self.assertTrue(result is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsInterface.py b/systemvm/test/TestCsInterface.py
index f30e599..08161a9 100644
--- a/systemvm/test/TestCsInterface.py
+++ b/systemvm/test/TestCsInterface.py
@@ -34,5 +34,6 @@ class TestCsInterface(unittest.TestCase):
def test_is_public(self):
self.assertTrue(self.csinterface.is_public() is False)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsNetfilter.py b/systemvm/test/TestCsNetfilter.py
index a64140d..9c4e282 100644
--- a/systemvm/test/TestCsNetfilter.py
+++ b/systemvm/test/TestCsNetfilter.py
@@ -29,5 +29,6 @@ class TestCsNetfilter(unittest.TestCase):
csnetfilter = CsNetfilter()
self.assertTrue(csnetfilter is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsProcess.py b/systemvm/test/TestCsProcess.py
index 78449ed..9e1c834 100644
--- a/systemvm/test/TestCsProcess.py
+++ b/systemvm/test/TestCsProcess.py
@@ -29,5 +29,6 @@ class TestCsProcess(unittest.TestCase):
csprocess = CsProcess({})
self.assertTrue(csprocess is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsRedundant.py b/systemvm/test/TestCsRedundant.py
index 1283d3d..7f99561 100644
--- a/systemvm/test/TestCsRedundant.py
+++ b/systemvm/test/TestCsRedundant.py
@@ -36,5 +36,6 @@ class TestCsRedundant(unittest.TestCase):
csredundant = CsRedundant(csconfig)
self.assertTrue(csredundant is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsRoute.py b/systemvm/test/TestCsRoute.py
index f9982fe..6d4ae6f 100644
--- a/systemvm/test/TestCsRoute.py
+++ b/systemvm/test/TestCsRoute.py
@@ -43,5 +43,6 @@ class TestCsRoute(unittest.TestCase):
name = "eth1"
self.assertEqual("Table_eth1", csroute.get_tablename(name))
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/TestCsRule.py b/systemvm/test/TestCsRule.py
index 2e37505..1dc3ba7 100644
--- a/systemvm/test/TestCsRule.py
+++ b/systemvm/test/TestCsRule.py
@@ -29,5 +29,6 @@ class TestCsRule(unittest.TestCase):
csrule = CsRule("eth1")
self.assertTrue(csrule is not None)
+
if __name__ == '__main__':
unittest.main()
diff --git a/systemvm/test/runtests.sh b/systemvm/test/runtests.sh
index 04290e7..94958e5 100644
--- a/systemvm/test/runtests.sh
+++ b/systemvm/test/runtests.sh
@@ -21,9 +21,9 @@
export PYTHONPATH="../debian/opt/cloud/bin/"
export PYTHONDONTWRITEBYTECODE=False
-echo "Running pep8 to check systemvm/python code for errors"
-pep8 --max-line-length=179 *py
-pep8 --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py`
+echo "Running pycodestyle to check systemvm/python code for errors"
+pycodestyle --max-line-length=179 *py
+pycodestyle --max-line-length=179 --exclude=monitorServices.py,baremetal-vr.py,passwd_server_ip.py `find ../debian -name \*.py`
if [ $? -gt 0 ]
then
echo "Pylint failed, please check your code"
diff --git a/tools/travis/before_install.sh b/tools/travis/before_install.sh
index c31213e..d6fb25c 100755
--- a/tools/travis/before_install.sh
+++ b/tools/travis/before_install.sh
@@ -22,6 +22,8 @@
#
echo -e "#### System Information ####"
+echo -e "\nO.S. information:"
+echo $(uname -a)
echo -e "\nWho am I:"
whoami
@@ -100,7 +102,7 @@ pip install --user --upgrade pip
for ((i=0;i<$RETRY_COUNT;i++))
do
- pip install --user --upgrade lxml paramiko nose texttable ipmisim pyopenssl mock flask netaddr pylint pep8 > /tmp/piplog
+ pip install --user --upgrade lxml paramiko nose texttable ipmisim pyopenssl mock flask netaddr pylint pycodestyle six astroid > /tmp/piplog
if [[ $? -eq 0 ]]; then
echo -e "\npython packages installed successfully"
break;
@@ -109,3 +111,5 @@ do
cat /tmp/piplog
done
+echo -e "\nVersion of pip packages:\n"
+echo $(pip freeze)
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
rafael@apache.org.