mirror of
https://github.com/ceph/ceph
synced 2025-02-20 17:37:29 +00:00
cephfs-shell: Fix flake8 bare 'except' warnings
Instead of bare 'except', catch OSError and libcephfs exceptions. Fixes: https://tracker.ceph.com/issues/40191 Signed-off-by: Varsha Rao <varao@redhat.com>
This commit is contained in:
parent
6a0a5ed83d
commit
d063e8b1e0
@ -586,13 +586,13 @@ exists.')
|
||||
dst_dir[:-1]) and not locate_file(dst_dir):
|
||||
try:
|
||||
cephfs.mkdirs(to_bytes(dst_dir), 0o777)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
pass
|
||||
if (not args.force) and dst_dir != '/' and not is_dir_exists(
|
||||
dst_dir) and not os.path.isfile(root_src_dir):
|
||||
try:
|
||||
cephfs.mkdirs(to_bytes(dst_dir), 0o777)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
pass
|
||||
|
||||
for dir_ in dirs:
|
||||
@ -600,7 +600,7 @@ exists.')
|
||||
if not is_dir_exists(dir_name):
|
||||
try:
|
||||
cephfs.mkdirs(to_bytes(dir_name), 0o777)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
pass
|
||||
|
||||
for file_ in files:
|
||||
@ -654,7 +654,7 @@ exists.')
|
||||
if len(files) == 0:
|
||||
try:
|
||||
os.makedirs(root_dst_dir + '/' + root_src_dir)
|
||||
except:
|
||||
except OSError:
|
||||
if args.force:
|
||||
pass
|
||||
else:
|
||||
@ -670,7 +670,7 @@ exists.')
|
||||
if is_dir_exists(file_):
|
||||
try:
|
||||
os.makedirs(dst_path)
|
||||
except:
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
if not args.force:
|
||||
@ -678,7 +678,7 @@ exists.')
|
||||
os.stat(dst_path)
|
||||
self.poutput("%s: file already exists! use --force to override" % file_)
|
||||
return
|
||||
except:
|
||||
except OSError:
|
||||
copy_to_local(file_, dst_path)
|
||||
else:
|
||||
copy_to_local(file_, dst_path)
|
||||
@ -1176,7 +1176,7 @@ sub-directories, files')
|
||||
max_bytes, len(max_bytes),
|
||||
os.XATTR_CREATE)
|
||||
self.poutput('max_bytes set to %d' % args.max_bytes)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
cephfs.setxattr(to_bytes(args.dir), 'ceph.quota.max_bytes',
|
||||
max_bytes, len(max_bytes),
|
||||
os.XATTR_REPLACE)
|
||||
@ -1189,7 +1189,7 @@ sub-directories, files')
|
||||
max_files, len(max_files),
|
||||
os.XATTR_CREATE)
|
||||
self.poutput('max_files set to %d' % args.max_files)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
cephfs.setxattr(to_bytes(args.dir), 'ceph.quota.max_files',
|
||||
max_files, len(max_files),
|
||||
os.XATTR_REPLACE)
|
||||
@ -1201,7 +1201,7 @@ sub-directories, files')
|
||||
max_bytes = cephfs.getxattr(to_bytes(args.dir),
|
||||
'ceph.quota.max_bytes')
|
||||
self.poutput('max_bytes: %s' % max_bytes)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
self.poutput('max_bytes is not set')
|
||||
pass
|
||||
|
||||
@ -1209,7 +1209,7 @@ sub-directories, files')
|
||||
max_files = cephfs.getxattr(to_bytes(args.dir),
|
||||
'ceph.quota.max_files')
|
||||
self.poutput('max_files: %s' % max_files)
|
||||
except:
|
||||
except libcephfs.Error:
|
||||
self.poutput('max_files is not set')
|
||||
pass
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user