Skip to content

Commit 9737a3c

Browse files
Guillaume De Saint MartinGuillaumeDSM
authored andcommitted
[Deps] use packaging.version
1 parent 629df78 commit 9737a3c

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

octobot/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# You should have received a copy of the GNU General Public
1515
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.
1616

17-
from distutils.version import LooseVersion
17+
import packaging.version as packaging_version
1818

1919
import argparse
2020
import os
@@ -399,7 +399,7 @@ def main(args=None):
399399
try:
400400
from octobot_tentacles_manager import VERSION
401401

402-
if LooseVersion(VERSION) < MIN_TENTACLE_MANAGER_VERSION:
402+
if packaging_version.Version(VERSION) < packaging_version.Version(MIN_TENTACLE_MANAGER_VERSION):
403403
print("OctoBot requires OctoBot-Tentacles-Manager in a minimum version of " + MIN_TENTACLE_MANAGER_VERSION +
404404
" you can install and update OctoBot-Tentacles-Manager using the following command: "
405405
"python3 -m pip install -U OctoBot-Tentacles-Manager", file=sys.stderr)

octobot/community/feeds/community_mqtt_feed.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
#
1414
# You should have received a copy of the GNU General Public
1515
# License along with OctoBot. If not, see <https://www.gnu.org/licenses/>.
16-
import time
1716
import uuid
1817
import gmqtt
1918
import json
2019
import zlib
2120
import asyncio
22-
import distutils.version as loose_version
21+
import packaging.version as packaging_version
2322

2423
import octobot_commons.enums as commons_enums
2524
import octobot_commons.errors as commons_errors
@@ -182,8 +181,8 @@ def _build_message(self, channel_type, message):
182181
return {}
183182

184183
def _ensure_supported(self, parsed_message):
185-
if loose_version.LooseVersion(parsed_message[commons_enums.CommunityFeedAttrs.VERSION.value]) \
186-
< loose_version.LooseVersion(constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION):
184+
if packaging_version.Version(parsed_message[commons_enums.CommunityFeedAttrs.VERSION.value]) \
185+
< packaging_version.Version(constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION):
187186
raise commons_errors.UnsupportedError(
188187
f"Minimum version: {constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION}"
189188
)

octobot/community/feeds/community_ws_feed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import asyncio
2121
import enum
2222
import json
23-
import distutils.version as loose_version
23+
import packaging.version as packaging_version
2424

2525
import octobot_commons.errors as commons_errors
2626
import octobot_commons.enums as commons_enums
@@ -119,8 +119,8 @@ async def consume(self, message):
119119
self.logger.error(f"Unsupported message: {e}")
120120

121121
def _ensure_supported(self, parsed_message):
122-
if loose_version.LooseVersion(parsed_message[commons_enums.CommunityFeedAttrs.VERSION.value]) \
123-
< loose_version.LooseVersion(constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION):
122+
if packaging_version.Version(parsed_message[commons_enums.CommunityFeedAttrs.VERSION.value]) \
123+
< packaging_version.Version(constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION):
124124
raise commons_errors.UnsupportedError(
125125
f"Minimum version: {constants.COMMUNITY_FEED_CURRENT_MINIMUM_VERSION}"
126126
)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ colorlog==4.7.2
1616
yarl==1.7.2
1717
idna<2.9,>=2.5
1818
requests==2.25.1
19+
packaging==21.3
1920

2021
# Community
2122
websockets

0 commit comments

Comments
 (0)