From 07688b96e1698c49af1aa6383cd19fbe4f50f7a8 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Tue, 9 Jul 2019 17:12:01 +0530 Subject: [PATCH] qa/vstart_runner.py: ignores when source and destination are same put_file() in vstart_runner.py should ignore the error when source and destination paths supplied are same, since source and destination for put_file() method in teuthology are on different machines, they represent different locations. Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index dd477a62f4f..42319bfe74c 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -231,8 +231,22 @@ class LocalRemote(object): shutil.copy(path, tmpfile) return tmpfile + # XXX: This method ignores the error raised when src and dst are + # holding same path. For teuthology, same path still represents + # different locations as they lie on different machines. def put_file(self, src, dst, sudo=False): - shutil.copy(src, dst) + if sys.version_info.major < 3: + exception = shutil.Error + elif sys.version_info.major >= 3: + exception = shutil.SameFileError + + try: + shutil.copy(src, dst) + except exception as e: + if sys.version_info.major < 3 and e.message.find('are the same ' + 'file') != -1: + return + raise e def _perform_checks_and_return_list_of_args(self, args, omit_sudo): # Since Python's shell simulation can only work when commands are -- 2.39.5