From f71c907a0eb6a04af2f98b5f96b6d7b1be645bd0 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Sat, 30 Jun 2018 18:35:59 +0300 Subject: [PATCH] ssh: choose md5 command depending on the os Signed-off-by: Ruslan Kuprieiev --- dvc/remote/ssh.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dvc/remote/ssh.py b/dvc/remote/ssh.py index ce20efd4d..749f0b750 100644 --- a/dvc/remote/ssh.py +++ b/dvc/remote/ssh.py @@ -1,5 +1,4 @@ import os -import re import errno import getpass import filecmp @@ -104,10 +103,24 @@ class RemoteSSH(RemoteBase): raise NotImplementedError ssh = self.ssh(host=path_info['host'], user=path_info['user']) - stdout = self._exec(ssh, 'md5sum {}'.format(path_info['path'])) - md5 = re.match(r'^(?P.*) .*$', stdout).group('md5') + + # Use different md5 commands depending on os + stdout = self._exec(ssh, 'uname').strip() + if stdout == 'Darwin': + md5cmd = 'md5' + index = -1 + elif stdout == 'Linux': + md5cmd = 'md5sum' + index = 0 + else: + raise DvcException('\'{}\' is not supported as a remote'.format(stdout)) + + stdout = self._exec(ssh, '{} {}'.format(md5cmd, path_info['path'])) + md5 = stdout.split()[index] ssh.close() + assert len(md5) == 32 + return md5 def cp(self, from_info, to_info):