fix for reactor.spawnProcess sending deprecation warning
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
# Copyright [2010] [Anso Labs, LLC]
|
# Copyright [2010] [Anso Labs, LLC]
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -118,7 +118,7 @@ class BackRelayWithInput(_BackRelay):
|
|||||||
|
|
||||||
def errReceivedIsGood(self, text):
|
def errReceivedIsGood(self, text):
|
||||||
self.stderr.write(text)
|
self.stderr.write(text)
|
||||||
|
|
||||||
def connectionMade(self):
|
def connectionMade(self):
|
||||||
if self.startedDeferred:
|
if self.startedDeferred:
|
||||||
self.startedDeferred.callback(self)
|
self.startedDeferred.callback(self)
|
||||||
@@ -151,6 +151,11 @@ def getProcessOutput(executable, args=None, env=None, path=None, reactor=None,
|
|||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
p = BackRelayWithInput(
|
p = BackRelayWithInput(
|
||||||
d, startedDeferred=startedDeferred, error_ok=error_ok, input=input)
|
d, startedDeferred=startedDeferred, error_ok=error_ok, input=input)
|
||||||
|
# VISH: commands come in as unicode, but self.executes needs
|
||||||
|
# strings or process.spawn raises a deprecation warning
|
||||||
|
executable = str(executable)
|
||||||
|
if not args is None:
|
||||||
|
args = [str(x) for x in args]
|
||||||
reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
|
reactor.spawnProcess(p, executable, (executable,)+tuple(args), env, path)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@@ -167,7 +172,7 @@ class ProcessPool(object):
|
|||||||
|
|
||||||
def simpleExecute(self, cmd, **kw):
|
def simpleExecute(self, cmd, **kw):
|
||||||
""" Weak emulation of the old utils.execute() function.
|
""" Weak emulation of the old utils.execute() function.
|
||||||
|
|
||||||
This only exists as a way to quickly move old execute methods to
|
This only exists as a way to quickly move old execute methods to
|
||||||
this new style of code.
|
this new style of code.
|
||||||
|
|
||||||
@@ -190,7 +195,7 @@ class ProcessPool(object):
|
|||||||
|
|
||||||
d.process = None
|
d.process = None
|
||||||
d.started = started
|
d.started = started
|
||||||
|
|
||||||
d.addCallback(lambda _: getProcessOutput(*args, **kw))
|
d.addCallback(lambda _: getProcessOutput(*args, **kw))
|
||||||
d.addBoth(self._release)
|
d.addBoth(self._release)
|
||||||
return d
|
return d
|
||||||
|
|||||||
Reference in New Issue
Block a user