import shlex
import stat
import errno
+import distro
from cmd2 import Cmd
from cmd2 import __version__ as cmd2_version
from packaging.version import Version
+# DFLAG is used to override the checks done by cephfs-shell
+# for cmd2 versions due to weird behaviour of Ubuntu22.04 with
+# cmd2's version i.e. it always gets the version of cmd2 as
+# "0.0.0" instead of the actual cmd2 version.
+DFLAG = False
+if distro.name() == "Ubuntu" and distro.version() == "22.04":
+ DFLAG = True
# XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
# Cmd2ArgparseError
-if Version(cmd2_version) >= Version("1.0.1"):
+if Version(cmd2_version) >= Version("1.0.1") or DFLAG is True:
from cmd2.exceptions import Cmd2ArgparseError
else:
# HACK: so that we don't have check for version everywhere
sec = 'cephfs-shell'
opts = []
- if Version(cmd2_version) >= Version("0.10.0"):
+ if Version(cmd2_version) >= Version("0.10.0") or DFLAG is True:
for attr in shell.settables.keys():
opts.append(attr)
else:
args.exe_and_quit = False # Execute and quit, don't launch the shell.
if args.batch:
- if Version(cmd2_version) <= Version("0.9.13"):
+ if Version(cmd2_version) <= Version("0.9.13") and DFLAG is not True:
args.commands = ['load ' + args.batch, ',quit']
else:
args.commands = ['run_script ' + args.batch, ',quit']
# value to indicate whether the execution of the commands should stop, but
# since 0.9.7 it returns the return value of do_* methods only if it's
# not None. When it is None it returns False instead of None.
- if Version(cmd2_version) <= Version("0.9.6"):
+ if Version(cmd2_version) <= Version("0.9.6") and DFLAG is not True:
stop_exec_val = None
else:
stop_exec_val = False