Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cephfs-shell: Fix flake8 errors (E302, E502, E128, F821, W605, 5128, E122) #34254

Closed
wants to merge 8 commits into from
8 changes: 5 additions & 3 deletions src/tools/cephfs/cephfs-shell
Expand Up @@ -64,6 +64,7 @@ shell = None # holds instance of class CephFSShell
#
#######################################################################


def poutput(s, end='\n'):
shell.poutput(s, end=end)

Expand Down Expand Up @@ -111,13 +112,14 @@ def to_bytes(param):
elif isinstance(param, str):
return bytes(param, encoding='utf-8')
elif isinstance(param, list):
return [i.encode('utf-8') if isinstance(i, str) else to_bytes(i) for \
return [i.encode('utf-8') if isinstance(i, str) else to_bytes(i) for
i in param]
elif isinstance(param, int) or isinstance(param, float):
return str(param).encode('utf-8')
elif param is None:
return None


def ls(path, opts=''):
# opts tries to be like /bin/ls opts
almost_all = 'A' in opts
Expand All @@ -134,6 +136,7 @@ def ls(path, opts=''):
perror(e)
shell.exit_code = e.get_error_code()


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this change to a different commit.

def glob(path, pattern):
paths = []
parent_dir = os.path.dirname(path)
Expand Down Expand Up @@ -1220,7 +1223,7 @@ class CephFSShell(Cmd):
if f[0] is ord('/'):
f = b'.' + f
poutput('{:10s} {}'.format(humansize(dusage),
f.decode('utf-8')))
f.decode('utf-8')))
except libcephfs.Error as e:
perror(e)
self.exit_code = e.get_error_code()
Expand Down Expand Up @@ -1354,7 +1357,6 @@ class CephFSShell(Cmd):
else:
self.perror("snapshot can only be created or deleted; check - "
"help snap")
self.exit_code = e.get_error_code()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is wrong. Exit code is required and it should return 1 here .


def do_help(self, line):
"""
Expand Down