parent
c1803944ba
commit
6698ed806e
1 changed files with 8 additions and 2 deletions
|
@ -25,6 +25,12 @@ import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
try:
|
||||||
|
from subprocess import DEVNULL # Only in python >= 3.3
|
||||||
|
except ImportError:
|
||||||
|
import os
|
||||||
|
DEVNULL = open(os.devnull, 'wb')
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class Executor(threading.Thread):
|
class Executor(threading.Thread):
|
||||||
|
@ -51,7 +57,7 @@ class Executor(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
log.debug('executing %s', self.command)
|
log.debug('executing %s', self.command)
|
||||||
stdout = None
|
stdout = DEVNULL
|
||||||
if self.filename:
|
if self.filename:
|
||||||
try:
|
try:
|
||||||
stdout = open(self.filename, self.redirection_mode)
|
stdout = open(self.filename, self.redirection_mode)
|
||||||
|
@ -59,7 +65,7 @@ class Executor(threading.Thread):
|
||||||
log.error('Could not open redirection file: %s', self.filename, exc_info=True)
|
log.error('Could not open redirection file: %s', self.filename, exc_info=True)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
subprocess.call(self.command, stdout=stdout)
|
subprocess.call(self.command, stdout=stdout, stderr=DEVNULL)
|
||||||
except:
|
except:
|
||||||
if self.remote:
|
if self.remote:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
Loading…
Reference in a new issue