Skip to content

Commit

Permalink
Merge pull request #209 from libanp/develop
Browse files Browse the repository at this point in the history
Fix version checks
  • Loading branch information
angelblue05 authored Feb 4, 2019
2 parents 712230f + de60e8d commit b0d8ee3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
26 changes: 8 additions & 18 deletions resources/lib/emby/core/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import socket
import time
from datetime import datetime
from distutils.version import LooseVersion

from credentials import Credentials
from http import HTTP
Expand Down Expand Up @@ -472,26 +473,15 @@ def _compare_versions(self, a, b):
1 a is larger
0 equal
'''
a = a.split('.')
b = b.split('.')
a = LooseVersion(a)
b = LooseVersion(b)

for i in range(0, max(len(a), len(b)), 1):
try:
aVal = a[i]
except IndexError:
aVal = 0

try:
bVal = b[i]
except IndexError:
bVal = 0

if aVal < bVal:
return -1

if aVal > bVal:
return 1
if a < b:
return -1

if a > b:
return 1

return 0

def _string_equals_ignore_case(self, str1, str2):
Expand Down
24 changes: 7 additions & 17 deletions resources/lib/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import unicodedata
import urllib
from uuid import uuid4
from distutils.version import LooseVersion

import xbmc
import xbmcaddon
Expand Down Expand Up @@ -95,25 +96,14 @@ def compare_version(a, b):
1 a is larger
0 equal
'''
a = a.split('.')
b = b.split('.')
a = LooseVersion(a)
b = LooseVersion(b)

for i in range(0, max(len(a), len(b)), 1):
try:
aVal = a[i]
except IndexError:
aVal = 0
if a < b:
return -1

try:
bVal = b[i]
except IndexError:
bVal = 0

if aVal < bVal:
return -1

if aVal > bVal:
return 1
if a > b:
return 1

return 0

Expand Down

0 comments on commit b0d8ee3

Please sign in to comment.