From ef75ea4afb889c51997a47f2512b3733241dc0eb Mon Sep 17 00:00:00 2001 From: Varsha Rao Date: Mon, 4 May 2020 17:37:04 +0530 Subject: [PATCH] cephfs-shell: Remove get_error_code() call on OSError type exception objects OSError type exception has no attribute 'get_error_code'. Insead use errno to fetch error code. Fixes: https://tracker.ceph.com/issues/45373 Signed-off-by: Varsha Rao --- src/tools/cephfs/cephfs-shell | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/tools/cephfs/cephfs-shell b/src/tools/cephfs/cephfs-shell index 007bd4e5d9aeb..0bde6d34e9d68 100755 --- a/src/tools/cephfs/cephfs-shell +++ b/src/tools/cephfs/cephfs-shell @@ -714,7 +714,7 @@ class CephFSShell(Cmd): else: perror('{}: already exists! use --force to overwrite'.format( root_src_dir.decode('utf-8'))) - self.exit_code = e.get_error_code() + self.exit_code = e.errno return for file_ in files: @@ -1065,7 +1065,7 @@ class CephFSShell(Cmd): os.chdir(os.path.expanduser(args.path)) except OSError as e: perror("Cannot change to {}: {}".format(e.filename, e.strerror)) - self.exit_code = e.get_error_code() + self.exit_code = e.errno def complete_lls(self, text, line, begidx, endidx): """ @@ -1094,7 +1094,7 @@ class CephFSShell(Cmd): print_list(items) except OSError as e: perror("'{}': {}".format(e.filename, e.strerror)) - self.exit_code = e.get_error_code() + self.exit_code = e.errno # Arguments to the with_argpaser decorator function are sticky. # The items in args.path do not get overwritten in subsequent calls. # The arguments remain in args.paths after the function exits and we @@ -1530,7 +1530,10 @@ def read_ceph_conf(shell, config_file): shell.prompt = get_bool_vals_for_boolopts(cephfs.conf_get('prompt')) shell.quiet = get_bool_vals_for_boolopts(cephfs.conf_get('quiet')) shell.timing = get_bool_vals_for_boolopts(cephfs.conf_get('timing')) - except (OSError, libcephfs.Error) as e: + except OSError as e: + perror(e) + shell.exit_code = e.errno + except libcephfs.Error as e: perror(e) shell.exit_code = e.get_error_code() -- 2.47.3