Address shutil.copy() failure when running a scheduler instance without
remote drones.

Signed-off-by: James Ren <jamesren@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@3945 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/scheduler/drone_utility.py b/scheduler/drone_utility.py
index 3ec4c97..82f8b79 100755
--- a/scheduler/drone_utility.py
+++ b/scheduler/drone_utility.py
@@ -251,7 +251,7 @@
         contents of the directory are copied; otherwise, the directory iself is
         copied.
         """
-        if source_path.rstrip('/') == destination_path.rstrip('/'):
+        if self._same_file(source_path, destination_path):
             return
         self._ensure_directory_exists(os.path.dirname(destination_path))
         if source_path.endswith('/'):
@@ -272,6 +272,17 @@
             shutil.copy(source_path, destination_path)
 
 
+    def _same_file(self, source_path, destination_path):
+        """Checks if the source and destination are the same
+
+        Returns True if the destination is the same as the source, False
+        otherwise. Also returns False if the destination does not exist.
+        """
+        if not os.path.exists(destination_path):
+            return False
+        return os.path.samefile(source_path, destination_path)
+
+
     def wait_for_all_async_commands(self):
         for subproc in self._subcommands:
             subproc.fork_waitfor()