Use urlopener
This commit is contained in:
1 parent
c87f638b18
commit
1f827ef20a
15 files changed
+140
-166
No files matched your search
@@ -1,13 +1,9 @@
|
||||
from couchpotato.api import addApiView
|
||||
from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.encoding import toUnicode
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from couchpotato.environment import Env
|
||||
from flask.helpers import json
|
||||
import base64
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
@@ -23,15 +19,15 @@ class Notifo(Notification):
|
||||
if self.isDisabled(): return
|
||||
|
||||
try:
|
||||
data = urllib.urlencode({
|
||||
params = {
|
||||
'msg': toUnicode(message),
|
||||
})
|
||||
}
|
||||
|
||||
req = urllib2.Request(self.url)
|
||||
authHeader = "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('api_key')))[:-1]
|
||||
req.add_header("Authorization", authHeader)
|
||||
headers = {
|
||||
'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('username'), self.conf('api_key')))[:-1]
|
||||
}
|
||||
|
||||
handle = urllib2.urlopen(req, data)
|
||||
handle = self.urlopen(self.url, params = params, headers = headers)
|
||||
result = json.load(handle)
|
||||
|
||||
if result['status'] != 'success' or result['response_message'] != 'OK':
|
||||
|
||||
Reference in new issue
Block a user