Merge pull request #832 from efiop/master

ssh: choose md5 command depending on the os
This commit is contained in:
Ruslan Kuprieiev
2018-06-30 18:41:13 +03:00
committed by GitHub
+16 -3
View File
@@ -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<md5>.*) .*$', 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):