mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
ifupdownaddons: mstpctlutil: fixing 'UnboundLocalError: local variable referenced before assignment'. Also, now catching subprocess.CalledProcessError exception and general Exception.
Ticket: None Reviewed By: Roopa Testing Done: ifreload -a (vxlan interface file)
This commit is contained in:
@@ -77,8 +77,9 @@ class mstpctlutil(utilsBase):
|
|||||||
try:
|
try:
|
||||||
showall_output = self.subprocess_check_output(['/sbin/mstpctl',
|
showall_output = self.subprocess_check_output(['/sbin/mstpctl',
|
||||||
'showportdetail', bridgename, 'json'])
|
'showportdetail', bridgename, 'json'])
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
self.logger.warn(str(e))
|
||||||
|
return
|
||||||
if not showall_output or showall_output == '':
|
if not showall_output or showall_output == '':
|
||||||
return
|
return
|
||||||
showall_output = showall_output.strip('\n')
|
showall_output = showall_output.strip('\n')
|
||||||
|
@@ -99,9 +99,12 @@ class utilsBase(object):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output(cmdl, stderr=subprocess.STDOUT)
|
return subprocess.check_output(cmdl, stderr=subprocess.STDOUT)
|
||||||
except Exception, e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise Exception('failed to execute cmd \'%s\' (%s)'
|
raise Exception('failed to execute cmd \'%s\' (%s)'
|
||||||
%(' '.join(cmdl), e.output))
|
%(' '.join(cmdl), e.output))
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception('failed to execute cmd \'%s\' (%s)'
|
||||||
|
%(' '.join(cmdl), str(e)))
|
||||||
|
|
||||||
def subprocess_check_call(self, cmdl):
|
def subprocess_check_call(self, cmdl):
|
||||||
""" subprocess check_call implementation using popen
|
""" subprocess check_call implementation using popen
|
||||||
|
Reference in New Issue
Block a user