From 4b958532e6c9648b73bdd78e0758ca6ddc4cf344 Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Mon, 10 Jun 2019 16:42:58 +0530 Subject: [PATCH] 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 --- src/tools/cephfs/cephfs-shell | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index 67f2d9c1616..7f309aa8e93 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -1007,13 +1007,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): """ -- 2.39.5