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