From: Varsha Rao Date: Mon, 10 Jun 2019 11:12:58 +0000 (+0530) Subject: cephfs-shell: Catch OSError exceptions in lcd X-Git-Tag: v14.2.2~23^2~17 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=73e2b97bac40e9d99b8494e6ee70a3060d3029d7;p=ceph.git cephfs-shell: Catch OSError exceptions in lcd This patch adds try-except statement to catch the OSError exceptions. Fixes: http://tracker.ceph.com/issues/40243 Signed-off-by: Varsha Rao (cherry picked from commit 4b958532e6c9648b73bdd78e0758ca6ddc4cf344) --- diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index cbd2753ea25..32a5b736775 100644 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -990,13 +990,11 @@ sub-directories, files') """ Moves into the given local directory """ - - path = os.path.expanduser(args.path) - if os.path.isdir(path): - os.chdir(path) - # self.poutput(get_all_possible_paths(args.path)) - else: - self.poutput("%s: no such directory" % path) + try: + os.chdir(os.path.expanduser(args.path)) + except OSError as e: + self.perror("Cannot change to {}: {}".format(e.filename, + e.strerror), False) def complete_lls(self, text, line, begidx, endidx): """