moved 'path exists' function to shell

now it will work with powershell/winrm
This commit is contained in:
Brian Coca 2016-03-25 08:13:44 -07:00
parent 81d9066ee1
commit 28d20dbe53
4 changed files with 29 additions and 8 deletions

View file

@ -94,6 +94,22 @@ class ShellModule(object):
script = 'Write-Host "%s"' % self._escape(user_home_path)
return self._encode_script(script)
def exists(self, path):
path = self._escape(self._unquote(path))
script = '''
If (Test-Path "%s")
{
$res = 0;
}
Else
{
$res = 1;
}
Write-Host "$res";
Exit $res;
''' % path
return self._encode_script(script)
def checksum(self, path, *args, **kwargs):
path = self._escape(self._unquote(path))
script = '''