]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: Catch OSError exceptions in lcd
authorVarsha Rao <varao@redhat.com>
Mon, 10 Jun 2019 11:12:58 +0000 (16:42 +0530)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 20 Jun 2019 22:30:40 +0000 (15:30 -0700)
This patch adds try-except statement to catch the OSError exceptions.

Fixes: http://tracker.ceph.com/issues/40243
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit 4b958532e6c9648b73bdd78e0758ca6ddc4cf344)

src/tools/cephfs/cephfs-shell

index cbd2753ea259970fca67619c60adf2c2c59171d3..32a5b7367750d9ff960a8c47f9ff216dc0b3a46f 100644 (file)
@@ -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):
         """