]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-shell: drop LooseVersion for version.parse
authorJos Collin <jcollin@redhat.com>
Tue, 19 Sep 2023 10:01:56 +0000 (15:31 +0530)
committerJos Collin <jcollin@redhat.com>
Tue, 19 Sep 2023 14:13:19 +0000 (19:43 +0530)
Fixes: https://tracker.ceph.com/issues/62739
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/tools/cephfs/shell/cephfs-shell

index 60ad79c6126cc5eb4de79939523c42ca840d7808..bdd1bb4f0b2b09c4abd49a2c71770be1e0be0df9 100755 (executable)
@@ -16,13 +16,13 @@ import shlex
 import stat
 import errno
 
-from distutils.version import LooseVersion
+from packaging import version
 
 from cmd2 import Cmd
 from cmd2 import __version__ as cmd2_version
 # XXX: In cmd2 versions < 1.0.1, we'll get SystemExit(2) instead of
 # Cmd2ArgparseError
-if LooseVersion(cmd2_version) >= LooseVersion("1.0.1"):
+if version.parse(cmd2_version) >= version.parse("1.0.1"):
     from cmd2.exceptions import Cmd2ArgparseError
 else:
     # HACK: so that we don't have check for version everywhere
@@ -1700,11 +1700,11 @@ def read_shell_conf(shell, shell_conf_file):
 
     sec = 'cephfs-shell'
     opts = []
-    if LooseVersion(cmd2_version) >= LooseVersion("0.10.0"):
+    if version.parse(cmd2_version) >= version.parse("0.10.0"):
         for attr in shell.settables.keys():
             opts.append(attr)
     else:
-        if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
+        if version.parse(cmd2_version) <= version.parse("0.9.13"):
             # hardcoding options for 0.7.9 because -
             # 1. we use cmd2 v0.7.9 with teuthology and
             # 2. there's no way distinguish between a shell setting and shell
@@ -1713,7 +1713,7 @@ def read_shell_conf(shell, shell_conf_file):
                     'continuation_prompt', 'debug', 'echo', 'editor',
                     'feedback_to_output', 'locals_in_py', 'prompt', 'quiet',
                     'timing']
-        elif LooseVersion(cmd2_version) >= LooseVersion("0.9.23"):
+        elif version.parse(cmd2_version) >= version.parse("0.9.23"):
             opts.append('allow_style')
         # no equivalent option was defined by cmd2.
         else:
@@ -1768,7 +1768,7 @@ def manage_args():
     args.exe_and_quit = False    # Execute and quit, don't launch the shell.
 
     if args.batch:
-        if LooseVersion(cmd2_version) <= LooseVersion("0.9.13"):
+        if version.parse(cmd2_version) <= version.parse("0.9.13"):
             args.commands = ['load ' + args.batch, ',quit']
         else:
             args.commands = ['run_script ' + args.batch, ',quit']
@@ -1813,7 +1813,7 @@ def execute_cmds_and_quit(args):
     # 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 LooseVersion(cmd2_version) <= LooseVersion("0.9.6"):
+    if version.parse(cmd2_version) <= version.parse("0.9.6"):
         stop_exec_val = None
     else:
         stop_exec_val = False