mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-19 15:28:28 +01:00
Windows symlink: exec cmd as shell option; small os.path.join() test fix
This commit is contained in:
+3
-2
@@ -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
@@ -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
@@ -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
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user