diff --git a/systemvm/debian/opt/cloud/bin/configure.py b/systemvm/debian/opt/cloud/bin/configure.py index a3b7674926c..b94333fe977 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 6155f3031d1..c3a42e5a8b3 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 29b502895aa..7fc2020b6f7 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 5918883ea96..ee6d818431e 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 c22aea03b4f..f79e74c828f 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 65f52789771..5cf22eb5d8f 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 15e4e143062..0ad9ae861b9 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 c5ea7a1b8c4..9296cf48ea1 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 b89d65d37aa..a945f396b31 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 c24700e5105..02f65a2c99f 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 bff4fe516fa..bd791c8d911 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 348f078368d..339fc6a6d7e 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 aeed8f257f3..8d12368b8cc 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 06e2d16cc4a..dd095e33eee 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 bae38e0a9b0..c3be13c62d3 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 f30e599a172..08161a943c3 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 a64140dfeab..9c4e282ff75 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 78449eda326..9e1c8340bbd 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 1283d3d6a40..7f995613059 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 f9982fe1f8f..6d4ae6fd7bd 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 2e3750511ea..1dc3ba7d97e 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 04290e77608..94958e531b0 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 c31213ee052..d6fb25cfbb3 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