mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 21:53:37 +00:00
Change queue, httplib, cookielib and xmlrpclib to use explicit import lib/six.moves.
This commit is contained in:
parent
2193064fff
commit
3d602398ad
6 changed files with 21 additions and 22 deletions
|
@ -52,6 +52,7 @@
|
||||||
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)
|
* Update Requests library 2.7.0 (ab1f493) to 2.7.0 (8b5e457)
|
||||||
* Update Tornado webserver from 4.2.dev1 (609dbb9) to 4.2b1 (61a16c9)
|
* Update Tornado webserver from 4.2.dev1 (609dbb9) to 4.2b1 (61a16c9)
|
||||||
* Change reload_module call to explicit import lib/six.moves
|
* Change reload_module call to explicit import lib/six.moves
|
||||||
|
* Change queue, httplib, cookielib and xmlrpclib to use explicit import lib/six.moves
|
||||||
|
|
||||||
|
|
||||||
### 0.9.1 (2015-05-25 03:03:00 UTC)
|
### 0.9.1 (2015-05-25 03:03:00 UTC)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
from lib.six import moves
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
from six.moves.queue import Queue, Empty
|
|
||||||
|
|
||||||
class Event:
|
class Event:
|
||||||
def __init__(self, type):
|
def __init__(self, type):
|
||||||
|
@ -12,7 +13,7 @@ class Event:
|
||||||
class Events(threading.Thread):
|
class Events(threading.Thread):
|
||||||
def __init__(self, callback):
|
def __init__(self, callback):
|
||||||
super(Events, self).__init__()
|
super(Events, self).__init__()
|
||||||
self.queue = Queue()
|
self.queue = moves.Queue()
|
||||||
self.daemon = True
|
self.daemon = True
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.name = "EVENT-QUEUE"
|
self.name = "EVENT-QUEUE"
|
||||||
|
@ -32,7 +33,7 @@ class Events(threading.Thread):
|
||||||
|
|
||||||
# event completed
|
# event completed
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
except Empty:
|
except moves.Empty:
|
||||||
type = None
|
type = None
|
||||||
|
|
||||||
# exiting thread
|
# exiting thread
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from lib.six import moves
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
from six.moves.http_client import HTTPSConnection, HTTPException
|
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -75,7 +76,7 @@ class ProwlNotifier:
|
||||||
|
|
||||||
logger.log("PROWL: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, api=%s" % (event, message, prowl_priority, prowl_api), logger.DEBUG)
|
logger.log("PROWL: Sending notice with details: event=\"%s\", message=\"%s\", priority=%s, api=%s" % (event, message, prowl_priority, prowl_api), logger.DEBUG)
|
||||||
|
|
||||||
http_handler = HTTPSConnection("api.prowlapp.com")
|
http_handler = moves.http_client.HTTPSConnection("api.prowlapp.com")
|
||||||
|
|
||||||
data = {'apikey': prowl_api,
|
data = {'apikey': prowl_api,
|
||||||
'application': title,
|
'application': title,
|
||||||
|
@ -88,7 +89,7 @@ class ProwlNotifier:
|
||||||
"/publicapi/add",
|
"/publicapi/add",
|
||||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||||
body=urlencode(data))
|
body=urlencode(data))
|
||||||
except (SSLError, HTTPException, socket.error):
|
except (SSLError, moves.http_client.HTTPException, socket.error):
|
||||||
logger.log(u"Prowl notification failed.", logger.ERROR)
|
logger.log(u"Prowl notification failed.", logger.ERROR)
|
||||||
return False
|
return False
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
|
|
|
@ -17,8 +17,9 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from lib.six import moves
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
from six.moves.http_client import HTTPSConnection, HTTPException
|
|
||||||
from urllib import urlencode
|
from urllib import urlencode
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ class PushalotNotifier:
|
||||||
logger.log(u"Pushalot message: " + message, logger.DEBUG)
|
logger.log(u"Pushalot message: " + message, logger.DEBUG)
|
||||||
logger.log(u"Pushalot api: " + pushalot_authorizationtoken, logger.DEBUG)
|
logger.log(u"Pushalot api: " + pushalot_authorizationtoken, logger.DEBUG)
|
||||||
|
|
||||||
http_handler = HTTPSConnection("pushalot.com")
|
http_handler = moves.http_client.HTTPSConnection("pushalot.com")
|
||||||
|
|
||||||
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
data = {'AuthorizationToken': pushalot_authorizationtoken,
|
||||||
'Title': event.encode('utf-8'),
|
'Title': event.encode('utf-8'),
|
||||||
|
@ -78,7 +79,7 @@ class PushalotNotifier:
|
||||||
"/api/sendmessage",
|
"/api/sendmessage",
|
||||||
headers={'Content-type': "application/x-www-form-urlencoded"},
|
headers={'Content-type': "application/x-www-form-urlencoded"},
|
||||||
body=urlencode(data))
|
body=urlencode(data))
|
||||||
except (SSLError, HTTPException, socket.error):
|
except (SSLError, moves.http_client.HTTPException, socket.error):
|
||||||
logger.log(u"Pushalot notification failed.", logger.ERROR)
|
logger.log(u"Pushalot notification failed.", logger.ERROR)
|
||||||
return False
|
return False
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
|
|
|
@ -16,16 +16,13 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from lib.six import moves
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import re
|
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from base64 import standard_b64encode
|
from base64 import standard_b64encode
|
||||||
from six.moves import xmlrpc_client
|
|
||||||
from six.moves import http_client
|
|
||||||
|
|
||||||
from sickbeard.providers.generic import GenericProvider
|
from sickbeard.providers.generic import GenericProvider
|
||||||
|
|
||||||
|
@ -50,20 +47,20 @@ def sendNZB(nzb, proper=False):
|
||||||
url = nzbgetXMLrpc % {"host": sickbeard.NZBGET_HOST, "username": sickbeard.NZBGET_USERNAME,
|
url = nzbgetXMLrpc % {"host": sickbeard.NZBGET_HOST, "username": sickbeard.NZBGET_USERNAME,
|
||||||
"password": sickbeard.NZBGET_PASSWORD}
|
"password": sickbeard.NZBGET_PASSWORD}
|
||||||
|
|
||||||
nzbGetRPC = xmlrpc_client.ServerProxy(url)
|
nzbGetRPC = moves.xmlrpc_client.ServerProxy(url)
|
||||||
try:
|
try:
|
||||||
if nzbGetRPC.writelog("INFO", "SickGear connected to drop off %s any moment now." % (nzb.name + ".nzb")):
|
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)
|
logger.log(u"Successfully connected to NZBget", logger.DEBUG)
|
||||||
else:
|
else:
|
||||||
logger.log(u"Successfully connected to NZBget, but unable to send a message", logger.ERROR)
|
logger.log(u"Successfully connected to NZBget, but unable to send a message", logger.ERROR)
|
||||||
|
|
||||||
except http_client.socket.error:
|
except moves.http_client.socket.error:
|
||||||
logger.log(
|
logger.log(
|
||||||
u"Please check your NZBget host and port (if it is running). NZBget is not responding to this combination",
|
u"Please check your NZBget host and port (if it is running). NZBget is not responding to this combination",
|
||||||
logger.ERROR)
|
logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except xmlrpc_client.ProtocolError as e:
|
except moves.xmlrpc_client.ProtocolError as e:
|
||||||
if (e.errmsg == "Unauthorized"):
|
if (e.errmsg == "Unauthorized"):
|
||||||
logger.log(u"NZBget username or password is incorrect.", logger.ERROR)
|
logger.log(u"NZBget username or password is incorrect.", logger.ERROR)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -16,16 +16,14 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from six import moves
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
from six.moves import http_client
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
|
||||||
from lib import MultipartPostHandler
|
from lib import MultipartPostHandler
|
||||||
import urllib2
|
import urllib2
|
||||||
from six.moves import http_cookiejar
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -90,7 +88,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
|
# 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":
|
elif nzb.resultType == "nzbdata":
|
||||||
cookies = http_cookiejar.CookieJar()
|
cookies = moves.http_cookiejar.CookieJar()
|
||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),
|
||||||
MultipartPostHandler.MultipartPostHandler)
|
MultipartPostHandler.MultipartPostHandler)
|
||||||
req = urllib2.Request(url,
|
req = urllib2.Request(url,
|
||||||
|
@ -103,7 +101,7 @@ def sendNZB(nzb):
|
||||||
logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR)
|
logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except http_client.InvalidURL as e:
|
except moves.http_client.InvalidURL as e:
|
||||||
logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR)
|
logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -175,7 +173,7 @@ def _sabURLOpenSimple(url):
|
||||||
except (EOFError, IOError) as e:
|
except (EOFError, IOError) as e:
|
||||||
logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR)
|
logger.log(u"Unable to connect to SABnzbd: " + ex(e), logger.ERROR)
|
||||||
return False, "Unable to connect"
|
return False, "Unable to connect"
|
||||||
except http_client.InvalidURL as e:
|
except moves.http_client.InvalidURL as e:
|
||||||
logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR)
|
logger.log(u"Invalid SABnzbd host, check your config: " + ex(e), logger.ERROR)
|
||||||
return False, "Invalid SABnzbd host"
|
return False, "Invalid SABnzbd host"
|
||||||
if f is None:
|
if f is None:
|
||||||
|
|
Loading…
Reference in a new issue