]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerVarsha Rao <varao@redhat.com>
Mon, 10 Jun 2019 14:46:28 +0000 (20:16 +0530)
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>
src/tools/cephfs/cephfs-shell

index 67f2d9c1616e9e4aae87a280388b0b36a3d70179..7f309aa8e93966a68d7e73b672ff5e346f727c95 100755 (executable)
@@ -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):
         """