Windows symlink: exec cmd as shell option; small os.path.join() test fix

This commit is contained in:
Dmitry Petrov
2017-04-08 17:57:16 -07:00
parent 4ce1e43041
commit b706f60959
4 changed files with 6 additions and 7 deletions
+3 -2
View File
@@ -10,7 +10,7 @@ class ExecutorError(DvcException):
class Executor:
@staticmethod
def exec_cmd(cmd, stdout_file=None, stderr_file=None, cwd=None):
def exec_cmd(cmd, stdout_file=None, stderr_file=None, cwd=None, shell=False):
stdout, stdout_fd = Executor.output_file(stdout_file)
stderr, stderr_fd = Executor.output_file(stderr_file)
@@ -18,7 +18,8 @@ class Executor:
p = subprocess.Popen(cmd,
cwd=cwd,
stdout=stdout,
stderr=stderr)
stderr=stderr,
shell=False)
p.wait()
out, err = map(lambda s: s.decode().strip('\n\r') if s else '', p.communicate())
+1 -1
View File
@@ -40,7 +40,7 @@ class Runtime(object):
return False
# It is definitely not the best way to check a symlink.
code, output, _ = Executor.exec_cmd(["dir", path])
code, output, _ = Executor.exec_cmd(["dir", path], shell=True)
if code != 0:
return False
+1 -3
View File
@@ -20,9 +20,7 @@ def cached_property(f):
def rmtree(dir):
'''Cross platform rmtree()'''
if os.name == 'nt':
if not os.access(dir, os.W_OK):
if os.path.exists(dir) and not os.access(dir, os.W_OK):
os.chmod(dir, stat.S_IWUSR)
else:
raise
shutil.rmtree(dir, ignore_errors=True)
+1 -1
View File
@@ -71,7 +71,7 @@ class DirHierarchyEnvironment(BasicEnvironment):
self.settings = Settings([], self._git, self._config)
self.dir1 = os.path.join('dir1')
self.dir11 = os.path.join('dir1/dir11')
self.dir11 = os.path.join('dir1', 'dir11')
self.dir2 = os.path.join('dir2')
os.mkdir('cache')