Browse Source

Try and encode logging messages. fix #403

pull/460/merge
Ruud 13 years ago
parent
commit
e0440d4b11
  1. 6
      couchpotato/core/_base/_core/main.py
  2. 10
      couchpotato/core/_base/scheduler/main.py
  3. 32
      couchpotato/core/_base/updater/main.py
  4. 10
      couchpotato/core/downloaders/blackhole/main.py
  5. 8
      couchpotato/core/downloaders/nzbget/main.py
  6. 2
      couchpotato/core/downloaders/sabnzbd/main.py
  7. 6
      couchpotato/core/downloaders/transmission/main.py
  8. 12
      couchpotato/core/event.py
  9. 2
      couchpotato/core/helpers/encoding.py
  10. 2
      couchpotato/core/helpers/rss.py
  11. 4
      couchpotato/core/helpers/variable.py
  12. 12
      couchpotato/core/loader.py
  13. 52
      couchpotato/core/logger.py
  14. 2
      couchpotato/core/notifications/base.py
  15. 2
      couchpotato/core/notifications/growl/main.py
  16. 16
      couchpotato/core/notifications/nmj/main.py
  17. 2
      couchpotato/core/notifications/notifo/main.py
  18. 2
      couchpotato/core/notifications/notifymyandroid/main.py
  19. 2
      couchpotato/core/notifications/notifymywp/main.py
  20. 4
      couchpotato/core/notifications/plex/main.py
  21. 2
      couchpotato/core/notifications/prowl/main.py
  22. 2
      couchpotato/core/notifications/pushover/main.py
  23. 6
      couchpotato/core/notifications/synoindex/main.py
  24. 10
      couchpotato/core/notifications/twitter/main.py
  25. 2
      couchpotato/core/notifications/xbmc/main.py
  26. 20
      couchpotato/core/plugins/base.py
  27. 6
      couchpotato/core/plugins/library/main.py
  28. 2
      couchpotato/core/plugins/log/main.py
  29. 4
      couchpotato/core/plugins/manage/main.py
  30. 4
      couchpotato/core/plugins/movie/main.py
  31. 5
      couchpotato/core/plugins/profile/main.py
  32. 16
      couchpotato/core/plugins/quality/main.py
  33. 4
      couchpotato/core/plugins/release/main.py
  34. 38
      couchpotato/core/plugins/renamer/main.py
  35. 66
      couchpotato/core/plugins/scanner/main.py
  36. 26
      couchpotato/core/plugins/searcher/main.py
  37. 2
      couchpotato/core/plugins/status/main.py
  38. 4
      couchpotato/core/plugins/trailer/main.py
  39. 2
      couchpotato/core/plugins/userscript/main.py
  40. 4
      couchpotato/core/providers/automation/base.py
  41. 4
      couchpotato/core/providers/automation/imdb/main.py
  42. 2
      couchpotato/core/providers/automation/trakt/main.py
  43. 6
      couchpotato/core/providers/base.py
  44. 8
      couchpotato/core/providers/metadata/base.py
  45. 2
      couchpotato/core/providers/metadata/xbmc/main.py
  46. 2
      couchpotato/core/providers/movie/_modifier/main.py
  47. 8
      couchpotato/core/providers/movie/couchpotatoapi/main.py
  48. 6
      couchpotato/core/providers/movie/imdbapi/main.py
  49. 24
      couchpotato/core/providers/movie/themoviedb/main.py
  50. 6
      couchpotato/core/providers/nzb/newzbin/main.py
  51. 12
      couchpotato/core/providers/nzb/newznab/main.py
  52. 6
      couchpotato/core/providers/nzb/nzbclub/main.py
  53. 2
      couchpotato/core/providers/nzb/nzbindex/main.py
  54. 2
      couchpotato/core/providers/nzb/nzbmatrix/main.py
  55. 2
      couchpotato/core/providers/torrent/kickasstorrents/main.py
  56. 10
      couchpotato/core/providers/torrent/thepiratebay/main.py
  57. 2
      couchpotato/core/providers/trailer/hdtrailers/main.py
  58. 6
      couchpotato/core/providers/userscript/youteather/main.py
  59. 10
      couchpotato/runner.py

6
couchpotato/core/_base/_core/main.py

@ -96,7 +96,7 @@ class Core(Plugin):
while loop:
log.debug('Asking who is running')
still_running = fireEvent('plugin.running', merge = True)
log.debug('Still running: %s' % still_running)
log.debug('Still running: %s', still_running)
if len(still_running) == 0:
break
@ -105,7 +105,7 @@ class Core(Plugin):
running = list(set(still_running) - set(self.ignore_restart))
if len(running) > 0:
log.info('Waiting on plugins to finish: %s' % running)
log.info('Waiting on plugins to finish: %s', running)
else:
loop = False
@ -118,7 +118,7 @@ class Core(Plugin):
except RuntimeError:
pass
except:
log.error('Failed shutting down the server: %s' % traceback.format_exc())
log.error('Failed shutting down the server: %s', traceback.format_exc())
fireEvent('app.after_shutdown', restart = restart)

10
couchpotato/core/_base/scheduler/main.py

@ -28,7 +28,7 @@ class Scheduler(Plugin):
for type in ['interval', 'cron']:
try:
self.sched.unschedule_job(getattr(self, type)[identifier]['job'])
log.debug('%s unscheduled %s' % (type.capitalize(), identifier))
log.debug('%s unscheduled %s', (type.capitalize(), identifier))
except:
pass
@ -45,7 +45,7 @@ class Scheduler(Plugin):
job = self.sched.add_cron_job(cron['handle'], day = cron['day'], hour = cron['hour'], minute = cron['minute'])
cron['job'] = job
except ValueError, e:
log.error("Failed adding cronjob: %s" % e)
log.error('Failed adding cronjob: %s', e)
# Intervals
for identifier in self.intervals:
@ -55,7 +55,7 @@ class Scheduler(Plugin):
job = self.sched.add_interval_job(interval['handle'], hours = interval['hours'], minutes = interval['minutes'], seconds = interval['seconds'])
interval['job'] = job
except ValueError, e:
log.error("Failed adding interval cronjob: %s" % e)
log.error('Failed adding interval cronjob: %s', e)
# Start it
log.debug('Starting scheduler')
@ -75,7 +75,7 @@ class Scheduler(Plugin):
self.started = False
def cron(self, identifier = '', handle = None, day = '*', hour = '*', minute = '*'):
log.info('Scheduling "%s", cron: day = %s, hour = %s, minute = %s' % (identifier, day, hour, minute))
log.info('Scheduling "%s", cron: day = %s, hour = %s, minute = %s', (identifier, day, hour, minute))
self.remove(identifier)
self.crons[identifier] = {
@ -86,7 +86,7 @@ class Scheduler(Plugin):
}
def interval(self, identifier = '', handle = None, hours = 0, minutes = 0, seconds = 0):
log.info('Scheduling %s, interval: hours = %s, minutes = %s, seconds = %s' % (identifier, hours, minutes, seconds))
log.info('Scheduling %s, interval: hours = %s, minutes = %s, seconds = %s', (identifier, hours, minutes, seconds))
self.remove(identifier)
self.intervals[identifier] = {

32
couchpotato/core/_base/updater/main.py

@ -128,11 +128,11 @@ class BaseUpdater(Plugin):
for excess_pyc_file in excess_pyc_files:
full_path = os.path.join(root, excess_pyc_file)
log.debug('Removing old PYC file: %s' % full_path)
log.debug('Removing old PYC file: %s', full_path)
try:
os.remove(full_path)
except:
log.error('Couldn\'t remove %s: %s' % (full_path, traceback.format_exc()))
log.error('Couldn\'t remove %s: %s', (full_path, traceback.format_exc()))
for dir_name in dirs:
full_path = os.path.join(root, dir_name)
@ -140,7 +140,7 @@ class BaseUpdater(Plugin):
try:
os.rmdir(full_path)
except:
log.error('Couldn\'t remove empty directory %s: %s' % (full_path, traceback.format_exc()))
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
@ -170,7 +170,7 @@ class GitUpdater(BaseUpdater):
return True
except:
log.error('Failed updating via GIT: %s' % traceback.format_exc())
log.error('Failed updating via GIT: %s', traceback.format_exc())
self.update_failed = True
@ -181,14 +181,14 @@ class GitUpdater(BaseUpdater):
if not self.version:
try:
output = self.repo.getHead() # Yes, please
log.debug('Git version output: %s' % output.hash)
log.debug('Git version output: %s', output.hash)
self.version = {
'hash': output.hash[:8],
'date': output.getDate(),
'type': 'git',
}
except Exception, e:
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s' % e)
log.error('Failed using GIT updater, running from source, you need to have GIT installed. %s', e)
return 'No GIT'
return self.version
@ -198,7 +198,7 @@ class GitUpdater(BaseUpdater):
if self.update_version:
return
log.info('Checking for new version on github for %s' % self.repo_name)
log.info('Checking for new version on github for %s', self.repo_name)
if not Env.get('dev'):
self.repo.fetch()
@ -210,7 +210,7 @@ class GitUpdater(BaseUpdater):
local = self.repo.getHead()
remote = branch.getHead()
log.info('Versions, local:%s, remote:%s' % (local.hash[:8], remote.hash[:8]))
log.info('Versions, local:%s, remote:%s', (local.hash[:8], remote.hash[:8]))
if local.getDate() < remote.getDate():
self.update_version = {
@ -263,7 +263,7 @@ class SourceUpdater(BaseUpdater):
return True
except:
log.error('Failed updating: %s' % traceback.format_exc())
log.error('Failed updating: %s', traceback.format_exc())
self.update_failed = True
return False
@ -296,7 +296,7 @@ class SourceUpdater(BaseUpdater):
except ValueError:
pass
except Exception, e:
log.error('Failed overwriting file: %s' % e)
log.error('Failed overwriting file: %s', e)
def removeDir(self, path):
@ -315,11 +315,11 @@ class SourceUpdater(BaseUpdater):
output = json.loads(f.read())
f.close()
log.debug('Source version output: %s' % output)
log.debug('Source version output: %s', output)
self.version = output
self.version['type'] = 'source'
except Exception, e:
log.error('Failed using source updater. %s' % e)
log.error('Failed using source updater. %s', e)
return {}
return self.version
@ -336,7 +336,7 @@ class SourceUpdater(BaseUpdater):
self.last_check = time.time()
except:
log.error('Failed updating via source: %s' % traceback.format_exc())
log.error('Failed updating via source: %s', traceback.format_exc())
return self.update_version is not None
@ -351,7 +351,7 @@ class SourceUpdater(BaseUpdater):
'date': int(time.mktime(parse(commit['commit']['committer']['date']).timetuple())),
}
except:
log.error('Failed getting latest request from github: %s' % traceback.format_exc())
log.error('Failed getting latest request from github: %s', traceback.format_exc())
return {}
@ -372,7 +372,7 @@ class DesktopUpdater(BaseUpdater):
if e['status'] == 'done':
fireEventAsync('app.restart')
else:
log.error('Failed updating desktop: %s' % e['exception'])
log.error('Failed updating desktop: %s', e['exception'])
self.update_failed = True
self.desktop._esky.auto_update(callback = do_restart)
@ -403,7 +403,7 @@ class DesktopUpdater(BaseUpdater):
self.last_check = time.time()
except:
log.error('Failed updating desktop: %s' % traceback.format_exc())
log.error('Failed updating desktop: %s', traceback.format_exc())
return self.update_version is not None

10
couchpotato/core/downloaders/blackhole/main.py

@ -16,7 +16,7 @@ class Blackhole(Downloader):
directory = self.conf('directory')
if not directory or not os.path.isdir(directory):
log.error('No directory set for blackhole %s download.' % data.get('type'))
log.error('No directory set for blackhole %s download.', data.get('type'))
else:
try:
if not filedata or len(filedata) < 50:
@ -27,19 +27,19 @@ class Blackhole(Downloader):
try:
if not os.path.isfile(fullPath):
log.info('Downloading %s to %s.' % (data.get('type'), fullPath))
log.info('Downloading %s to %s.', (data.get('type'), fullPath))
with open(fullPath, 'wb') as f:
f.write(filedata)
return True
else:
log.info('File %s already exists.' % fullPath)
log.info('File %s already exists.', fullPath)
return True
except:
log.error('Failed to download to blackhole %s' % traceback.format_exc())
log.error('Failed to download to blackhole %s', traceback.format_exc())
pass
except:
log.info('Failed to download file %s: %s' % (data.get('name'), traceback.format_exc()))
log.info('Failed to download file %s: %s', (data.get('name'), traceback.format_exc()))
return False
return False

8
couchpotato/core/downloaders/nzbget/main.py

@ -20,10 +20,10 @@ class NZBGet(Downloader):
return
if not filedata:
log.error('Unable to get NZB file: %s' % traceback.format_exc())
log.error('Unable to get NZB file: %s', traceback.format_exc())
return False
log.info('Sending "%s" to NZBGet.' % data.get('name'))
log.info('Sending "%s" to NZBGet.', data.get('name'))
url = self.url % {'host': self.conf('host'), 'password': self.conf('password')}
nzb_name = '%s.nzb' % self.createNzbName(data, movie)
@ -41,12 +41,12 @@ class NZBGet(Downloader):
if e.errcode == 401:
log.error('Password is incorrect.')
else:
log.error('Protocol Error: %s' % e)
log.error('Protocol Error: %s', e)
return False
if rpc.append(nzb_name, self.conf('category'), False, standard_b64encode(filedata.strip())):
log.info('NZB sent successfully to NZBGet')
return True
else:
log.error('NZBGet could not add %s to the queue.' % nzb_name)
log.error('NZBGet could not add %s to the queue.', nzb_name)
return False

2
couchpotato/core/downloaders/sabnzbd/main.py

@ -15,7 +15,7 @@ class Sabnzbd(Downloader):
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
return
log.info("Sending '%s' to SABnzbd." % data.get('name'))
log.info('Sending "%s" to SABnzbd.', data.get('name'))
params = {
'apikey': self.conf('api_key'),

6
couchpotato/core/downloaders/transmission/main.py

@ -16,7 +16,7 @@ class Transmission(Downloader):
if self.isDisabled(manual) or not self.isCorrectType(data.get('type')):
return
log.info('Sending "%s" to Transmission.' % data.get('name'))
log.info('Sending "%s" to Transmission.', data.get('name'))
# Load host from config and split out port.
host = self.conf('host').split(':')
@ -42,10 +42,10 @@ class Transmission(Downloader):
torrent.seed_ratio_limit = self.conf('ratio')
torrent.seed_ratio_mode = 'single' if self.conf('ratio') else 'global'
except transmissionrpc.TransmissionError, e:
log.error('Failed to change settings for transfer in transmission: %s' % e)
log.error('Failed to change settings for transfer in transmission: %s', e)
return True
except transmissionrpc.TransmissionError, e:
log.error('Failed to send link to transmission: %s' % e)
log.error('Failed to send link to transmission: %s', e)
return False

12
couchpotato/core/event.py

@ -12,7 +12,7 @@ def runHandler(name, handler, *args, **kwargs):
return handler(*args, **kwargs)
except:
from couchpotato.environment import Env
log.error('Error in event "%s", that wasn\'t caught: %s%s' % (name, traceback.format_exc(), Env.all()))
log.error('Error in event "%s", that wasn\'t caught: %s%s', (name, traceback.format_exc(), Env.all()))
def addEvent(name, handler, priority = 100):
@ -43,7 +43,7 @@ def removeEvent(name, handler):
def fireEvent(name, *args, **kwargs):
if not events.get(name): return
#log.debug('Firing event %s' % name)
#log.debug('Firing event %s', name)
try:
# Fire after event
@ -100,7 +100,7 @@ def fireEvent(name, *args, **kwargs):
elif r[1]:
errorHandler(r[1])
else:
log.debug('Assume disabled eventhandler for: %s' % name)
log.debug('Assume disabled eventhandler for: %s', name)
else:
results = []
@ -130,7 +130,7 @@ def fireEvent(name, *args, **kwargs):
modified_results = fireEvent('result.modify.%s' % name, results, single = True)
if modified_results:
log.debug('Return modified results for %s' % name)
log.debug('Return modified results for %s', name)
results = modified_results
if not is_after_event:
@ -143,7 +143,7 @@ def fireEvent(name, *args, **kwargs):
except KeyError, e:
pass
except Exception:
log.error('%s: %s' % (name, traceback.format_exc()))
log.error('%s: %s', (name, traceback.format_exc()))
def fireEventAsync(*args, **kwargs):
try:
@ -152,7 +152,7 @@ def fireEventAsync(*args, **kwargs):
my_thread.start()
return True
except Exception, e:
log.error('%s: %s' % (args[0], e))
log.error('%s: %s', (args[0], e))
def errorHandler(error):
etype, value, tb = error

2
couchpotato/core/helpers/encoding.py

@ -31,7 +31,7 @@ def toUnicode(original, *args):
except:
raise
except UnicodeDecodeError:
log.error('Unable to decode value: %s... ' % repr(original)[:20])
log.error('Unable to decode value: %s... ', repr(original)[:20])
ascii_text = str(original).encode('string_escape')
return toUnicode(ascii_text)

2
couchpotato/core/helpers/rss.py

@ -47,5 +47,5 @@ class RSS(object):
try:
return XMLTree.parse(data).findall(path)
except Exception, e:
log.error('Error parsing RSS. %s' % e)
log.error('Error parsing RSS. %s', e)
return []

4
couchpotato/core/helpers/variable.py

@ -118,10 +118,10 @@ def getTitle(library_dict):
try:
return library_dict['titles'][0]['title']
except:
log.error('Could not get title for %s' % library_dict['identifier'])
log.error('Could not get title for %s', library_dict['identifier'])
return None
except:
log.error('Could not get title for library item: %s' % library_dict)
log.error('Could not get title for library item: %s', library_dict)
return None
def randomString(size = 8, chars = string.ascii_uppercase + string.digits):

12
couchpotato/core/loader.py

@ -45,7 +45,7 @@ class Loader(object):
try:
m = getattr(self.loadModule(module_name), plugin.get('name'))
log.info("Loading %s: %s" % (plugin['type'], plugin['name']))
log.info('Loading %s: %s', (plugin['type'], plugin['name']))
# Save default settings for plugin/provider
did_save += self.loadSettings(m, module_name, save = False)
@ -57,10 +57,10 @@ class Loader(object):
log.error(e.message)
pass
# todo:: this needs to be more descriptive.
log.error('Import error, remove the empty folder: %s' % plugin.get('module'))
log.debug('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
log.error('Import error, remove the empty folder: %s', plugin.get('module'))
log.debug('Can\'t import %s: %s', (module_name, traceback.format_exc()))
except:
log.error('Can\'t import %s: %s' % (module_name, traceback.format_exc()))
log.error('Can\'t import %s: %s', (module_name, traceback.format_exc()))
if did_save:
fireEvent('settings.save')
@ -84,7 +84,7 @@ class Loader(object):
fireEvent('settings.register', section_name = section['name'], options = options, save = save)
return True
except:
log.debug("Failed loading settings for '%s': %s" % (name, traceback.format_exc()))
log.debug('Failed loading settings for "%s": %s', (name, traceback.format_exc()))
return False
def loadPlugins(self, module, name):
@ -97,7 +97,7 @@ class Loader(object):
return True
except Exception, e:
log.error("Failed loading plugin '%s': %s" % (module.__file__, traceback.format_exc()))
log.error('Failed loading plugin "%s": %s', (module.__file__, traceback.format_exc()))
return False
def addModule(self, priority, plugin_type, module, name):

52
couchpotato/core/logger.py

@ -1,5 +1,6 @@
import logging
import re
import traceback
class CPLog(object):
@ -13,39 +14,54 @@ class CPLog(object):
self.context = context
self.logger = logging.getLogger()
def info(self, msg):
self.logger.info(self.addContext(msg))
def info(self, msg, replace_tuple = ()):
self.logger.info(self.addContext(msg, replace_tuple))
def debug(self, msg):
self.logger.debug(self.addContext(msg))
def debug(self, msg, replace_tuple = ()):
self.logger.debug(self.addContext(msg, replace_tuple))
def error(self, msg):
self.logger.error(self.addContext(msg))
def error(self, msg, replace_tuple = ()):
self.logger.error(self.addContext(msg, replace_tuple))
def warning(self, msg):
self.logger.warning(self.addContext(msg))
def warning(self, msg, replace_tuple = ()):
self.logger.warning(self.addContext(msg, replace_tuple))
def critical(self, msg):
self.logger.critical(self.addContext(msg), exc_info = 1)
def critical(self, msg, replace_tuple = ()):
self.logger.critical(self.addContext(msg, replace_tuple), exc_info = 1)
def addContext(self, msg):
return '[%+25.25s] %s' % (self.context[-25:], self.removePrivateData(msg))
def addContext(self, msg, replace_tuple = ()):
return '[%+25.25s] %s' % (self.context[-25:], self.safeMessage(msg, replace_tuple))
def safeMessage(self, msg, replace_tuple = ()):
if not hasattr(self, 'Env'):
from couchpotato.environment import Env
from couchpotato.core.helpers.encoding import toUnicode
self.Env = Env
self.toUnicode = toUnicode
msg = self.toUnicode(msg)
def removePrivateData(self, msg):
try:
msg = unicode(msg)
msg = msg % replace_tuple
except:
pass
try:
if isinstance(replace_tuple, tuple):
msg = msg % tuple([self.toUnicode(x).encode(self.Env.get('encoding')) for x in list(replace_tuple)])
else:
msg = msg % self.toUnicode(replace_tuple).encode(self.Env.get('encoding'))
except:
self.error('Failed encoding stuff to log: %s' % traceback.format_exc())
from couchpotato.environment import Env
if not Env.get('dev'):
if not self.Env.get('dev'):
for replace in self.replace_private:
msg = re.sub('(%s=)[^\&]+' % replace, '%s=xxx' % replace, msg)
# Replace api key
try:
api_key = Env.setting('api_key')
api_key = self.Env.setting('api_key')
if api_key:
msg = msg.replace(api_key, 'API_KEY')
except:

2
couchpotato/core/notifications/base.py

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

2
couchpotato/core/notifications/growl/main.py

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

16
couchpotato/core/notifications/nmj/main.py

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

2
couchpotato/core/notifications/notifo/main.py

@ -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.')

2
couchpotato/core/notifications/notifymyandroid/main.py

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

2
couchpotato/core/notifications/notifymywp/main.py

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

4
couchpotato/core/notifications/plex/main.py

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

2
couchpotato/core/notifications/prowl/main.py

@ -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.')

2
couchpotato/core/notifications/pushover/main.py

@ -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.')

6
couchpotato/core/notifications/synoindex/main.py

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

10
couchpotato/core/notifications/twitter/main.py

@ -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'])

2
couchpotato/core/notifications/xbmc/main.py

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

20
couchpotato/core/plugins/base.py

@ -80,7 +80,7 @@ class Plugin(object):
f.close()
os.chmod(path, Env.getPermission('file'))
except Exception, e:
log.error('Unable writing to file "%s": %s' % (path, e))
log.error('Unable writing to file "%s": %s', (path, e))
def makeDir(self, path):
try:
@ -88,7 +88,7 @@ class Plugin(object):
os.makedirs(path, Env.getPermission('folder'))
return True
except Exception, e:
log.error('Unable to create folder "%s": %s' % (path, e))
log.error('Unable to create folder "%s": %s', (path, e))
return False
@ -106,7 +106,7 @@ class Plugin(object):
# Don't try for failed requests
if self.http_failed_disabled.get(host, 0) > 0:
if self.http_failed_disabled[host] > (time.time() - 900):
log.info('Disabled calls to %s for 15 minutes because so many failed requests.' % host)
log.info('Disabled calls to %s for 15 minutes because so many failed requests.', host)
raise Exception
else:
del self.http_failed_request[host]
@ -116,7 +116,7 @@ class Plugin(object):
try:
if multipart:
log.info('Opening multipart url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
log.info('Opening multipart url: %s, params: %s', (url, [x for x in params.iterkeys()]))
request = urllib2.Request(url, params, headers)
cookies = cookielib.CookieJar()
@ -124,7 +124,7 @@ class Plugin(object):
data = opener.open(request, timeout = timeout).read()
else:
log.info('Opening url: %s, params: %s' % (url, [x for x in params.iterkeys()]))
log.info('Opening url: %s, params: %s', (url, [x for x in params.iterkeys()]))
data = tryUrlencode(params) if len(params) > 0 else None
request = urllib2.Request(url, data, headers)
@ -133,7 +133,7 @@ class Plugin(object):
self.http_failed_request[host] = 0
except IOError:
if show_error:
log.error('Failed opening url in %s: %s %s' % (self.getName(), url, traceback.format_exc(1)))
log.error('Failed opening url in %s: %s %s', (self.getName(), url, traceback.format_exc(1)))
# Save failed requests by hosts
try:
@ -147,7 +147,7 @@ class Plugin(object):
self.http_failed_disabled[host] = time.time()
except:
log.debug('Failed logging failed requests for %s: %s' % (url, traceback.format_exc()))
log.debug('Failed logging failed requests for %s: %s', (url, traceback.format_exc()))
raise
@ -163,7 +163,7 @@ class Plugin(object):
wait = math.ceil(last_use - now + self.http_time_between_calls)
if wait > 0:
log.debug('Waiting for %s, %d seconds' % (self.getName(), wait))
log.debug('Waiting for %s, %d seconds', (self.getName(), wait))
time.sleep(last_use - now + self.http_time_between_calls)
def beforeCall(self, handler):
@ -202,7 +202,7 @@ class Plugin(object):
cache_key = simplifyString(cache_key)
cache = Env.get('cache').get(cache_key)
if cache:
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
if not Env.get('dev'): log.debug('Getting cache %s', cache_key)
return cache
if url:
@ -220,7 +220,7 @@ class Plugin(object):
pass
def setCache(self, cache_key, value, timeout = 300):
log.debug('Setting cache %s' % cache_key)
log.debug('Setting cache %s', cache_key)
Env.get('cache').set(cache_key, value, timeout)
return value

6
couchpotato/core/plugins/library/main.py

@ -78,7 +78,7 @@ class LibraryPlugin(Plugin):
except: pass
if not info or len(info) == 0:
log.error('Could not update, no movie info to work with: %s' % identifier)
log.error('Could not update, no movie info to work with: %s', identifier)
return False
# Main info
@ -95,7 +95,7 @@ class LibraryPlugin(Plugin):
db.commit()
titles = info.get('titles', [])
log.debug('Adding titles: %s' % titles)
log.debug('Adding titles: %s', titles)
for title in titles:
if not title:
continue
@ -123,7 +123,7 @@ class LibraryPlugin(Plugin):
library.files.append(file_obj)
db.commit()
except:
log.debug('Failed to attach to library: %s' % traceback.format_exc())
log.debug('Failed to attach to library: %s', traceback.format_exc())
library_dict = library.to_dict(self.default_dict)

2
couchpotato/core/plugins/log/main.py

@ -149,7 +149,7 @@ class Logging(Plugin):
except:
log.error(log_message)
except:
log.error('Couldn\'t log via API: %s' % params)
log.error('Couldn\'t log via API: %s', params)
return jsonified({

4
couchpotato/core/plugins/manage/main.py

@ -52,10 +52,10 @@ class Manage(Plugin):
if not os.path.isdir(directory):
if len(directory) > 0:
log.error('Directory doesn\'t exist: %s' % directory)
log.error('Directory doesn\'t exist: %s', directory)
continue
log.info('Updating manage library: %s' % directory)
log.info('Updating manage library: %s', directory)
identifiers = fireEvent('scanner.folder', folder = directory, newer_than = last_update if not full else 0, single = True)
if identifiers:
added_identifiers.extend(identifiers)

4
couchpotato/core/plugins/movie/main.py

@ -315,7 +315,7 @@ class MoviePlugin(Plugin):
m.profile_id = params.get('profile_id', default_profile.get('id'))
else:
log.debug('Movie already exists, not updating: %s' % params)
log.debug('Movie already exists, not updating: %s', params)
added = False
if force_readd:
@ -458,7 +458,7 @@ class MoviePlugin(Plugin):
log.debug('Can\'t restatus movie, doesn\'t seem to exist.')
return False
log.debug('Changing status for %s' % (m.library.titles[0].title))
log.debug('Changing status for %s', (m.library.titles[0].title))
if not m.profile:
m.status_id = done_status.get('id')
else:

5
couchpotato/core/plugins/profile/main.py

@ -135,8 +135,7 @@ class ProfilePlugin(Plugin):
success = True
except Exception, e:
message = 'Failed deleting Profile: %s' % e
log.error(message)
message = log.error('Failed deleting Profile: %s', e)
#db.close()
@ -163,7 +162,7 @@ class ProfilePlugin(Plugin):
# Create default quality profile
order = -2
for profile in profiles:
log.info('Creating default profile: %s' % profile.get('label'))
log.info('Creating default profile: %s', profile.get('label'))
p = Profile(
label = toUnicode(profile.get('label')),
order = order

16
couchpotato/core/plugins/quality/main.py

@ -116,7 +116,7 @@ class QualityPlugin(Plugin):
quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()
if not quality:
log.info('Creating quality: %s' % q.get('label'))
log.info('Creating quality: %s', q.get('label'))
quality = Quality()
db.add(quality)
@ -133,7 +133,7 @@ class QualityPlugin(Plugin):
).all()
if not profile:
log.info('Creating profile: %s' % q.get('label'))
log.info('Creating profile: %s', q.get('label'))
profile = Profile(
core = True,
label = toUnicode(quality.label),
@ -170,20 +170,20 @@ class QualityPlugin(Plugin):
# Check tags
if quality['identifier'] in words:
log.debug('Found via identifier "%s" in %s' % (quality['identifier'], cur_file))
log.debug('Found via identifier "%s" in %s', (quality['identifier'], cur_file))
return self.setCache(hash, quality)
if list(set(quality.get('alternative', [])) & set(words)):
log.debug('Found %s via alt %s in %s' % (quality['identifier'], quality.get('alternative'), cur_file))
log.debug('Found %s via alt %s in %s', (quality['identifier'], quality.get('alternative'), cur_file))
return self.setCache(hash, quality)
for tag in quality.get('tags', []):
if isinstance(tag, tuple) and '.'.join(tag) in '.'.join(words):
log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), cur_file))
log.debug('Found %s via tag %s in %s', (quality['identifier'], quality.get('tags'), cur_file))
return self.setCache(hash, quality)
if list(set(quality.get('tags', [])) & set(words)):
log.debug('Found %s via tag %s in %s' % (quality['identifier'], quality.get('tags'), cur_file))
log.debug('Found %s via tag %s in %s', (quality['identifier'], quality.get('tags'), cur_file))
return self.setCache(hash, quality)
# Try again with loose testing
@ -191,7 +191,7 @@ class QualityPlugin(Plugin):
if quality:
return self.setCache(hash, quality)
log.debug('Could not identify quality for: %s' % files)
log.debug('Could not identify quality for: %s', files)
return None
def guessLoose(self, hash, extra):
@ -200,7 +200,7 @@ class QualityPlugin(Plugin):
# Last check on resolution only
if quality.get('width', 480) == extra.get('resolution_width', 0):
log.debug('Found %s via resolution_width: %s == %s' % (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
log.debug('Found %s via resolution_width: %s == %s', (quality['identifier'], quality.get('width', 480), extra.get('resolution_width', 0)))
return self.setCache(hash, quality)
if 480 <= extra.get('resolution_width', 0) <= 720:

4
couchpotato/core/plugins/release/main.py

@ -79,7 +79,7 @@ class Release(Plugin):
rel.files.append(added_file)
db.commit()
except Exception, e:
log.debug('Failed to attach "%s" to release: %s' % (cur_file, e))
log.debug('Failed to attach "%s" to release: %s', (cur_file, e))
fireEvent('movie.restatus', movie.id)
@ -158,7 +158,7 @@ class Release(Plugin):
'success': True
})
else:
log.error('Couldn\'t find release with id: %s' % id)
log.error('Couldn\'t find release with id: %s', id)
#db.close()
return jsonified({

38
couchpotato/core/plugins/renamer/main.py

@ -100,7 +100,7 @@ class Renamer(Plugin):
else:
group['library'] = fireEvent('library.update', identifier = group['library']['identifier'], single = True)
if not group['library']:
log.error('Could not rename, no library item to work with: %s' % group_identifier)
log.error('Could not rename, no library item to work with: %s', group_identifier)
continue
library = group['library']
@ -138,7 +138,7 @@ class Renamer(Plugin):
# Move nfo depending on settings
if file_type is 'nfo' and not self.conf('rename_nfo'):
log.debug('Skipping, renaming of %s disabled' % file_type)
log.debug('Skipping, renaming of %s disabled', file_type)
if self.conf('cleanup'):
for current_file in group['files'][file_type]:
remove_files.append(current_file)
@ -197,7 +197,7 @@ class Renamer(Plugin):
break
if not found:
log.error('Could not determine dvd structure for: %s' % current_file)
log.error('Could not determine dvd structure for: %s', current_file)
# Do rename others
else:
@ -272,7 +272,7 @@ class Renamer(Plugin):
movie.status_id = done_status.get('id')
db.commit()
except Exception, e:
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
log.error('Failed marking movie finished: %s %s', (e, traceback.format_exc()))
# Go over current movie releases
for release in movie.releases:
@ -282,20 +282,20 @@ class Renamer(Plugin):
# This is where CP removes older, lesser quality releases
if release.quality.order > group['meta_data']['quality']['order']:
log.info('Removing lesser quality %s for %s.' % (movie.library.titles[0].title, release.quality.label))
log.info('Removing lesser quality %s for %s.', (movie.library.titles[0].title, release.quality.label))
for current_file in release.files:
remove_files.append(current_file)
remove_releases.append(release)
# Same quality, but still downloaded, so maybe repack/proper/unrated/directors cut etc
elif release.quality.order is group['meta_data']['quality']['order']:
log.info('Same quality release already exists for %s, with quality %s. Assuming repack.' % (movie.library.titles[0].title, release.quality.label))
log.info('Same quality release already exists for %s, with quality %s. Assuming repack.', (movie.library.titles[0].title, release.quality.label))
for current_file in release.files:
remove_files.append(current_file)
remove_releases.append(release)
# Downloaded a lower quality, rename the newly downloaded files/folder to exclude them from scan
else:
log.info('Better quality release already exists for %s, with quality %s' % (movie.library.titles[0].title, release.quality.label))
log.info('Better quality release already exists for %s, with quality %s', (movie.library.titles[0].title, release.quality.label))
# Add _EXISTS_ to the parent dir
if group['dirname']:
@ -333,18 +333,18 @@ class Renamer(Plugin):
if isinstance(src, File):
src = src.path
log.info('Removing "%s"' % src)
log.info('Removing "%s"', src)
try:
os.remove(src)
except:
log.error('Failed removing %s: %s' % (src, traceback.format_exc()))
log.error('Failed removing %s: %s', (src, traceback.format_exc()))
# Rename all files marked
group['renamed_files'] = []
for src in rename_files:
if rename_files[src]:
dst = rename_files[src]
log.info('Renaming "%s" to "%s"' % (src, dst))
log.info('Renaming "%s" to "%s"', (src, dst))
# Create dir
self.makeDir(os.path.dirname(dst))
@ -353,22 +353,22 @@ class Renamer(Plugin):
self.moveFile(src, dst)
group['renamed_files'].append(dst)
except:
log.error('Failed moving the file "%s" : %s' % (os.path.basename(src), traceback.format_exc()))
log.error('Failed moving the file "%s" : %s', (os.path.basename(src), traceback.format_exc()))
# Remove matching releases
for release in remove_releases:
log.debug('Removing release %s' % release.identifier)
log.debug('Removing release %s', release.identifier)
try:
db.delete(release)
except:
log.error('Failed removing %s: %s' % (release.identifier, traceback.format_exc()))
log.error('Failed removing %s: %s', (release.identifier, traceback.format_exc()))
if group['dirname'] and group['parentdir']:
try:
log.info('Deleting folder: %s' % group['parentdir'])
log.info('Deleting folder: %s', group['parentdir'])
self.deleteEmptyFolder(group['parentdir'])
except:
log.error('Failed removing %s: %s' % (group['parentdir'], traceback.format_exc()))
log.error('Failed removing %s: %s', (group['parentdir'], traceback.format_exc()))
if not unknown:
# Search for trailers etc
@ -408,10 +408,10 @@ class Renamer(Plugin):
try:
os.chmod(dest, Env.getPermission('file'))
except:
log.error('Failed setting permissions for file: %s' % dest)
log.error('Failed setting permissions for file: %s', dest)
except:
log.error("Couldn't move file '%s' to '%s': %s" % (old, dest, traceback.format_exc()))
log.error('Couldn\'t move file "%s" to "%s": %s', (old, dest, traceback.format_exc()))
raise Exception
return True
@ -447,9 +447,9 @@ class Renamer(Plugin):
try:
os.rmdir(full_path)
except:
log.error('Couldn\'t remove empty directory %s: %s' % (full_path, traceback.format_exc()))
log.error('Couldn\'t remove empty directory %s: %s', (full_path, traceback.format_exc()))
try:
os.rmdir(folder)
except:
log.error('Couldn\'t remove empty directory %s: %s' % (folder, traceback.format_exc()))
log.error('Couldn\'t remove empty directory %s: %s', (folder, traceback.format_exc()))

66
couchpotato/core/plugins/scanner/main.py

@ -136,7 +136,7 @@ class Scanner(Plugin):
folder = os.path.normpath(folder)
if not folder or not os.path.isdir(folder):
log.error('Folder doesn\'t exists: %s' % folder)
log.error('Folder doesn\'t exists: %s', folder)
return {}
# Get movie "master" files
@ -154,12 +154,12 @@ class Scanner(Plugin):
try:
files = []
folder = toUnicode(folder).encode(Env.get('encoding'))
log.info('Trying to convert unicode to str path: %s, %s' % (folder, type(folder)))
log.info('Trying to convert unicode to str path: %s, %s', (folder, type(folder)))
for root, dirs, walk_files in os.walk(folder):
for filename in walk_files:
files.append(os.path.join(root, filename))
except:
log.error('Failed getting files from %s: %s' % (folder, traceback.format_exc()))
log.error('Failed getting files from %s: %s', (folder, traceback.format_exc()))
db = get_session()
@ -215,7 +215,7 @@ class Scanner(Plugin):
for identifier, group in movie_files.iteritems():
if identifier not in group['identifiers'] and len(identifier) > 0: group['identifiers'].append(identifier)
log.debug('Grouping files: %s' % identifier)
log.debug('Grouping files: %s', identifier)
for file_path in group['unsorted_files']:
wo_ext = file_path[:-(len(getExt(file_path)) + 1)]
@ -241,7 +241,7 @@ class Scanner(Plugin):
# Group the files based on the identifier
delete_identifiers = []
for identifier, found_files in self.path_identifiers.iteritems():
log.debug('Grouping files on identifier: %s' % identifier)
log.debug('Grouping files on identifier: %s', identifier)
group = movie_files.get(identifier)
if group:
@ -264,7 +264,7 @@ class Scanner(Plugin):
# Group based on folder
delete_identifiers = []
for identifier, found_files in self.path_identifiers.iteritems():
log.debug('Grouping files on foldername: %s' % identifier)
log.debug('Grouping files on foldername: %s', identifier)
for ff in found_files:
new_identifier = self.createStringIdentifier(os.path.dirname(ff), folder)
@ -308,7 +308,7 @@ class Scanner(Plugin):
break
if file_too_new:
log.info('Files seem to be still unpacking or just unpacked (created on %s), ignoring for now: %s' % (time.ctime(file_time[0]), identifier))
log.info('Files seem to be still unpacking or just unpacked (created on %s), ignoring for now: %s', (time.ctime(file_time[0]), identifier))
# Delete the unsorted list
del group['unsorted_files']
@ -322,7 +322,7 @@ class Scanner(Plugin):
if file_time[0] > time.time() or file_time[1] > time.time():
break
log.debug('None of the files have changed since %s for %s, skipping.' % (time.ctime(newer_than), identifier))
log.debug('None of the files have changed since %s for %s, skipping.', (time.ctime(newer_than), identifier))
# Delete the unsorted list
del group['unsorted_files']
@ -348,10 +348,10 @@ class Scanner(Plugin):
group['files']['movie'] = self.getMediaFiles(group['unsorted_files'])
if len(group['files']['movie']) == 0:
log.error('Couldn\t find any movie files for %s' % identifier)
log.error('Couldn\t find any movie files for %s', identifier)
continue
log.debug('Getting metadata for %s' % identifier)
log.debug('Getting metadata for %s', identifier)
group['meta_data'] = self.getMetaData(group)
# Subtitle meta
@ -384,7 +384,7 @@ class Scanner(Plugin):
# Determine movie
group['library'] = self.determineMovie(group)
if not group['library']:
log.error('Unable to determine movie: %s' % group['identifiers'])
log.error('Unable to determine movie: %s', group['identifiers'])
else:
movie = db.query(Movie).filter_by(library_id = group['library']['id']).first()
group['movie_id'] = None if not movie else movie.id
@ -397,9 +397,9 @@ class Scanner(Plugin):
self.path_identifiers = {}
if len(processed_movies) > 0:
log.info('Found %s movies in the folder %s' % (len(processed_movies), folder))
log.info('Found %s movies in the folder %s', (len(processed_movies), folder))
else:
log.debug('Found no movies in the folder %s' % (folder))
log.debug('Found no movies in the folder %s', (folder))
return processed_movies
def getMetaData(self, group):
@ -419,7 +419,7 @@ class Scanner(Plugin):
data['resolution_height'] = meta.get('resolution_height', 480)
data['aspect'] = meta.get('resolution_width', 720) / meta.get('resolution_height', 480)
except:
log.debug('Error parsing metadata: %s %s' % (cur_file, traceback.format_exc()))
log.debug('Error parsing metadata: %s %s', (cur_file, traceback.format_exc()))
pass
if data.get('audio'): break
@ -447,11 +447,11 @@ class Scanner(Plugin):
'resolution_height': tryInt(p.video[0].height),
}
except ParseError:
log.debug('Failed to parse meta for %s' % filename)
log.debug('Failed to parse meta for %s', filename)
except NoParserError:
log.debug('No parser found for %s' % filename)
log.debug('No parser found for %s', filename)
except:
log.debug('Failed parsing %s' % filename)
log.debug('Failed parsing %s', filename)
return {}
@ -473,7 +473,7 @@ class Scanner(Plugin):
if s.language and s.path not in paths:
detected_languages[s.path] = [s.language]
except:
log.debug('Failed parsing subtitle languages for %s: %s' % (paths, traceback.format_exc()))
log.debug('Failed parsing subtitle languages for %s: %s', (paths, traceback.format_exc()))
# IDX
for extra in group['files']['subtitle_extra']:
@ -489,7 +489,7 @@ class Scanner(Plugin):
if len(idx_langs) > 0 and os.path.isfile(sub_file):
detected_languages[sub_file] = idx_langs
except:
log.error('Failed parsing subtitle idx for %s: %s' % (extra, traceback.format_exc()))
log.error('Failed parsing subtitle idx for %s: %s', (extra, traceback.format_exc()))
return detected_languages
@ -502,7 +502,7 @@ class Scanner(Plugin):
for cur_file in files['movie']:
imdb_id = self.getCPImdb(cur_file)
if imdb_id:
log.debug('Found movie via CP tag: %s' % cur_file)
log.debug('Found movie via CP tag: %s', cur_file)
break
# Check and see if nfo contains the imdb-id
@ -511,7 +511,7 @@ class Scanner(Plugin):
for nfo_file in files['nfo']:
imdb_id = getImdb(nfo_file)
if imdb_id:
log.debug('Found movie via nfo file: %s' % nfo_file)
log.debug('Found movie via nfo file: %s', nfo_file)
break
except:
pass
@ -523,7 +523,7 @@ class Scanner(Plugin):
for filetype_file in files[filetype]:
imdb_id = getImdb(filetype_file, check_inside = False)
if imdb_id:
log.debug('Found movie via imdb in filename: %s' % nfo_file)
log.debug('Found movie via imdb in filename: %s', nfo_file)
break
except:
pass
@ -535,7 +535,7 @@ class Scanner(Plugin):
f = db.query(File).filter_by(path = toUnicode(cur_file)).first()
try:
imdb_id = f.library[0].identifier
log.debug('Found movie via database: %s' % cur_file)
log.debug('Found movie via database: %s', cur_file)
break
except:
pass
@ -549,7 +549,7 @@ class Scanner(Plugin):
if len(movie) > 0:
imdb_id = movie[0]['imdb']
if imdb_id:
log.debug('Found movie via OpenSubtitleHash: %s' % cur_file)
log.debug('Found movie via OpenSubtitleHash: %s', cur_file)
break
# Search based on identifiers
@ -566,17 +566,17 @@ class Scanner(Plugin):
if len(movie) > 0:
imdb_id = movie[0]['imdb']
log.debug('Found movie via search: %s' % cur_file)
log.debug('Found movie via search: %s', cur_file)
if imdb_id: break
else:
log.debug('Identifier to short to use for search: %s' % identifier)
log.debug('Identifier to short to use for search: %s', identifier)
if imdb_id:
return fireEvent('library.add', attrs = {
'identifier': imdb_id
}, update_after = False, single = True)
log.error('No imdb_id found for %s. Add a NFO file with IMDB id or add the year to the filename.' % group['identifiers'])
log.error('No imdb_id found for %s. Add a NFO file with IMDB id or add the year to the filename.', group['identifiers'])
return {}
def getCPImdb(self, string):
@ -665,17 +665,17 @@ class Scanner(Plugin):
# ignoredpaths
for i in self.ignored_in_path:
if i in filename.lower():
log.debug('Ignored "%s" contains "%s".' % (filename, i))
log.debug('Ignored "%s" contains "%s".', (filename, i))
return False
# Sample file
if self.isSampleFile(filename):
log.debug('Is sample file "%s".' % filename)
log.debug('Is sample file "%s".', filename)
return False
# Minimal size
if self.filesizeBetween(filename, self.minimal_filesize['media']):
log.debug('File to small: %s' % filename)
log.debug('File to small: %s', filename)
return False
# All is OK
@ -683,14 +683,14 @@ class Scanner(Plugin):
def isSampleFile(self, filename):
is_sample = re.search('(^|[\W_])sample\d*[\W_]', filename.lower())
if is_sample: log.debug('Is sample file: %s' % filename)
if is_sample: log.debug('Is sample file: %s', filename)
return is_sample
def filesizeBetween(self, file, min = 0, max = 100000):
try:
return (min * 1048576) < os.path.getsize(file) < (max * 1048576)
except:
log.error('Couldn\'t get filesize of %s.' % file)
log.error('Couldn\'t get filesize of %s.', file)
return False
@ -793,7 +793,7 @@ class Scanner(Plugin):
'year': guess.get('year'),
}
except:
log.debug('Could not detect via guessit "%s": %s' % (file_name, traceback.format_exc()))
log.debug('Could not detect via guessit "%s": %s', (file_name, traceback.format_exc()))
# Backup to simple
cleaned = ' '.join(re.split('\W+', simplifyString(release_name)))

26
couchpotato/core/plugins/searcher/main.py

@ -56,7 +56,7 @@ class Searcher(Plugin):
except IndexError:
fireEvent('library.update', movie_dict['library']['identifier'], force = True)
except:
log.error('Search failed for %s: %s' % (movie_dict['library']['identifier'], traceback.format_exc()))
log.error('Search failed for %s: %s', (movie_dict['library']['identifier'], traceback.format_exc()))
# Break if CP wants to shut down
if self.shuttingDown():
@ -88,7 +88,7 @@ class Searcher(Plugin):
ret = False
for quality_type in movie['profile']['types']:
if not self.couldBeReleased(quality_type['quality']['identifier'], release_dates, pre_releases):
log.info('To early to search for %s, %s' % (quality_type['quality']['identifier'], default_title))
log.info('To early to search for %s, %s', (quality_type['quality']['identifier'], default_title))
continue
has_better_quality = 0
@ -101,12 +101,12 @@ class Searcher(Plugin):
# Don't search for quality lower then already available.
if has_better_quality is 0:
log.info('Search for %s in %s' % (default_title, quality_type['quality']['label']))
log.info('Search for %s in %s', (default_title, quality_type['quality']['label']))
quality = fireEvent('quality.single', identifier = quality_type['quality']['identifier'], single = True)
results = fireEvent('yarr.search', movie, quality, merge = True)
sorted_results = sorted(results, key = lambda k: k['score'], reverse = True)
if len(sorted_results) == 0:
log.debug('Nothing found for %s in %s' % (default_title, quality_type['quality']['label']))
log.debug('Nothing found for %s in %s', (default_title, quality_type['quality']['label']))
# Check if movie isn't deleted while searching
if not db.query(Movie).filter_by(id = movie.get('id')).first():
@ -141,7 +141,7 @@ class Searcher(Plugin):
rls.info.append(rls_info)
db.commit()
except InterfaceError:
log.debug('Couldn\'t add %s to ReleaseInfo: %s' % (info, traceback.format_exc()))
log.debug('Couldn\'t add %s to ReleaseInfo: %s', (info, traceback.format_exc()))
for nzb in sorted_results:
@ -152,7 +152,7 @@ class Searcher(Plugin):
elif downloaded != 'try_next':
break
else:
log.info('Better quality (%s) already available or snatched for %s' % (quality_type['quality']['label'], default_title))
log.info('Better quality (%s) already available or snatched for %s', (quality_type['quality']['label'], default_title))
fireEvent('movie.restatus', movie['id'])
break
@ -200,7 +200,7 @@ class Searcher(Plugin):
if movie['status_id'] == active_status.get('id'):
for profile_type in movie['profile']['types']:
if profile_type['quality_id'] == rls.quality.id and profile_type['finish']:
log.info('Renamer disabled, marking movie as finished: %s' % log_movie)
log.info('Renamer disabled, marking movie as finished: %s', log_movie)
# Mark release done
rls.status_id = done_status.get('id')
@ -211,7 +211,7 @@ class Searcher(Plugin):
mvie.status_id = done_status.get('id')
db.commit()
except Exception, e:
log.error('Failed marking movie finished: %s %s' % (e, traceback.format_exc()))
log.error('Failed marking movie finished: %s %s', (e, traceback.format_exc()))
#db.close()
return True
@ -226,7 +226,7 @@ class Searcher(Plugin):
retention = Env.setting('retention', section = 'nzb')
if nzb.get('seeds') is None and retention < nzb.get('age', 0):
log.info('Wrong: Outside retention, age is %s, needs %s or lower: %s' % (nzb['age'], retention, nzb['name']))
log.info('Wrong: Outside retention, age is %s, needs %s or lower: %s', (nzb['age'], retention, nzb['name']))
return False
movie_name = getTitle(movie['library'])
@ -248,7 +248,7 @@ class Searcher(Plugin):
pron_tags = ['xxx', 'sex', 'anal', 'tits', 'fuck', 'porn', 'orgy', 'milf', 'boobs']
for p_tag in pron_tags:
if p_tag in nzb_words and p_tag not in movie_words:
log.info('Wrong: %s, probably pr0n' % (nzb['name']))
log.info('Wrong: %s, probably pr0n', (nzb['name']))
return False
#qualities = fireEvent('quality.all', single = True)
@ -256,18 +256,18 @@ class Searcher(Plugin):
# Contains lower quality string
if self.containsOtherQuality(nzb, movie_year = movie['library']['year'], preferred_quality = preferred_quality, single_category = single_category):
log.info('Wrong: %s, looking for %s' % (nzb['name'], quality['label']))
log.info('Wrong: %s, looking for %s', (nzb['name'], quality['label']))
return False
# File to small
if nzb['size'] and preferred_quality['size_min'] > nzb['size']:
log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.' % (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
log.info('"%s" is too small to be %s. %sMB instead of the minimal of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
return False
# File to large
if nzb['size'] and preferred_quality.get('size_max') < nzb['size']:
log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.' % (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
log.info('"%s" is too large to be %s. %sMB instead of the maximum of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
return False

2
couchpotato/core/plugins/status/main.py

@ -92,7 +92,7 @@ class StatusPlugin(Plugin):
for identifier, label in self.statuses.iteritems():
s = db.query(Status).filter_by(identifier = identifier).first()
if not s:
log.info('Creating status: %s' % label)
log.info('Creating status: %s', label)
s = Status(
identifier = identifier,
label = toUnicode(label)

4
couchpotato/core/plugins/trailer/main.py

@ -18,7 +18,7 @@ class Trailer(Plugin):
trailers = fireEvent('trailer.search', group = group, merge = True)
if not trailers or trailers == []:
log.info('No trailers found for: %s' % getTitle(group['library']))
log.info('No trailers found for: %s', getTitle(group['library']))
return
for trailer in trailers.get(self.conf('quality'), []):
@ -26,7 +26,7 @@ class Trailer(Plugin):
if not os.path.isfile(destination):
fireEvent('file.download', url = trailer, dest = destination, urlopen_kwargs = {'headers': {'User-Agent': 'Quicktime'}}, single = True)
else:
log.debug('Trailer already exists: %s' % destination)
log.debug('Trailer already exists: %s', destination)
# Download first and break
break

2
couchpotato/core/plugins/userscript/main.py

@ -73,7 +73,7 @@ class Userscript(Plugin):
'movie': fireEvent('userscript.get_movie_via_url', url = url, single = True)
}
if not isDict(params['movie']):
log.error('Failed adding movie via url: %s' % url)
log.error('Failed adding movie via url: %s', url)
params['error'] = params['movie'] if params['movie'] else 'Failed getting movie info'
return jsonified(params)

4
couchpotato/core/providers/automation/base.py

@ -20,7 +20,7 @@ class Automation(Plugin):
def _getMovies(self):
if not self.canCheck():
log.debug('Just checked, skipping %s' % self.getName())
log.debug('Just checked, skipping %s', self.getName())
return []
self.last_checked = time.time()
@ -43,7 +43,7 @@ class Automation(Plugin):
type_value = movie.get(minimal_type, 0)
type_min = self.getMinimal(minimal_type)
if type_value < type_min:
log.info('%s to low for %s, need %s has %s' % (minimal_type, identifier, type_min, type_value))
log.info('%s to low for %s, need %s has %s', (minimal_type, identifier, type_min, type_value))
return False
return True

4
couchpotato/core/providers/automation/imdb/main.py

@ -31,7 +31,7 @@ class IMDB(Automation, RSS):
if not enablers[index]:
continue
elif 'rss.imdb' not in rss_url:
log.error('This isn\'t the correct url.: %s' % rss_url)
log.error('This isn\'t the correct url.: %s', rss_url)
continue
prop_name = 'automation.imdb.last_update.%s' % md5(rss_url)
@ -58,7 +58,7 @@ class IMDB(Automation, RSS):
movies.append(imdb)
except:
log.error('Failed loading IMDB watchlist: %s %s' % (rss_url, traceback.format_exc()))
log.error('Failed loading IMDB watchlist: %s %s', (rss_url, traceback.format_exc()))
Env.prop(prop_name, last_movie_added)

2
couchpotato/core/providers/automation/trakt/main.py

@ -43,7 +43,7 @@ class Trakt(Automation):
if self.conf('automation_password'):
headers = {
'Authorization': "Basic %s" % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
'Authorization': 'Basic %s' % base64.encodestring('%s:%s' % (self.conf('automation_username'), self.conf('automation_password')))[:-1]
}
else:
headers = {}

6
couchpotato/core/providers/base.py

@ -31,7 +31,7 @@ class Provider(Plugin):
self.urlopen(test_url, 30)
self.is_available[host] = True
except:
log.error('"%s" unavailable, trying again in an 15 minutes.' % host)
log.error('"%s" unavailable, trying again in an 15 minutes.', host)
self.is_available[host] = False
return self.is_available.get(host, False)
@ -73,7 +73,7 @@ class YarrProvider(Provider):
if hostname in download_url:
return self
except:
log.debug('Url % s doesn\'t belong to %s' % (url, self.getName()))
log.debug('Url % s doesn\'t belong to %s', (url, self.getName()))
return
@ -106,4 +106,4 @@ class YarrProvider(Provider):
return [self.cat_backup_id]
def found(self, new):
log.info('Found: score(%(score)s) on %(provider)s: %(name)s' % new)
log.info('Found: score(%(score)s) on %(provider)s: %(name)s', new)

8
couchpotato/core/providers/metadata/base.py

@ -19,14 +19,14 @@ class MetaDataBase(Plugin):
def create(self, release):
if self.isDisabled(): return
log.info('Creating %s metadata.' % self.getName())
log.info('Creating %s metadata.', self.getName())
# Update library to get latest info
try:
updated_library = fireEvent('library.update', release['library']['identifier'], force = True, single = True)
release['library'] = mergeDicts(release['library'], updated_library)
except:
log.error('Failed to update movie, before creating metadata: %s' % traceback.format_exc())
log.error('Failed to update movie, before creating metadata: %s', traceback.format_exc())
root_name = self.getRootName(release)
meta_name = os.path.basename(root_name)
@ -44,14 +44,14 @@ class MetaDataBase(Plugin):
# Get file content
content = getattr(self, 'get' + file_type.capitalize())(movie_info = movie_info, data = release)
if content:
log.debug('Creating %s file: %s' % (file_type, name))
log.debug('Creating %s file: %s', (file_type, name))
if os.path.isfile(content):
shutil.copy2(content, name)
else:
self.createFile(name, content)
except:
log.error('Unable to create %s file: %s' % (file_type, traceback.format_exc()))
log.error('Unable to create %s file: %s', (file_type, traceback.format_exc()))
def getRootName(self, data):
return

2
couchpotato/core/providers/metadata/xbmc/main.py

@ -77,7 +77,7 @@ class XBMC(MetaDataBase):
votes.text = str(v)
break
except:
log.debug('Failed adding rating info from %s: %s' % (rating_type, traceback.format_exc()))
log.debug('Failed adding rating info from %s: %s', (rating_type, traceback.format_exc()))
# Genre
for genre in movie_info.get('genres', []):

2
couchpotato/core/providers/movie/_modifier/main.py

@ -68,7 +68,7 @@ class MovieResultModifier(Plugin):
if release.status_id == done_status['id']:
temp['in_library'] = fireEvent('movie.get', movie.id, single = True)
except:
log.error('Tried getting more info on searched movies: %s' % traceback.format_exc())
log.error('Tried getting more info on searched movies: %s', traceback.format_exc())
#db.close()
return temp

8
couchpotato/core/providers/movie/couchpotatoapi/main.py

@ -32,10 +32,10 @@ class CouchPotatoApi(MovieProvider):
headers = {'X-CP-Version': fireEvent('app.version', single = True)}
data = self.urlopen((self.api_url % ('eta')) + (identifier + '/'), headers = headers)
dates = json.loads(data)
log.debug('Found ETA for %s: %s' % (identifier, dates))
log.debug('Found ETA for %s: %s', (identifier, dates))
return dates
except Exception, e:
log.error('Error getting ETA for %s: %s' % (identifier, e))
log.error('Error getting ETA for %s: %s', (identifier, e))
return {}
@ -43,9 +43,9 @@ class CouchPotatoApi(MovieProvider):
try:
data = self.urlopen((self.api_url % ('suggest')) + ','.join(movies) + '/' + ','.join(ignore) + '/')
suggestions = json.loads(data)
log.info('Found Suggestions for %s' % (suggestions))
log.info('Found Suggestions for %s', (suggestions))
except Exception, e:
log.error('Error getting suggestions for %s: %s' % (movies, e))
log.error('Error getting suggestions for %s: %s', (movies, e))
return suggestions

6
couchpotato/core/providers/movie/imdbapi/main.py

@ -36,7 +36,7 @@ class IMDBAPI(MovieProvider):
if cached:
result = self.parseMovie(cached)
if result.get('titles') and len(result.get('titles')) > 0:
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
log.info('Found: %s', result['titles'][0] + ' (' + str(result['year']) + ')')
return [result]
return []
@ -54,7 +54,7 @@ class IMDBAPI(MovieProvider):
if cached:
result = self.parseMovie(cached)
if result.get('titles') and len(result.get('titles')) > 0:
log.info('Found: %s' % result['titles'][0] + ' (' + str(result['year']) + ')')
log.info('Found: %s', result['titles'][0] + ' (' + str(result['year']) + ')')
return result
return {}
@ -103,7 +103,7 @@ class IMDBAPI(MovieProvider):
'actors': movie.get('Actors', '').split(','),
}
except:
log.error('Failed parsing IMDB API json: %s' % traceback.format_exc())
log.error('Failed parsing IMDB API json: %s', traceback.format_exc())
return movie_data

24
couchpotato/core/providers/movie/themoviedb/main.py

@ -28,7 +28,7 @@ class TheMovieDb(MovieProvider):
results = self.getCache(cache_key)
if not results:
log.debug('Searching for movie by hash: %s' % file)
log.debug('Searching for movie by hash: %s', file)
try:
raw = tmdb.searchByHashingFile(file)
@ -36,15 +36,15 @@ class TheMovieDb(MovieProvider):
if raw:
try:
results = self.parseMovie(raw)
log.info('Found: %s' % results['titles'][0] + ' (' + str(results['year']) + ')')
log.info('Found: %s', results['titles'][0] + ' (' + str(results['year']) + ')')
self.setCache(cache_key, results)
return results
except SyntaxError, e:
log.error('Failed to parse XML response: %s' % e)
log.error('Failed to parse XML response: %s', e)
return False
except:
log.debug('No movies known by hash for: %s' % file)
log.debug('No movies known by hash for: %s', file)
pass
return results
@ -56,11 +56,11 @@ class TheMovieDb(MovieProvider):
return False
search_string = simplifyString(q)
cache_key = 'tmdb.cache.%s.%s' % (search_string, limit)
cache_key = 'tmdb.cache.%s.%s', (search_string, limit)
results = self.getCache(cache_key)
if not results:
log.debug('Searching for movie: %s' % q)
log.debug('Searching for movie: %s', q)
raw = tmdb.search(search_string)
results = []
@ -75,12 +75,12 @@ class TheMovieDb(MovieProvider):
if nr == limit:
break
log.info('Found: %s' % [result['titles'][0] + ' (' + str(result['year']) + ')' for result in results])
log.info('Found: %s', [result['titles'][0] + ' (' + str(result['year']) + ')' for result in results])
self.setCache(cache_key, results)
return results
except SyntaxError, e:
log.error('Failed to parse XML response: %s' % e)
log.error('Failed to parse XML response: %s', e)
return False
return results
@ -90,7 +90,7 @@ class TheMovieDb(MovieProvider):
if not identifier:
return {}
cache_key = 'tmdb.cache.%s' % identifier
cache_key = 'tmdb.cache.%s', identifier
result = self.getCache(cache_key)
if not result:
@ -98,7 +98,7 @@ class TheMovieDb(MovieProvider):
movie = None
try:
log.debug('Getting info: %s' % cache_key)
log.debug('Getting info: %s', cache_key)
movie = tmdb.imdbLookup(id = identifier)
except:
pass
@ -111,7 +111,7 @@ class TheMovieDb(MovieProvider):
def getInfoByTMDBId(self, id = None):
cache_key = 'tmdb.cache.%s' % id
cache_key = 'tmdb.cache.%s', id
result = self.getCache(cache_key)
if not result:
@ -119,7 +119,7 @@ class TheMovieDb(MovieProvider):
movie = None
try:
log.debug('Getting info: %s' % cache_key)
log.debug('Getting info: %s', cache_key)
movie = tmdb.getMovieInfo(id = id)
except:
pass

6
couchpotato/core/providers/nzb/newzbin/main.py

@ -82,7 +82,7 @@ class Newzbin(NZBProvider, RSS):
data = XMLTree.fromstring(data)
nzbs = self.getElements(data, 'channel/item')
except Exception, e:
log.debug('%s, %s' % (self.getName(), e))
log.debug('%s, %s', (self.getName(), e))
return results
for nzb in nzbs:
@ -133,7 +133,7 @@ class Newzbin(NZBProvider, RSS):
def download(self, url = '', nzb_id = ''):
try:
log.info('Download nzb from newzbin, report id: %s ' % nzb_id)
log.info('Download nzb from newzbin, report id: %s ', nzb_id)
return self.urlopen(self.urls['download'], params = {
'username' : self.conf('username'),
@ -141,7 +141,7 @@ class Newzbin(NZBProvider, RSS):
'reportid' : nzb_id
}, show_error = False)
except Exception, e:
log.error('Failed downloading from newzbin, check credit: %s' % e)
log.error('Failed downloading from newzbin, check credit: %s', e)
return False
def getFormatId(self, format):

12
couchpotato/core/providers/nzb/newznab/main.py

@ -112,7 +112,7 @@ class Newznab(NZBProvider, RSS):
data = XMLTree.fromstring(data)
nzbs = self.getElements(data, 'channel/item')
except Exception, e:
log.debug('%s, %s' % (self.getName(), e))
log.debug('%s, %s', (self.getName(), e))
return results
results = []
@ -126,8 +126,8 @@ class Newznab(NZBProvider, RSS):
elif item.attrib.get('name') == 'usenetdate':
date = item.attrib.get('value')
if date is '': log.debug('Date not parsed properly or not available for %s: %s' % (host['host'], self.getTextElement(nzb, "title")))
if size is 0: log.debug('Size not parsed properly or not available for %s: %s' % (host['host'], self.getTextElement(nzb, "title")))
if date is '': log.debug('Date not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
if size is 0: log.debug('Size not parsed properly or not available for %s: %s', (host['host'], self.getTextElement(nzb, "title")))
id = self.getTextElement(nzb, "guid").split('/')[-1:].pop()
new = {
@ -157,7 +157,7 @@ class Newznab(NZBProvider, RSS):
return results
except SyntaxError:
log.error('Failed to parse XML response from Newznab: %s' % host)
log.error('Failed to parse XML response from Newznab: %s', host)
return results
def getHosts(self):
@ -216,9 +216,9 @@ class Newznab(NZBProvider, RSS):
response = e.read().lower()
if 'maximum api' in response or 'download limit' in response:
if not self.limits_reached.get(host):
log.error('Limit reached for newznab provider: %s' % host)
log.error('Limit reached for newznab provider: %s', host)
self.limits_reached[host] = time.time()
return 'try_next'
log.error('Failed download from %s' % (host, traceback.format_exc()))
log.error('Failed download from %s', (host, traceback.format_exc()))
raise

6
couchpotato/core/providers/nzb/nzbclub/main.py

@ -49,7 +49,7 @@ class NZBClub(NZBProvider, RSS):
data = XMLTree.fromstring(data)
nzbs = self.getElements(data, 'channel/item')
except Exception, e:
log.debug('%s, %s' % (self.getName(), e))
log.debug('%s, %s', (self.getName(), e))
return results
for nzb in nzbs:
@ -63,7 +63,7 @@ class NZBClub(NZBProvider, RSS):
full_description = self.getCache('nzbclub.%s' % nzbclub_id, item['detail_url'], cache_timeout = 25920000)
if 'ARCHIVE inside ARCHIVE' in full_description:
log.info('Wrong: Seems to be passworded files: %s' % new['name'])
log.info('Wrong: Seems to be passworded files: %s', new['name'])
return False
return True
@ -111,7 +111,7 @@ class NZBClub(NZBProvider, RSS):
full_description = self.getCache('nzbclub.%s' % item['id'], item['detail_url'], cache_timeout = 25920000)
if 'ARCHIVE inside ARCHIVE' in full_description:
log.info('Wrong: Seems to be passworded files: %s' % item['name'])
log.info('Wrong: Seems to be passworded files: %s', item['name'])
return False
return True

2
couchpotato/core/providers/nzb/nzbindex/main.py

@ -53,7 +53,7 @@ class NzbIndex(NZBProvider, RSS):
data = XMLTree.fromstring(data)
nzbs = self.getElements(data, 'channel/item')
except Exception, e:
log.debug('%s, %s' % (self.getName(), e))
log.debug('%s, %s', (self.getName(), e))
return results
for nzb in nzbs:

2
couchpotato/core/providers/nzb/nzbmatrix/main.py

@ -58,7 +58,7 @@ class NZBMatrix(NZBProvider, RSS):
data = XMLTree.fromstring(data)
nzbs = self.getElements(data, 'channel/item')
except Exception, e:
log.debug('%s, %s' % (self.getName(), e))
log.debug('%s, %s', (self.getName(), e))
return results
for nzb in nzbs:

2
couchpotato/core/providers/torrent/kickasstorrents/main.py

@ -99,7 +99,7 @@ class KickAssTorrents(TorrentProvider):
results.append(new)
self.found(new)
except:
log.error('Failed parsing KickAssTorrents: %s' % traceback.format_exc())
log.error('Failed parsing KickAssTorrents: %s', traceback.format_exc())
except:
pass

10
couchpotato/core/providers/torrent/thepiratebay/main.py

@ -36,11 +36,11 @@ class ThePirateBay(TorrentProvider):
url = self.apiUrl % (quote_plus(self.toSearchString(movie.name + ' ' + quality) + self.makeIgnoreString(type)), self.getCatId(type))
log.info('Searching: %s' % url)
log.info('Searching: %s', url)
data = self.urlopen(url)
if not data:
log.error('Failed to get data from %s.' % url)
log.error('Failed to get data from %s.', url)
return results
try:
@ -104,7 +104,7 @@ class ThePirateBay(TorrentProvider):
new.content = self.getInfo(new.detailUrl)
if self.isCorrectMovie(new, movie, type):
results.append(new)
log.info('Found: %s' % new.name)
log.info('Found: %s', new.name)
return results
@ -127,11 +127,11 @@ class ThePirateBay(TorrentProvider):
def getInfo(self, url):
log.debug('Getting info: %s' % url)
log.debug('Getting info: %s', url)
data = self.urlopen(url)
if not data:
log.error('Failed to get data from %s.' % url)
log.error('Failed to get data from %s.', url)
return ''
div = SoupStrainer('div')

2
couchpotato/core/providers/trailer/hdtrailers/main.py

@ -94,7 +94,7 @@ class HDTrailers(TrailerProvider):
return results
except AttributeError:
log.debug('No trailers found in provider %s.' % provider)
log.debug('No trailers found in provider %s.', provider)
results['404'] = True
return results

6
couchpotato/core/providers/userscript/youteather/main.py

@ -5,8 +5,8 @@ class YouTheater(UserscriptBase):
id_re = re.compile("view\.php\?id=(\d+)")
includes = ['http://www.youtheater.com/view.php?id=*', 'http://youtheater.com/view.php?id=*',
'http://www.sratim.co.il/view.php?id=*', 'http://sratim.co.il/view.php?id=*']
def getMovie(self, url):
id = self.id_re.findall(url)[0]
url = "http://www.youtheater.com/view.php?id=%s" % id
return super(YouTheater, self).getMovie(url)
url = 'http://www.youtheater.com/view.php?id=%s' % id
return super(YouTheater, self).getMovie(url)

10
couchpotato/runner.py

@ -155,10 +155,10 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
import color_logs
from couchpotato.core.logger import CPLog
log = CPLog(__name__)
log.debug('Started with options %s' % options)
log.debug('Started with options %s', options)
def customwarn(message, category, filename, lineno, file = None, line = None):
log.warning('%s %s %s line:%s' % (category, message, filename, lineno))
log.warning('%s %s %s line:%s', (category, message, filename, lineno))
warnings.showwarning = customwarn
@ -185,7 +185,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
current_db_version = db_version(db, repo)
if current_db_version < latest_db_version and not debug:
log.info('Doing database upgrade. From %d to %d' % (current_db_version, latest_db_version))
log.info('Doing database upgrade. From %d to %d', (current_db_version, latest_db_version))
upgrade(db, repo)
# Configure Database
@ -220,7 +220,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
app.register_blueprint(api, url_prefix = '%s/api/%s/' % (url_base, api_key))
# Some logging and fire load event
try: log.info('Starting server on port %(port)s' % config)
try: log.info('Starting server on port %(port)s', config)
except: pass
fireEventAsync('app.load')
@ -248,7 +248,7 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En
try:
nr, msg = e
if nr == 48:
log.info('Already in use, try %s more time after few seconds' % restart_tries)
log.info('Already in use, try %s more time after few seconds', restart_tries)
time.sleep(1)
restart_tries -= 1

Loading…
Cancel
Save