From 116e426d5a23b441f75f4d4c8f6eb0b28fb481f2 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Tue, 29 May 2018 14:46:53 +0800 Subject: [PATCH] vcs: collect errors into log This fixes #39. --- nvchecker/source/vcs.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/nvchecker/source/vcs.py b/nvchecker/source/vcs.py index 046a77f..51c2867 100644 --- a/nvchecker/source/vcs.py +++ b/nvchecker/source/vcs.py @@ -1,5 +1,5 @@ # MIT licensed -# Copyright (c) 2013-2017 lilydjwg , et al. +# Copyright (c) 2013-2018 lilydjwg , et al. import asyncio import os.path as _path @@ -34,12 +34,19 @@ async def get_version(name, conf, **kwargs): cmd = _cmd_prefix + [name, vcs] if use_max_tag: cmd += ["get_tags"] - p = await asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE) + p = await asyncio.create_subprocess_exec( + *cmd, + stdout=asyncio.subprocess.PIPE, + stderr=asyncio.subprocess.PIPE, + ) + + output, error = await p.communicate() + output = output.strip().decode('latin1') + error = error.strip().decode('latin1') - output = (await p.communicate())[0].strip().decode('latin1') if p.returncode != 0: - logger.error('command exited with error', - name=name, returncode=p.returncode) + logger.error('command exited with error', output=output, + name=name, returncode=p.returncode, error=error) return else: if use_max_tag: