From: Varsha Rao Date: Mon, 10 Jun 2019 11:12:58 +0000 (+0530) Subject: cephfs-shell: Catch OSError exceptions in lcd X-Git-Tag: v15.1.0~2475^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4b958532e6c9648b73bdd78e0758ca6ddc4cf344;p=ceph-ci.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 --- 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): """