diff --git a/aiida/transports/plugins/local.py b/aiida/transports/plugins/local.py index cdb28d111..9ddab42c6 100644 --- a/aiida/transports/plugins/local.py +++ b/aiida/transports/plugins/local.py @@ -557,7 +557,7 @@ def copy(self, remotesource, remotedestination, dereference=False, recursive=Tru raise ValueError('Input remotedestination to copy must be a non empty object') if not self.has_magic(remotesource): if not os.path.exists(os.path.join(self.curdir, remotesource)): - raise OSError('Source not found') + raise FileNotFoundError('Source not found') if self.normalize(remotesource) == self.normalize(remotedestination): raise ValueError('Cannot copy from itself to itself') diff --git a/aiida/transports/plugins/ssh.py b/aiida/transports/plugins/ssh.py index 2696817e7..e8a3325a6 100644 --- a/aiida/transports/plugins/ssh.py +++ b/aiida/transports/plugins/ssh.py @@ -1203,6 +1203,7 @@ def copy(self, remotesource, remotedestination, dereference=False, recursive=Tru raise ValueError('Pathname patterns are not allowed in the destination') if self.has_magic(remotesource): + to_copy_list = self.glob(remotesource) if len(to_copy_list) > 1: @@ -1213,6 +1214,9 @@ def copy(self, remotesource, remotedestination, dereference=False, recursive=Tru self._exec_cp(cp_exe, cp_flags, file, remotedestination) else: + if not self.path_exists(remotesource): + raise FileNotFoundError('Source not found') + self._exec_cp(cp_exe, cp_flags, remotesource, remotedestination) def _exec_cp(self, cp_exe, cp_flags, src, dst):