summaryrefslogtreecommitdiff
path: root/tests/topotests/lib/topogen.py
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2019-04-30 11:31:02 -0400
committerMark Stapp <mjs@voltanet.io>2019-04-30 11:31:02 -0400
commita07e17d5e78bb4d16c12e5b2b8767daafe2fc47e (patch)
treefab6c2704c40c5b63830de112ffbac13ac3302a9 /tests/topotests/lib/topogen.py
parentf799ea3f940dc8107e677f4349fcd542cf01305b (diff)
topotest: fixes to support python3
Make some small changes to support both python 2 and 3. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'tests/topotests/lib/topogen.py')
-rw-r--r--tests/topotests/lib/topogen.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py
index d989240a16..0bc1596eb2 100644
--- a/tests/topotests/lib/topogen.py
+++ b/tests/topotests/lib/topogen.py
@@ -42,7 +42,12 @@ import os
import sys
import logging
import json
-import ConfigParser
+
+if sys.version_info[0] > 2:
+ import configparser
+else:
+ import ConfigParser as configparser
+
import glob
import grp
import platform
@@ -153,7 +158,7 @@ class Topogen(object):
Loads the configuration file `pytest.ini` located at the root dir of
topotests.
"""
- self.config = ConfigParser.ConfigParser(tgen_defaults)
+ self.config = configparser.ConfigParser(tgen_defaults)
pytestini_path = os.path.join(CWD, '../pytest.ini')
self.config.read(pytestini_path)
@@ -599,7 +604,7 @@ class TopoRouter(TopoGear):
def _prepare_tmpfiles(self):
# Create directories if they don't exist
try:
- os.makedirs(self.logdir, 0755)
+ os.makedirs(self.logdir, 0o755)
except OSError:
pass
@@ -608,10 +613,10 @@ class TopoRouter(TopoGear):
# Only allow group, if it exist.
gid = grp.getgrnam(self.routertype)[2]
os.chown(self.logdir, 0, gid)
- os.chmod(self.logdir, 0775)
+ os.chmod(self.logdir, 0o775)
except KeyError:
# Allow anyone, but set the sticky bit to avoid file deletions
- os.chmod(self.logdir, 01777)
+ os.chmod(self.logdir, 0o1777)
# Try to find relevant old logfiles in /tmp and delete them
map(os.remove, glob.glob('{}/{}/*.log'.format(self.logdir, self.name)))
@@ -931,7 +936,7 @@ def diagnose_env_linux():
logger.info('Running environment diagnostics')
# Load configuration
- config = ConfigParser.ConfigParser(tgen_defaults)
+ config = configparser.ConfigParser(tgen_defaults)
pytestini_path = os.path.join(CWD, '../pytest.ini')
config.read(pytestini_path)