Execute: log stdout/stderr when command fails
This commit is contained in:
parent
ba75ae4ccc
commit
31ff64b537
|
@ -37,7 +37,7 @@ import os
|
||||||
import time
|
import time
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
from twisted.internet.utils import getProcessValue
|
from twisted.internet.utils import getProcessOutputAndValue
|
||||||
|
|
||||||
from deluge.plugins.pluginbase import CorePluginBase
|
from deluge.plugins.pluginbase import CorePluginBase
|
||||||
import deluge.component as component
|
import deluge.component as component
|
||||||
|
@ -112,9 +112,14 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
log.debug("[execute] Running commands for %s", event)
|
log.debug("[execute] Running commands for %s", event)
|
||||||
|
|
||||||
def log_error(exit_code, command):
|
def log_error(result, command):
|
||||||
|
(stdout, stderr, exit_code) = result
|
||||||
if exit_code:
|
if exit_code:
|
||||||
log.warn("[execute] command '%s' failed with exit code %d", command, exit_code)
|
log.warn("[execute] command '%s' failed with exit code %d", command, exit_code)
|
||||||
|
if stdout:
|
||||||
|
log.warn("[execute] stdout: %s", stdout)
|
||||||
|
if stderr:
|
||||||
|
log.warn("[execute] stderr: %s", stderr)
|
||||||
|
|
||||||
# Go through and execute all the commands
|
# Go through and execute all the commands
|
||||||
for command in self.config["commands"]:
|
for command in self.config["commands"]:
|
||||||
|
@ -122,7 +127,7 @@ class Core(CorePluginBase):
|
||||||
command = os.path.expandvars(command[EXECUTE_COMMAND])
|
command = os.path.expandvars(command[EXECUTE_COMMAND])
|
||||||
command = os.path.expanduser(command)
|
command = os.path.expanduser(command)
|
||||||
log.debug("[execute] running %s", command)
|
log.debug("[execute] running %s", command)
|
||||||
d = getProcessValue(command, (torrent_id, torrent_name, save_path), env=os.environ)
|
d = getProcessOutputAndValue(command, (torrent_id, torrent_name, save_path), env=os.environ)
|
||||||
d.addCallback(log_error, command)
|
d.addCallback(log_error, command)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
|
|
Loading…
Reference in New Issue