Improve python3 compatibility
Use proper print() function to make scripts compatible with both python
2 and 3. This paves the way to deprecating python 2 support altogether.
Change-Id: I80e5850a8978d78cda793e2192ef4bd3fd54a121
diff --git a/scripts/osmotestvty.py b/scripts/osmotestvty.py
index e513c05..55017a5 100644
--- a/scripts/osmotestvty.py
+++ b/scripts/osmotestvty.py
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
+from __future__ import print_function
import os
import time
import unittest
@@ -36,11 +36,11 @@
osmo_vty_cmd[cfi] = os.path.join(confpath, osmo_vty_cmd[cfi])
try:
- print "Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd())
+ print("Launch: %s from %s" % (' '.join(osmo_vty_cmd), os.getcwd()))
self.proc = osmoutil.popen_devnull(osmo_vty_cmd)
except OSError:
- print >> sys.stderr, "Current directory: %s" % os.getcwd()
- print >> sys.stderr, "Consider setting -b"
+ print("Current directory: %s" % os.getcwd(), file=sys.stderr)
+ print("Consider setting -b", file=sys.stderr)
appstring = osmoappdesc.vty_app[2]
appport = osmoappdesc.vty_app[0]
@@ -94,9 +94,9 @@
osmoappdesc = osmoutil.importappconf_or_quit(confpath, "osmoappdesc",
args.p)
- print "confpath %s, workdir %s" % (confpath, workdir)
+ print("confpath %s, workdir %s" % (confpath, workdir))
os.chdir(workdir)
- print "Running tests for specific VTY commands"
+ print("Running tests for specific VTY commands")
suite = unittest.TestLoader().loadTestsFromTestCase(TestVTY)
res = unittest.TextTestRunner(verbosity=verbose_level).run(suite)
sys.exit(len(res.errors) + len(res.failures))