mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-29 06:29:40 +00:00
Merge pull request #4232 from mjstapp/fix_topotests_py3
topotest: fixes to support python3
This commit is contained in:
commit
bcbce7b283
@ -42,7 +42,12 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import ConfigParser
|
|
||||||
|
if sys.version_info[0] > 2:
|
||||||
|
import configparser
|
||||||
|
else:
|
||||||
|
import ConfigParser as configparser
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
import grp
|
import grp
|
||||||
import platform
|
import platform
|
||||||
@ -153,7 +158,7 @@ class Topogen(object):
|
|||||||
Loads the configuration file `pytest.ini` located at the root dir of
|
Loads the configuration file `pytest.ini` located at the root dir of
|
||||||
topotests.
|
topotests.
|
||||||
"""
|
"""
|
||||||
self.config = ConfigParser.ConfigParser(tgen_defaults)
|
self.config = configparser.ConfigParser(tgen_defaults)
|
||||||
pytestini_path = os.path.join(CWD, '../pytest.ini')
|
pytestini_path = os.path.join(CWD, '../pytest.ini')
|
||||||
self.config.read(pytestini_path)
|
self.config.read(pytestini_path)
|
||||||
|
|
||||||
@ -599,7 +604,7 @@ class TopoRouter(TopoGear):
|
|||||||
def _prepare_tmpfiles(self):
|
def _prepare_tmpfiles(self):
|
||||||
# Create directories if they don't exist
|
# Create directories if they don't exist
|
||||||
try:
|
try:
|
||||||
os.makedirs(self.logdir, 0755)
|
os.makedirs(self.logdir, 0o755)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -608,10 +613,10 @@ class TopoRouter(TopoGear):
|
|||||||
# Only allow group, if it exist.
|
# Only allow group, if it exist.
|
||||||
gid = grp.getgrnam(self.routertype)[2]
|
gid = grp.getgrnam(self.routertype)[2]
|
||||||
os.chown(self.logdir, 0, gid)
|
os.chown(self.logdir, 0, gid)
|
||||||
os.chmod(self.logdir, 0775)
|
os.chmod(self.logdir, 0o775)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# Allow anyone, but set the sticky bit to avoid file deletions
|
# 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
|
# Try to find relevant old logfiles in /tmp and delete them
|
||||||
map(os.remove, glob.glob('{}/{}/*.log'.format(self.logdir, self.name)))
|
map(os.remove, glob.glob('{}/{}/*.log'.format(self.logdir, self.name)))
|
||||||
@ -931,7 +936,7 @@ def diagnose_env_linux():
|
|||||||
logger.info('Running environment diagnostics')
|
logger.info('Running environment diagnostics')
|
||||||
|
|
||||||
# Load configuration
|
# Load configuration
|
||||||
config = ConfigParser.ConfigParser(tgen_defaults)
|
config = configparser.ConfigParser(tgen_defaults)
|
||||||
pytestini_path = os.path.join(CWD, '../pytest.ini')
|
pytestini_path = os.path.join(CWD, '../pytest.ini')
|
||||||
config.read(pytestini_path)
|
config.read(pytestini_path)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user