execvp passes pep8

This commit is contained in:
Eric Windisch
2011-03-09 15:33:20 -05:00
parent 866048da04
commit f8a7c12219
2 changed files with 11 additions and 10 deletions

View File

@@ -316,7 +316,7 @@ class IptablesFirewallTestCase(test.TestCase):
# self.fw.add_instance(instance_ref) # self.fw.add_instance(instance_ref)
def fake_iptables_execute(*cmd, **kwargs): def fake_iptables_execute(*cmd, **kwargs):
process_input=kwargs.get('process_input', None) process_input = kwargs.get('process_input', None)
if cmd == ('sudo', 'ip6tables-save', '-t', 'filter'): if cmd == ('sudo', 'ip6tables-save', '-t', 'filter'):
return '\n'.join(self.in6_rules), None return '\n'.join(self.in6_rules), None
if cmd == ('sudo', 'iptables-save', '-t', 'filter'): if cmd == ('sudo', 'iptables-save', '-t', 'filter'):

View File

@@ -40,7 +40,7 @@ import netaddr
from eventlet import event from eventlet import event
from eventlet import greenthread from eventlet import greenthread
from eventlet.green import subprocess from eventlet.green import subprocess
None
from nova import exception from nova import exception
from nova.exception import ProcessExecutionError from nova.exception import ProcessExecutionError
from nova import log as logging from nova import log as logging
@@ -129,13 +129,13 @@ def fetchfile(url, target):
def execute(*cmd, **kwargs): def execute(*cmd, **kwargs):
process_input=kwargs.get('process_input', None) process_input = kwargs.get('process_input', None)
addl_env=kwargs.get('addl_env', None) addl_env = kwargs.get('addl_env', None)
check_exit_code=kwargs.get('check_exit_code', 0) check_exit_code = kwargs.get('check_exit_code', 0)
stdin=kwargs.get('stdin', subprocess.PIPE) stdin = kwargs.get('stdin', subprocess.PIPE)
stdout=kwargs.get('stdout', subprocess.PIPE) stdout = kwargs.get('stdout', subprocess.PIPE)
stderr=kwargs.get('stderr', subprocess.PIPE) stderr = kwargs.get('stderr', subprocess.PIPE)
cmd=map(str,cmd) cmd = map(str, cmd)
LOG.debug(_("Running cmd (subprocess): %s"), ' '.join(cmd)) LOG.debug(_("Running cmd (subprocess): %s"), ' '.join(cmd))
env = os.environ.copy() env = os.environ.copy()
@@ -151,7 +151,8 @@ def execute(*cmd, **kwargs):
obj.stdin.close() obj.stdin.close()
if obj.returncode: if obj.returncode:
LOG.debug(_("Result was %s") % obj.returncode) LOG.debug(_("Result was %s") % obj.returncode)
if check_exit_code is not None and obj.returncode != check_exit_code: if type(check_exit_code) == types.IntType \
and obj.returncode != check_exit_code:
(stdout, stderr) = result (stdout, stderr) = result
raise ProcessExecutionError(exit_code=obj.returncode, raise ProcessExecutionError(exit_code=obj.returncode,
stdout=stdout, stdout=stdout,