Merge pull request #7125 from qlyoung/what-the-frick-robert

tools: fix vtysh failure error handling
This commit is contained in:
Donatas Abraitis 2020-09-18 10:38:13 +03:00 committed by GitHub
commit b0164b18eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -128,17 +128,13 @@ class Vtysh(object):
% (child.returncode))
def mark_file(self, filename, stdin=None):
kwargs = {}
if stdin is not None:
kwargs['stdin'] = stdin
child = self._call(['-m', '-f', filename],
stdout=subprocess.PIPE, **kwargs)
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
try:
stdout, stderr = child.communicate()
except subprocess.TimeoutExpired:
child.kill()
stdout, stderr = proc.communicate()
stdout, stderr = child.communicate()
raise VtyshException('vtysh call timed out!')
if child.wait() != 0:
@ -1313,8 +1309,12 @@ if __name__ == '__main__':
# Create a Config object from the config generated by newconf
newconf = Config(vtysh)
newconf.load_from_file(args.filename)
reload_ok = True
try:
newconf.load_from_file(args.filename)
reload_ok = True
except VtyshException as ve:
log.error("vtysh failed to process new configuration: {}".format(ve))
reload_ok = False
if args.test: