]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: Fix flake8 bare 'except' warnings
authorVarsha Rao <varao@redhat.com>
Mon, 13 May 2019 11:43:39 +0000 (17:13 +0530)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 20 Jun 2019 22:39:17 +0000 (15:39 -0700)
Instead of bare 'except', catch just libcephfs exceptions.

Fixes: https://tracker.ceph.com/issues/39717
Signed-off-by: Varsha Rao <varao@redhat.com>
(cherry picked from commit e6b6cf4ba5814e80da22b3b95b3686831202e483)

src/tools/cephfs/cephfs-shell

index 03999a004a2b581acc42cc6790691c455d60ca2a..49aeae26db0992d31cbb7f26f4207cf929d24317 100644 (file)
@@ -110,7 +110,7 @@ def list_items(dir_name=''):
     else:
         try:
             d = cephfs.opendir(dir_name)
-        except:
+        except libcephfs.Error:
             dir_name = dir_name.decode('utf-8')
             return []
     dent = cephfs.readdir(d)
@@ -209,7 +209,7 @@ def is_dir_exists(dir_name, dir_=''):
     path_to_stat = os.path.join(dir_, dir_name)
     try:
         return ((cephfs.stat(path_to_stat).st_mode & 0o0040000) != 0)
-    except:
+    except libcephfs.Error:
         return False
 
 
@@ -221,7 +221,7 @@ def is_file_exists(file_name, dir_=''):
     try:
         # if its not a directory, then its a file
         return ((cephfs.stat(os.path.join(dir_, file_name)).st_mode & 0o0040000) == 0)
-    except:
+    except libcephfs.Error:
         return False
 
 
@@ -501,7 +501,7 @@ exists.')
             else:
                 try:
                     cephfs.mkdir(path, permission)
-                except:
+                except libcephfs.Error:
                     self.poutput("directory missing in the path; "
                                  "you may want to pass the -p argument")
                     return
@@ -819,7 +819,7 @@ sub-directories, files')
             if not is_pattern and dir_path != os.path.normpath(path):
                 try:
                     cephfs.rmdir(to_bytes(dir_path))
-                except:
+                except libcephfs.Error:
                     self.poutput('error: no such directory "%s"' % dir_path)
 
     def complete_rm(self, text, line, begidx, endidx):
@@ -844,7 +844,7 @@ sub-directories, files')
             else:
                 try:
                     cephfs.unlink(to_bytes(file_path))
-                except:
+                except libcephfs.Error:
                     self.poutput('%s: no such file' % file_path)
 
     def complete_mv(self, text, line, begidx, endidx):
@@ -865,7 +865,7 @@ sub-directories, files')
         """
         try:
             cephfs.rename(to_bytes(args.src_path), to_bytes(args.dest_path))
-        except:
+        except libcephfs.Error:
             self.poutput("error: need a file name to move to")
 
     def complete_cd(self, text, line, begidx, endidx):
@@ -894,7 +894,7 @@ sub-directories, files')
         else:
             try:
                 cephfs.chdir(to_bytes(args.dir_name))
-            except:
+            except libcephfs.Error:
                 self.poutput("%s: no such directory" % args.dir_name)
         self.working_dir = cephfs.getcwd().decode('utf-8')
         self.set_prompt()
@@ -923,7 +923,7 @@ sub-directories, files')
         mode = int(args.mode, base=8)
         try:
             cephfs.chmod(args.file_name, mode)
-        except:
+        except libcephfs.Error:
             self.poutput('%s: no such file or directory' % args.file_name)
 
     def complete_cat(self, text, line, begidx, endidx):