From 6acbc2cc2587b14397bbf5b21927a10e26d43920 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= <sybren@stuvel.eu>
Date: Thu, 15 Nov 2018 12:43:22 +0100
Subject: [PATCH] Fix logging failed command

---
 flamenco_worker/commands.py | 8 ++++----
 tests/test_runner.py        | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/flamenco_worker/commands.py b/flamenco_worker/commands.py
index d26ecdfc..0c8fb5eb 100644
--- a/flamenco_worker/commands.py
+++ b/flamenco_worker/commands.py
@@ -508,12 +508,12 @@ class AbstractSubprocessCommand(AbstractCommand):
                     await self.worker.register_log(processed_line)
 
             retcode = await self.proc.wait()
-            cmdline = ' '.join(shlex.quote(arg) for arg in args)
-            self._log.info('Command %r (pid=%d) stopped with status code %s', cmdline, pid, retcode)
+            self._log.info('Command %s (pid=%d) stopped with status code %s',
+                           cmd_to_log, pid, retcode)
 
             if retcode:
-                raise CommandExecutionError('Command %r (pid=%d) failed with status %s' %
-                                            (cmdline, pid, retcode))
+                raise CommandExecutionError('Command %s (pid=%d) failed with status %s' %
+                                            (cmd_to_log, pid, retcode))
         except asyncio.CancelledError:
             self._log.info('asyncio task got canceled, killing subprocess pid=%d', pid)
             await self.abort()
diff --git a/tests/test_runner.py b/tests/test_runner.py
index 9c0f83e9..829dca00 100644
--- a/tests/test_runner.py
+++ b/tests/test_runner.py
@@ -162,11 +162,11 @@ class ExecCommandTest(AbstractCommandTest):
                  '%s -c \'raise SystemExit("¡FAIL!")\'' % sys.executable),
             call('pid=%d > ¡FAIL!' % pid),  # note the logged line doesn't end in a newline
             call('exec.(task_id=12345, command_idx=0): Error executing: '
-                 'Command pid=%d failed with status 1' % pid)
+                 'Command %s (pid=%d) failed with status 1' % (settings['cmd'], pid))
         ])
 
         # The update should NOT contain a new task status -- that is left to the Worker.
         self.fworker.register_task_update.assert_called_with(
             activity='exec.(task_id=12345, command_idx=0): Error executing: '
-                     'Command pid=%d failed with status 1' % pid,
+                     'Command %s (pid=%d) failed with status 1' % (settings['cmd'], pid),
         )
-- 
GitLab