Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
clinton-hall committed Jan 4, 2020
2 parents 2e7d4a5 + 1cca1b7 commit a320ac5
Show file tree
Hide file tree
Showing 19 changed files with 861 additions and 358 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 12.1.02
current_version = 12.1.03
commit = True
tag = False

Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
maxParallel: 5

steps:
- script: sudo apt-get install ffmpeg
- script: |
sudo apt-get update
sudo apt-get install ffmpeg
displayName: 'Install ffmpeg'
- task: UsePythonVersion@0
Expand Down
25 changes: 17 additions & 8 deletions core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
wake_up,
)

__version__ = '12.1.02'
__version__ = '12.1.03'

# Client Agents
NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual']
Expand Down Expand Up @@ -983,13 +983,22 @@ def check_python():

# Log warning if within grace period
days_left = eol.lifetime()
logger.info(
'Python v{major}.{minor} will reach end of life in {x} days.'.format(
major=sys.version_info[0],
minor=sys.version_info[1],
x=days_left,
),
)
if days_left > 0:
logger.info(
'Python v{major}.{minor} will reach end of life in {x} days.'.format(
major=sys.version_info[0],
minor=sys.version_info[1],
x=days_left,
),
)
else:
logger.info(
'Python v{major}.{minor} reached end of life {x} days ago.'.format(
major=sys.version_info[0],
minor=sys.version_info[1],
x=-days_left,
),
)
if days_left <= grace_period:
logger.warning('Please upgrade to a more recent Python version.')

Expand Down
6 changes: 3 additions & 3 deletions core/plugins/downloaders/torrent/deluge.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
unicode_literals,
)

from synchronousdeluge.client import DelugeClient
from deluge_client.client import DelugeRPCClient

import core
from core import logger
Expand All @@ -19,9 +19,9 @@ def configure_client():
password = core.DELUGE_PASSWORD

logger.debug('Connecting to {0}: http://{1}:{2}'.format(agent, host, port))
client = DelugeClient()
client = DelugeRPCClient(host, port, user, password)
try:
client.connect(host, port, user, password)
client.connect()
except Exception:
logger.error('Failed to connect to Deluge')
else:
Expand Down
27 changes: 18 additions & 9 deletions core/utils/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import os

from six import text_type
from six import PY2

import core
from core import logger

if not PY2:
from builtins import bytes

def char_replace(name):

def char_replace(name_in):
# Special character hex range:
# CP850: 0x80-0xA5 (fortunately not used in ISO-8859-15)
# UTF-8: 1st hex code 0xC2-0xC3 followed by a 2nd hex code 0xA1-0xFF
Expand All @@ -22,31 +26,36 @@ def char_replace(name):
# If there is special character, detects if it is a UTF-8, CP850 or ISO-8859-15 encoding
encoded = False
encoding = None
if isinstance(name, text_type):
return encoded, name.encode(core.SYS_ENCODING)
if isinstance(name_in, text_type):
return encoded, name_in.encode(core.SYS_ENCODING)
if PY2:
name = name_in
else:
name = bytes(name_in)
for Idx in range(len(name)):
print('Trying to intuit the encoding')
# /!\ detection is done 2char by 2char for UTF-8 special character
if (len(name) != 1) & (Idx < (len(name) - 1)):
# Detect UTF-8
if ((name[Idx] == '\xC2') | (name[Idx] == '\xC3')) & (
(name[Idx + 1] >= '\xA0') & (name[Idx + 1] <= '\xFF')):
if ((name[Idx] == 0xC2) | (name[Idx] == 0xC3)) & (
(name[Idx + 1] >= 0xA0) & (name[Idx + 1] <= 0xFF)):
encoding = 'utf-8'
break
# Detect CP850
elif (name[Idx] >= '\x80') & (name[Idx] <= '\xA5'):
elif (name[Idx] >= 0x80) & (name[Idx] <= 0xA5):
encoding = 'cp850'
break
# Detect ISO-8859-15
elif (name[Idx] >= '\xA6') & (name[Idx] <= '\xFF'):
elif (name[Idx] >= 0xA6) & (name[Idx] <= 0xFF):
encoding = 'iso-8859-15'
break
else:
# Detect CP850
if (name[Idx] >= '\x80') & (name[Idx] <= '\xA5'):
if (name[Idx] >= 0x80) & (name[Idx] <= 0xA5):
encoding = 'cp850'
break
# Detect ISO-8859-15
elif (name[Idx] >= '\xA6') & (name[Idx] <= '\xFF'):
elif (name[Idx] >= 0xA6) & (name[Idx] <= 0xFF):
encoding = 'iso-8859-15'
break
if encoding and not encoding == core.SYS_ENCODING:
Expand Down
2 changes: 1 addition & 1 deletion core/utils/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def parse_deluge(args):
input_hash = args[1]
input_id = args[1]
try:
input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get()['label']
input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get(b'label').decode()
except Exception:
input_category = ''
return input_directory, input_name, input_category, input_hash, input_id
Expand Down
2 changes: 1 addition & 1 deletion eol.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def check(version=None, grace_period=0):
:return: None
"""
try:
raise_for_status(version, grace_period)
warn_for_status(version, grace_period)
except LifetimeError as error:
print('Please use a newer version of Python.')
print_statuses()
Expand Down
Empty file.
Loading

0 comments on commit a320ac5

Please sign in to comment.