Try and encode logging messages. fix #403
This commit is contained in:
@@ -41,7 +41,7 @@ class Notification(Plugin):
|
||||
|
||||
test_type = self.testNotifyName()
|
||||
|
||||
log.info('Sending test to %s' % test_type)
|
||||
log.info('Sending test to %s', test_type)
|
||||
|
||||
success = self.notify(
|
||||
message = self.test_message,
|
||||
|
||||
@@ -38,7 +38,7 @@ class Growl(Notification):
|
||||
self.growl.register()
|
||||
self.registered = True
|
||||
except:
|
||||
log.error('Failed register of growl: %s' % traceback.format_exc())
|
||||
log.error('Failed register of growl: %s', traceback.format_exc())
|
||||
|
||||
def notify(self, message = '', data = {}, listener = None):
|
||||
if self.isDisabled(): return
|
||||
|
||||
@@ -33,10 +33,10 @@ class NMJ(Notification):
|
||||
try:
|
||||
terminal = telnetlib.Telnet(host)
|
||||
except Exception:
|
||||
log.error('Warning: unable to get a telnet session to %s' % (host))
|
||||
log.error('Warning: unable to get a telnet session to %s', (host))
|
||||
return self.failed()
|
||||
|
||||
log.debug('Connected to %s via telnet' % (host))
|
||||
log.debug('Connected to %s via telnet', (host))
|
||||
terminal.read_until('sh-3.00# ')
|
||||
terminal.write('cat /tmp/source\n')
|
||||
terminal.write('cat /tmp/netshare\n')
|
||||
@@ -48,9 +48,9 @@ class NMJ(Notification):
|
||||
if match:
|
||||
database = match.group(1)
|
||||
device = match.group(2)
|
||||
log.info('Found NMJ database %s on device %s' % (database, device))
|
||||
log.info('Found NMJ database %s on device %s', (database, device))
|
||||
else:
|
||||
log.error('Could not get current NMJ database on %s, NMJ is probably not running!' % (host))
|
||||
log.error('Could not get current NMJ database on %s, NMJ is probably not running!', (host))
|
||||
return self.failed()
|
||||
|
||||
if device.startswith('NETWORK_SHARE/'):
|
||||
@@ -58,7 +58,7 @@ class NMJ(Notification):
|
||||
|
||||
if match:
|
||||
mount = match.group().replace('127.0.0.1', host)
|
||||
log.info('Found mounting url on the Popcorn Hour in configuration: %s' % (mount))
|
||||
log.info('Found mounting url on the Popcorn Hour in configuration: %s', (mount))
|
||||
else:
|
||||
log.error('Detected a network share on the Popcorn Hour, but could not get the mounting url')
|
||||
return self.failed()
|
||||
@@ -77,7 +77,7 @@ class NMJ(Notification):
|
||||
database = self.conf('database')
|
||||
|
||||
if self.mount:
|
||||
log.debug('Try to mount network drive via url: %s' % (mount))
|
||||
log.debug('Try to mount network drive via url: %s', (mount))
|
||||
try:
|
||||
data = self.urlopen(mount)
|
||||
except:
|
||||
@@ -102,11 +102,11 @@ class NMJ(Notification):
|
||||
et = etree.fromstring(response)
|
||||
result = et.findtext('returnValue')
|
||||
except SyntaxError, e:
|
||||
log.error('Unable to parse XML returned from the Popcorn Hour: %s' % (e))
|
||||
log.error('Unable to parse XML returned from the Popcorn Hour: %s', (e))
|
||||
return False
|
||||
|
||||
if int(result) > 0:
|
||||
log.error('Popcorn Hour returned an errorcode: %s' % (result))
|
||||
log.error('Popcorn Hour returned an errorcode: %s', (result))
|
||||
return False
|
||||
else:
|
||||
log.info('NMJ started background scan')
|
||||
|
||||
@@ -32,7 +32,7 @@ class Notifo(Notification):
|
||||
raise Exception
|
||||
|
||||
except:
|
||||
log.error('Notification failed: %s' % traceback.format_exc())
|
||||
log.error('Notification failed: %s', traceback.format_exc())
|
||||
return False
|
||||
|
||||
log.info('Notifo notification successful.')
|
||||
|
||||
@@ -23,6 +23,6 @@ class NotifyMyAndroid(Notification):
|
||||
|
||||
for key in keys:
|
||||
if not response[str(key)]['code'] == u'200':
|
||||
log.error('Could not send notification to NotifyMyAndroid (%s). %s' % (key, response[key]['message']))
|
||||
log.error('Could not send notification to NotifyMyAndroid (%s). %s', (key, response[key]['message']))
|
||||
|
||||
return response
|
||||
|
||||
@@ -17,7 +17,7 @@ class NotifyMyWP(Notification):
|
||||
|
||||
for key in keys:
|
||||
if not response[key]['Code'] == u'200':
|
||||
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s' % (key, response[key]['message']))
|
||||
log.error('Could not send notification to NotifyMyWindowsPhone (%s). %s', (key, response[key]['message']))
|
||||
return False
|
||||
|
||||
return response
|
||||
|
||||
@@ -38,7 +38,7 @@ class Plex(Notification):
|
||||
x = self.urlopen(url)
|
||||
|
||||
except:
|
||||
log.error('Plex library update failed for %s: %s' % (host, traceback.format_exc()))
|
||||
log.error('Plex library update failed for %s: %s', (host, traceback.format_exc()))
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -63,5 +63,5 @@ class Plex(Notification):
|
||||
log.error("Couldn't sent command to Plex")
|
||||
return False
|
||||
|
||||
log.info('Plex notification to %s successful.' % host)
|
||||
log.info('Plex notification to %s successful.', host)
|
||||
return True
|
||||
|
||||
@@ -32,7 +32,7 @@ class Prowl(Notification):
|
||||
log.info('Prowl notifications sent.')
|
||||
return True
|
||||
elif request_status == 401:
|
||||
log.error('Prowl auth failed: %s' % response.reason)
|
||||
log.error('Prowl auth failed: %s', response.reason)
|
||||
return False
|
||||
else:
|
||||
log.error('Prowl notification failed.')
|
||||
|
||||
@@ -35,7 +35,7 @@ class Pushover(Notification):
|
||||
log.info('Pushover notifications sent.')
|
||||
return True
|
||||
elif request_status == 401:
|
||||
log.error('Pushover auth failed: %s' % response.reason)
|
||||
log.error('Pushover auth failed: %s', response.reason)
|
||||
return False
|
||||
else:
|
||||
log.error('Pushover notification failed.')
|
||||
|
||||
@@ -15,14 +15,14 @@ class Synoindex(Notification):
|
||||
if self.isDisabled(): return
|
||||
|
||||
command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir')]
|
||||
log.info(u'Executing synoindex command: %s ' % command)
|
||||
log.info(u'Executing synoindex command: %s ', command)
|
||||
try:
|
||||
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
|
||||
out = p.communicate()
|
||||
log.info('Result from synoindex: %s' % str(out))
|
||||
log.info('Result from synoindex: %s', str(out))
|
||||
return True
|
||||
except OSError, e:
|
||||
log.error('Unable to run synoindex: %s' % e)
|
||||
log.error('Unable to run synoindex: %s', e)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
@@ -55,7 +55,7 @@ class Twitter(Notification):
|
||||
else:
|
||||
api.PostUpdate('[%s] %s' % (self.default_title, message))
|
||||
except Exception, e:
|
||||
log.error('Error sending tweet: %s' % e)
|
||||
log.error('Error sending tweet: %s', e)
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -71,7 +71,7 @@ class Twitter(Notification):
|
||||
resp, content = oauth_client.request(self.urls['request'], 'POST', body = tryUrlencode({'oauth_callback': callback_url}))
|
||||
|
||||
if resp['status'] != '200':
|
||||
log.error('Invalid response from Twitter requesting temp token: %s' % resp['status'])
|
||||
log.error('Invalid response from Twitter requesting temp token: %s', resp['status'])
|
||||
return jsonified({
|
||||
'success': False,
|
||||
})
|
||||
@@ -80,7 +80,7 @@ class Twitter(Notification):
|
||||
|
||||
auth_url = self.urls['authorize'] + ("?oauth_token=%s" % self.request_token['oauth_token'])
|
||||
|
||||
log.info('Redirecting to "%s"' % auth_url)
|
||||
log.info('Redirecting to "%s"', auth_url)
|
||||
return jsonified({
|
||||
'success': True,
|
||||
'url': auth_url,
|
||||
@@ -100,10 +100,10 @@ class Twitter(Notification):
|
||||
access_token = dict(parse_qsl(content))
|
||||
|
||||
if resp['status'] != '200':
|
||||
log.error('The request for an access token did not succeed: %s' % resp['status'])
|
||||
log.error('The request for an access token did not succeed: %s', resp['status'])
|
||||
return 'Twitter auth failed'
|
||||
else:
|
||||
log.debug('Tokens: %s, %s' % (access_token['oauth_token'], access_token['oauth_token_secret']))
|
||||
log.debug('Tokens: %s, %s', (access_token['oauth_token'], access_token['oauth_token_secret']))
|
||||
|
||||
self.conf('access_token_key', value = access_token['oauth_token'])
|
||||
self.conf('access_token_secret', value = access_token['oauth_token_secret'])
|
||||
|
||||
@@ -35,5 +35,5 @@ class XBMC(Notification):
|
||||
log.error("Couldn't sent command to XBMC")
|
||||
return False
|
||||
|
||||
log.info('XBMC notification to %s successful.' % host)
|
||||
log.info('XBMC notification to %s successful.', host)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user