mirror of
https://github.com/clearml/clearml
synced 2025-05-03 04:21:00 +00:00
Don't strip the output of diff command
This commit is contained in:
parent
0b5c22d6dd
commit
79df2be26c
@ -75,17 +75,17 @@ class Detector(object):
|
|||||||
""" Returns a RepoInfo instance containing a command for each info attribute """
|
""" Returns a RepoInfo instance containing a command for each info attribute """
|
||||||
return self.Commands()
|
return self.Commands()
|
||||||
|
|
||||||
def _get_command_output(self, path, name, command):
|
def _get_command_output(self, path, name, command, strip=True):
|
||||||
""" Run a command and return its output """
|
""" Run a command and return its output """
|
||||||
try:
|
try:
|
||||||
return get_command_output(command, path)
|
return get_command_output(command, path, strip=strip)
|
||||||
|
|
||||||
except (CalledProcessError, UnicodeDecodeError) as ex:
|
except (CalledProcessError, UnicodeDecodeError) as ex:
|
||||||
if not name.endswith(self._fallback):
|
if not name.endswith(self._fallback):
|
||||||
fallback_command = attr.asdict(self._get_commands()).get(name + self._fallback)
|
fallback_command = attr.asdict(self._get_commands()).get(name + self._fallback)
|
||||||
if fallback_command:
|
if fallback_command:
|
||||||
try:
|
try:
|
||||||
return get_command_output(fallback_command, path)
|
return get_command_output(fallback_command, path, strip=strip)
|
||||||
except (CalledProcessError, UnicodeDecodeError):
|
except (CalledProcessError, UnicodeDecodeError):
|
||||||
pass
|
pass
|
||||||
_logger.warning("Can't get {} information for {} repo in {}".format(name, self.type_name, path))
|
_logger.warning("Can't get {} information for {} repo in {}".format(name, self.type_name, path))
|
||||||
@ -111,7 +111,7 @@ class Detector(object):
|
|||||||
|
|
||||||
info = Result(
|
info = Result(
|
||||||
**{
|
**{
|
||||||
name: self._get_command_output(path, name, command)
|
name: self._get_command_output(path, name, command, strip=bool(name != 'diff'))
|
||||||
for name, command in attr.asdict(commands).items()
|
for name, command in attr.asdict(commands).items()
|
||||||
if command and not name.endswith(self._fallback)
|
if command and not name.endswith(self._fallback)
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,15 @@ from subprocess import check_output
|
|||||||
from furl import furl
|
from furl import furl
|
||||||
|
|
||||||
|
|
||||||
def get_command_output(command, path=None):
|
def get_command_output(command, path=None, strip=True):
|
||||||
"""
|
"""
|
||||||
Run a command and return its output
|
Run a command and return its output
|
||||||
:raises CalledProcessError: when command execution fails
|
:raises CalledProcessError: when command execution fails
|
||||||
:raises UnicodeDecodeError: when output decoding fails
|
:raises UnicodeDecodeError: when output decoding fails
|
||||||
"""
|
"""
|
||||||
with open(os.devnull, "wb") as devnull:
|
with open(os.devnull, "wb") as devnull:
|
||||||
return check_output(command, cwd=path, stderr=devnull).decode().strip()
|
result = check_output(command, cwd=path, stderr=devnull).decode()
|
||||||
|
return result.strip() if strip else result
|
||||||
|
|
||||||
|
|
||||||
def remove_user_pass_from_url(url):
|
def remove_user_pass_from_url(url):
|
||||||
|
Loading…
Reference in New Issue
Block a user