Code cleanup
This commit is contained in:
1 parent
3c03e400f0
commit
799299c7cc
214 files changed
+497
-324
No files matched your search
@@ -1,5 +1,6 @@
|
||||
from .main import Boxcar
|
||||
|
||||
|
||||
def start():
|
||||
return Boxcar()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import CoreNotifier
|
||||
|
||||
|
||||
def start():
|
||||
return CoreNotifier()
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ class CoreNotifier(Notification):
|
||||
db.query(Notif).filter(Notif.added <= (int(time.time()) - 2419200)).delete()
|
||||
db.commit()
|
||||
|
||||
|
||||
def markAsRead(self, ids = None, **kwargs):
|
||||
|
||||
ids = splitString(ids) if ids else None
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Email
|
||||
|
||||
|
||||
def start():
|
||||
return Email()
|
||||
|
||||
@@ -30,7 +31,7 @@ config = [{
|
||||
},
|
||||
{ 'name': 'smtp_port',
|
||||
'label': 'SMTP server port',
|
||||
'default': '25',
|
||||
'default': '25',
|
||||
'type': 'int',
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ class Email(Notification):
|
||||
log.debug("SMTP over SSL %s", ("enabled" if ssl == 1 else "disabled"))
|
||||
mailserver = smtplib.SMTP_SSL(smtp_server) if ssl == 1 else smtplib.SMTP(smtp_server)
|
||||
|
||||
if (starttls):
|
||||
if starttls:
|
||||
log.debug("Using StartTLS to initiate the connection with the SMTP server")
|
||||
mailserver.starttls()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Growl
|
||||
|
||||
|
||||
def start():
|
||||
return Growl()
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class Growl(Notification):
|
||||
)
|
||||
self.growl.register()
|
||||
self.registered = True
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if 'timed out' in str(e):
|
||||
self.registered = True
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import NMJ
|
||||
|
||||
|
||||
def start():
|
||||
return NMJ()
|
||||
|
||||
|
||||
@@ -86,18 +86,17 @@ class NMJ(Notification):
|
||||
'arg3': '',
|
||||
}
|
||||
params = tryUrlencode(params)
|
||||
UPDATE_URL = 'http://%(host)s:8008/metadata_database?%(params)s'
|
||||
updateUrl = UPDATE_URL % {'host': host, 'params': params}
|
||||
update_url = 'http://%(host)s:8008/metadata_database?%(params)s' % {'host': host, 'params': params}
|
||||
|
||||
try:
|
||||
response = self.urlopen(updateUrl)
|
||||
response = self.urlopen(update_url)
|
||||
except:
|
||||
return False
|
||||
|
||||
try:
|
||||
et = etree.fromstring(response)
|
||||
result = et.findtext('returnValue')
|
||||
except SyntaxError, e:
|
||||
except SyntaxError as e:
|
||||
log.error('Unable to parse XML returned from the Popcorn Hour: %s', e)
|
||||
return False
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import NotifyMyAndroid
|
||||
|
||||
|
||||
def start():
|
||||
return NotifyMyAndroid()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import NotifyMyWP
|
||||
|
||||
|
||||
def start():
|
||||
return NotifyMyWP()
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ log = CPLog(__name__)
|
||||
|
||||
class NotifyMyWP(Notification):
|
||||
|
||||
def notify(self, message = '', data = {}, listener = None):
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
|
||||
keys = splitString(self.conf('api_key'))
|
||||
p = PyNMWP(keys, self.conf('dev_key'))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Plex
|
||||
|
||||
|
||||
def start():
|
||||
return Plex()
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ class Plex(Notification):
|
||||
|
||||
addEvent('renamer.after', self.addToLibrary)
|
||||
|
||||
|
||||
def addToLibrary(self, message = None, group = {}):
|
||||
def addToLibrary(self, message = None, group = None):
|
||||
if self.isDisabled(): return
|
||||
if not group: group = {}
|
||||
|
||||
return self.server.refresh()
|
||||
|
||||
@@ -57,7 +57,8 @@ class Plex(Notification):
|
||||
|
||||
return success
|
||||
|
||||
def notify(self, message = '', data = {}, listener = None):
|
||||
def notify(self, message = '', data = None, listener = None):
|
||||
if not data: data = {}
|
||||
return self.notifyClients(message, self.getClientNames())
|
||||
|
||||
def test(self, **kwargs):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Prowl
|
||||
|
||||
|
||||
def start():
|
||||
return Prowl()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Prowl(Notification):
|
||||
'priority': self.conf('priority'),
|
||||
}
|
||||
headers = {
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
'Content-type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Pushalot
|
||||
|
||||
|
||||
def start():
|
||||
return Pushalot()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Pushalot(Notification):
|
||||
|
||||
urls = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Pushbullet
|
||||
|
||||
|
||||
def start():
|
||||
return Pushbullet()
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Pushover
|
||||
|
||||
|
||||
def start():
|
||||
return Pushover()
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ class Pushover(Notification):
|
||||
})
|
||||
|
||||
http_handler.request('POST',
|
||||
"/1/messages.json",
|
||||
headers = {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
body = tryUrlencode(api_data)
|
||||
"/1/messages.json",
|
||||
headers = {'Content-type': 'application/x-www-form-urlencoded'},
|
||||
body = tryUrlencode(api_data)
|
||||
)
|
||||
|
||||
response = http_handler.getresponse()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Synoindex
|
||||
|
||||
|
||||
def start():
|
||||
return Synoindex()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Synoindex(Notification):
|
||||
out = p.communicate()
|
||||
log.info('Result from synoindex: %s', str(out))
|
||||
return True
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
log.error('Unable to run synoindex: %s', e)
|
||||
|
||||
return False
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Toasty
|
||||
|
||||
|
||||
def start():
|
||||
return Toasty()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import traceback
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Toasty(Notification):
|
||||
|
||||
urls = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Trakt
|
||||
|
||||
|
||||
def start():
|
||||
return Trakt()
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from couchpotato.core.notifications.base import Notification
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Trakt(Notification):
|
||||
|
||||
urls = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Twitter
|
||||
|
||||
|
||||
def start():
|
||||
return Twitter()
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class Twitter(Notification):
|
||||
api.PostUpdate(update_message[135:] + ' 2/2')
|
||||
else:
|
||||
api.PostUpdate(update_message)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
log.error('Error sending tweet: %s', e)
|
||||
return False
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import XBMC
|
||||
|
||||
|
||||
def start():
|
||||
return XBMC()
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from couchpotato.core.helpers.variable import splitString
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from urllib2 import URLError
|
||||
import base64
|
||||
import json
|
||||
import socket
|
||||
@@ -46,7 +45,7 @@ class XBMC(Notification):
|
||||
max_successful += len(calls)
|
||||
response = self.request(host, calls)
|
||||
else:
|
||||
response = self.notifyXBMCnoJSON(host, {'title':self.default_title, 'message':message})
|
||||
response = self.notifyXBMCnoJSON(host, {'title': self.default_title, 'message': message})
|
||||
|
||||
if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0):
|
||||
response += self.request(host, [('VideoLibrary.Scan', {})])
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .main import Xmpp
|
||||
|
||||
|
||||
def start():
|
||||
return Xmpp()
|
||||
|
||||
|
||||
Reference in new issue
Block a user