Merge pull request #409 from adam111316/feature/ChangePy2Imports1

Change py2 queue, httplib, cookielib and xmlrpclib to py2/3 compatibl…
This commit is contained in:
adam111316 2015-06-14 10:48:39 +08:00
commit 16fa92dd80
6 changed files with 14 additions and 13 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
import threading
from Queue import Queue, Empty
from six.moves.queue import Queue, Empty
class Event:
def __init__(self, type):

View file

@ -17,7 +17,7 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import socket
from httplib import HTTPSConnection, HTTPException
from six.moves.http_client import HTTPSConnection, HTTPException
from urllib import urlencode
try:

View file

@ -18,7 +18,7 @@
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
import socket
from httplib import HTTPSConnection, HTTPException
from six.moves.http_client import HTTPSConnection, HTTPException
from urllib import urlencode
from ssl import SSLError

View file

@ -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:

View file

@ -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: