Fix compatibility with cmd2 >= 2.3.0

cmd2.fg and cmd2.bg have been deprecated in cmd2 2.3.0 and removed
in cmd2 2.4.0.  Let's work around this by a version check.

Related upstream commits:

commit f57b08672af97f9d973148b6c30d74fe4e712d14
Author: Kevin Van Brunt <kmvanbrunt@gmail.com>
Date:   Mon Oct 11 15:20:46 2021 -0400

and

commit f217861feae45a0a1abb56436e68c5dd859d64c0
Author: Kevin Van Brunt <kmvanbrunt@gmail.com>
Date:   Wed Feb 16 13:34:13 2022 -0500

Change-Id: I9fd32c0fd8f6d40e00a318602af97c288605e8e5
This commit is contained in:
Harald Welte 2022-06-23 08:55:24 +02:00
parent bda52830c9
commit 225e06059c
2 changed files with 7 additions and 2 deletions

View File

@ -23,7 +23,13 @@ import json
import traceback
import cmd2
from cmd2 import style, fg, bg
from cmd2 import style
# cmd2 >= 2.3.0 has deprecated the bg/fg in favor of Bg/Fg :(
from packaging import version
if version.parse(cmd2.__version__) < version.parse("2.3.0"):
from cmd2 import fg, bg
else:
from cmd2 import Fg as fg, Bg as bg
from cmd2 import CommandSet, with_default_category, with_argparser
import argparse

View File

@ -20,7 +20,6 @@
from typing import List
import cmd2
from cmd2 import style, fg, bg
from cmd2 import CommandSet, with_default_category, with_argparser
import argparse