diff --git a/CHANGES.md b/CHANGES.md index 3a6380ec..0befb056 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -36,6 +36,7 @@ * Change py2 print statements to py2/3 compatible functions * Change py2 octal literals into the new py2/3 syntax * Change py2 iteritems to py2/3 compatible statements using six library +* Change py2 queue, httplib, cookielib and xmlrpclib to py2/3 compatible calls using six * Change Kodi notifier to use requests as opposed to urllib * Change to consolidate scene exceptions and name cache code * Change check_url function to use requests instead of httplib library diff --git a/sickbeard/event_queue.py b/sickbeard/event_queue.py index aeb0c000..ad9bf770 100644 --- a/sickbeard/event_queue.py +++ b/sickbeard/event_queue.py @@ -1,5 +1,5 @@ import threading -from Queue import Queue, Empty +from six.moves.queue import Queue, Empty class Event: def __init__(self, type): diff --git a/sickbeard/notifiers/prowl.py b/sickbeard/notifiers/prowl.py index 6ef1b79b..206e4eea 100644 --- a/sickbeard/notifiers/prowl.py +++ b/sickbeard/notifiers/prowl.py @@ -17,7 +17,7 @@ # along with SickGear. If not, see . import socket -from httplib import HTTPSConnection, HTTPException +from six.moves.http_client import HTTPSConnection, HTTPException from urllib import urlencode try: diff --git a/sickbeard/notifiers/pushalot.py b/sickbeard/notifiers/pushalot.py index e12044a6..8821622d 100644 --- a/sickbeard/notifiers/pushalot.py +++ b/sickbeard/notifiers/pushalot.py @@ -18,7 +18,7 @@ # along with SickGear. If not, see . import socket -from httplib import HTTPSConnection, HTTPException +from six.moves.http_client import HTTPSConnection, HTTPException from urllib import urlencode from ssl import SSLError diff --git a/sickbeard/nzbget.py b/sickbeard/nzbget.py index cf47edef..94e58799 100644 --- a/sickbeard/nzbget.py +++ b/sickbeard/nzbget.py @@ -18,14 +18,14 @@ -import httplib import datetime import re import sickbeard from base64 import standard_b64encode -import xmlrpclib +from six.moves import xmlrpc_client +from six.moves import http_client from sickbeard.providers.generic import GenericProvider @@ -50,20 +50,20 @@ def sendNZB(nzb, proper=False): url = nzbgetXMLrpc % {"host": sickbeard.NZBGET_HOST, "username": sickbeard.NZBGET_USERNAME, "password": sickbeard.NZBGET_PASSWORD} - nzbGetRPC = xmlrpclib.ServerProxy(url) + nzbGetRPC = xmlrpc_client.ServerProxy(url) try: if nzbGetRPC.writelog("INFO", "SickGear connected to drop off %s any moment now." % (nzb.name + ".nzb")): logger.log(u"Successfully connected to NZBget", logger.DEBUG) else: logger.log(u"Successfully connected to NZBget, but unable to send a message", logger.ERROR) - except httplib.socket.error: + except http_client.socket.error: logger.log( u"Please check your NZBget host and port (if it is running). NZBget is not responding to this combination", logger.ERROR) return False - except xmlrpclib.ProtocolError as e: + except xmlrpc_client.ProtocolError as e: if (e.errmsg == "Unauthorized"): logger.log(u"NZBget username or password is incorrect.", logger.ERROR) else: diff --git a/sickbeard/sab.py b/sickbeard/sab.py index 6e00d559..cc274c68 100644 --- a/sickbeard/sab.py +++ b/sickbeard/sab.py @@ -18,14 +18,14 @@ import urllib -import httplib +from six.moves import http_client import datetime import sickbeard from lib import MultipartPostHandler import urllib2 -import cookielib +from six.moves import http_cookiejar try: import json @@ -90,7 +90,7 @@ def sendNZB(nzb): # if we are uploading the NZB data to SAB then we need to build a little POST form and send it elif nzb.resultType == "nzbdata": - cookies = cookielib.CookieJar() + cookies = http_cookiejar.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies), MultipartPostHandler.MultipartPostHandler) req = urllib2.Request(url, @@ -103,7 +103,7 @@ def sendNZB(nzb): logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR) return False - except httplib.InvalidURL as e: + except http_client.InvalidURL as e: logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR) return False @@ -175,7 +175,7 @@ def _sabURLOpenSimple(url): except (EOFError, IOError) as e: logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR) return False, "Unable to connect" - except httplib.InvalidURL as e: + except http_client.InvalidURL as e: logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR) return False, "Invalid SABnzbd host" if f is None: