Use except x as y instead of except x, y
According to https://docs.python.org/3/howto/pyporting.html the syntax changed in Python 3.x. The new syntax is usable with Python >= 2.6 and should be preferred to be compatible with Python3. Change-Id: I4a951aecc32ef9e5131da236ae4815b84897d67b
This commit is contained in:
@@ -33,7 +33,7 @@ finally:
|
|||||||
if uid != 0 and os.getuid() == 0:
|
if uid != 0 and os.getuid() == 0:
|
||||||
try:
|
try:
|
||||||
os.chown(PACKSTACK_VAR_DIR, uid, gid)
|
os.chown(PACKSTACK_VAR_DIR, uid, gid)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
print ('Unable to change owner of %s. Please fix ownership '
|
print ('Unable to change owner of %s. Please fix ownership '
|
||||||
'manually and try again.' % PACKSTACK_VAR_DIR)
|
'manually and try again.' % PACKSTACK_VAR_DIR)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ class PackstackDrone(SshTarballTransferMixin, Drone):
|
|||||||
local.execute(log=False)
|
local.execute(log=False)
|
||||||
# if we got to this point the puppet apply has finished
|
# if we got to this point the puppet apply has finished
|
||||||
return True
|
return True
|
||||||
except utils.ScriptRuntimeError, e:
|
except utils.ScriptRuntimeError as e:
|
||||||
# the test raises an exception if the file doesn't exist yet
|
# the test raises an exception if the file doesn't exist yet
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Step(object):
|
|||||||
# execute and report state
|
# execute and report state
|
||||||
try:
|
try:
|
||||||
self.function(config, messages)
|
self.function(config, messages)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
state = utils.state_message(self.title, 'ERROR', 'red')
|
state = utils.state_message(self.title, 'ERROR', 'red')
|
||||||
sys.stdout.write('%s\n' % state)
|
sys.stdout.write('%s\n' % state)
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ def process_cidr(param, process_args=None):
|
|||||||
return param
|
return param
|
||||||
try:
|
try:
|
||||||
return str(netaddr.IPNetwork(param).cidr)
|
return str(netaddr.IPNetwork(param).cidr)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
raise ParamProcessingError(str(ex))
|
raise ParamProcessingError(str(ex))
|
||||||
|
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ def process_host(param, process_args=None):
|
|||||||
process_args.get('allow_localhost', False)
|
process_args.get('allow_localhost', False)
|
||||||
try:
|
try:
|
||||||
return force_ip(param, allow_localhost=localhost)
|
return force_ip(param, allow_localhost=localhost)
|
||||||
except NetworkError, ex:
|
except NetworkError as ex:
|
||||||
raise ParamProcessingError(str(ex))
|
raise ParamProcessingError(str(ex))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ def process_param_value(param, value):
|
|||||||
else:
|
else:
|
||||||
logging.debug("Processor returned the original "
|
logging.debug("Processor returned the original "
|
||||||
"value: %s" % _value)
|
"value: %s" % _value)
|
||||||
except processors.ParamProcessingError, ex:
|
except processors.ParamProcessingError as ex:
|
||||||
print ("Value processing of parameter %s "
|
print ("Value processing of parameter %s "
|
||||||
"failed.\n%s" % (param.CONF_NAME, ex))
|
"failed.\n%s" % (param.CONF_NAME, ex))
|
||||||
raise
|
raise
|
||||||
@@ -628,7 +628,7 @@ def remove_remote_var_dirs():
|
|||||||
server.append('rm -rf %s' % host_dir)
|
server.append('rm -rf %s' % host_dir)
|
||||||
try:
|
try:
|
||||||
server.execute()
|
server.execute()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
msg = output_messages.ERR_REMOVE_REMOTE_VAR % (host_dir, host)
|
msg = output_messages.ERR_REMOVE_REMOTE_VAR % (host_dir, host)
|
||||||
logging.error(msg)
|
logging.error(msg)
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
@@ -914,7 +914,7 @@ def main():
|
|||||||
_set_command_line_values(options)
|
_set_command_line_values(options)
|
||||||
_main(confFile)
|
_main(confFile)
|
||||||
|
|
||||||
except FlagValidationError, ex:
|
except FlagValidationError as ex:
|
||||||
optParser.error(str(ex))
|
optParser.error(str(ex))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(traceback.format_exc())
|
logging.error(traceback.format_exc())
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def host2ip(hostname, allow_localhost=False):
|
|||||||
return get_localhost_ip()
|
return get_localhost_ip()
|
||||||
except socket.error:
|
except socket.error:
|
||||||
raise NetworkError('Unknown hostname %s.' % hostname)
|
raise NetworkError('Unknown hostname %s.' % hostname)
|
||||||
except Exception, ex:
|
except Exception as ex:
|
||||||
raise NetworkError('Unknown error appeared: %s' % repr(ex))
|
raise NetworkError('Unknown error appeared: %s' % repr(ex))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class ParameterTestCase(PackstackTestCaseMixin, TestCase):
|
|||||||
execute('echo "mask the password" && exit 1',
|
execute('echo "mask the password" && exit 1',
|
||||||
use_shell=True, mask_list=['password'])
|
use_shell=True, mask_list=['password'])
|
||||||
raise AssertionError('Masked execution failed.')
|
raise AssertionError('Masked execution failed.')
|
||||||
except ExecuteRuntimeError, ex:
|
except ExecuteRuntimeError as ex:
|
||||||
should_be = ('Failed to execute command, stdout: mask the %s\n\n'
|
should_be = ('Failed to execute command, stdout: mask the %s\n\n'
|
||||||
'stderr: ' % STR_MASK)
|
'stderr: ' % STR_MASK)
|
||||||
self.assertEqual(str(ex), should_be)
|
self.assertEqual(str(ex), should_be)
|
||||||
|
|||||||
Reference in New Issue
Block a user