Browse Source

Remove traces of 8bit ASCII support.

Remove or replace calls to latin1().
Replace all Ta() calls with T().
pull/191/merge
shypike 11 years ago
parent
commit
e184f730e2
  1. 26
      SABnzbd.py
  2. 20
      sabnzbd/__init__.py
  3. 4
      sabnzbd/api.py
  4. 14
      sabnzbd/assembler.py
  5. 2
      sabnzbd/bpsmeter.py
  6. 20
      sabnzbd/config.py
  7. 10
      sabnzbd/database.py
  8. 10
      sabnzbd/decoder.py
  9. 10
      sabnzbd/dirscanner.py
  10. 28
      sabnzbd/downloader.py
  11. 6
      sabnzbd/emailer.py
  12. 5
      sabnzbd/encoding.py
  13. 2
      sabnzbd/growler.py
  14. 18
      sabnzbd/interface.py
  15. 24
      sabnzbd/misc.py
  16. 12
      sabnzbd/newsunpack.py
  17. 2
      sabnzbd/newswrapper.py
  18. 16
      sabnzbd/nzbqueue.py
  19. 34
      sabnzbd/nzbstuff.py
  20. 20
      sabnzbd/panic.py
  21. 14
      sabnzbd/postproc.py
  22. 16
      sabnzbd/powersup.py
  23. 18
      sabnzbd/rss.py
  24. 8
      sabnzbd/scheduler.py
  25. 16
      sabnzbd/tvsort.py

26
SABnzbd.py

@ -96,7 +96,7 @@ import sabnzbd.scheduler as scheduler
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.cfg import sabnzbd.cfg
import sabnzbd.downloader import sabnzbd.downloader
from sabnzbd.encoding import unicoder, latin1, deunicode from sabnzbd.encoding import unicoder, deunicode
import sabnzbd.growler as growler import sabnzbd.growler as growler
import sabnzbd.zconfig import sabnzbd.zconfig
@ -325,7 +325,7 @@ def daemonize():
def Bail_Out(browserhost, cherryport, err=''): def Bail_Out(browserhost, cherryport, err=''):
"""Abort program because of CherryPy troubles """Abort program because of CherryPy troubles
""" """
logging.error(Ta('Failed to start web-interface') + ' : ' + str(err)) logging.error(T('Failed to start web-interface') + ' : ' + str(err))
if not sabnzbd.DAEMON: if not sabnzbd.DAEMON:
if '13' in err: if '13' in err:
panic_xport(browserhost, cherryport) panic_xport(browserhost, cherryport)
@ -363,7 +363,7 @@ def Web_Template(key, defweb, wdir):
if defweb == DEF_STDCONFIG: if defweb == DEF_STDCONFIG:
return '' return ''
# end temp fix # end temp fix
logging.warning(Ta('Cannot find web template: %s, trying standard template'), full_main) logging.warning(T('Cannot find web template: %s, trying standard template'), full_main)
full_dir = real_path(sabnzbd.DIR_INTERFACES, DEF_STDINTF) full_dir = real_path(sabnzbd.DIR_INTERFACES, DEF_STDINTF)
full_main = real_path(full_dir, DEF_MAIN_TMPL) full_main = real_path(full_dir, DEF_MAIN_TMPL)
if not os.path.exists(full_main): if not os.path.exists(full_main):
@ -489,14 +489,14 @@ def print_modules():
logging.info("_yenc module... found!") logging.info("_yenc module... found!")
else: else:
if hasattr(sys, "frozen"): if hasattr(sys, "frozen"):
logging.error(Ta('_yenc module... NOT found!')) logging.error(T('_yenc module... NOT found!'))
else: else:
logging.info("_yenc module... NOT found!") logging.info("_yenc module... NOT found!")
if sabnzbd.newsunpack.PAR2_COMMAND: if sabnzbd.newsunpack.PAR2_COMMAND:
logging.info("par2 binary... found (%s)", sabnzbd.newsunpack.PAR2_COMMAND) logging.info("par2 binary... found (%s)", sabnzbd.newsunpack.PAR2_COMMAND)
else: else:
logging.error(Ta('par2 binary... NOT found!')) logging.error(T('par2 binary... NOT found!'))
if sabnzbd.newsunpack.PAR2C_COMMAND: if sabnzbd.newsunpack.PAR2C_COMMAND:
logging.info("par2-classic binary... found (%s)", sabnzbd.newsunpack.PAR2C_COMMAND) logging.info("par2-classic binary... found (%s)", sabnzbd.newsunpack.PAR2C_COMMAND)
@ -504,17 +504,17 @@ def print_modules():
if sabnzbd.newsunpack.RAR_COMMAND: if sabnzbd.newsunpack.RAR_COMMAND:
logging.info("unrar binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND) logging.info("unrar binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND)
else: else:
logging.warning(Ta('unrar binary... NOT found')) logging.warning(T('unrar binary... NOT found'))
if sabnzbd.newsunpack.ZIP_COMMAND: if sabnzbd.newsunpack.ZIP_COMMAND:
logging.info("unzip binary... found (%s)", sabnzbd.newsunpack.ZIP_COMMAND) logging.info("unzip binary... found (%s)", sabnzbd.newsunpack.ZIP_COMMAND)
else: else:
if sabnzbd.cfg.enable_unzip(): logging.warning(Ta('unzip binary... NOT found!')) if sabnzbd.cfg.enable_unzip(): logging.warning(T('unzip binary... NOT found!'))
if sabnzbd.newsunpack.SEVEN_COMMAND: if sabnzbd.newsunpack.SEVEN_COMMAND:
logging.info("7za binary... found (%s)", sabnzbd.newsunpack.SEVEN_COMMAND) logging.info("7za binary... found (%s)", sabnzbd.newsunpack.SEVEN_COMMAND)
else: else:
if sabnzbd.cfg.enable_7zip(): logging.warning(Ta('7za binary... NOT found!')) if sabnzbd.cfg.enable_7zip(): logging.warning(T('7za binary... NOT found!'))
if not sabnzbd.WIN32: if not sabnzbd.WIN32:
if sabnzbd.newsunpack.NICE_COMMAND: if sabnzbd.newsunpack.NICE_COMMAND:
@ -667,7 +667,7 @@ def get_webhost(cherryhost, cherryport, https_port):
logging.info("IPV6 has priority on this system, potential Firefox issue") logging.info("IPV6 has priority on this system, potential Firefox issue")
if ipv6 and ipv4 and cherryhost == '' and sabnzbd.WIN32: if ipv6 and ipv4 and cherryhost == '' and sabnzbd.WIN32:
logging.warning(Ta('Please be aware the 0.0.0.0 hostname will need an IPv6 address for external access')) logging.warning(T('Please be aware the 0.0.0.0 hostname will need an IPv6 address for external access'))
if cherryhost == 'localhost' and not sabnzbd.WIN32 and not sabnzbd.DARWIN: if cherryhost == 'localhost' and not sabnzbd.WIN32 and not sabnzbd.DARWIN:
# On the Ubuntu family, localhost leads to problems for CherryPy # On the Ubuntu family, localhost leads to problems for CherryPy
@ -697,7 +697,7 @@ def get_webhost(cherryhost, cherryport, https_port):
if cherryport == https_port and sabnzbd.cfg.enable_https(): if cherryport == https_port and sabnzbd.cfg.enable_https():
sabnzbd.cfg.enable_https.set(False) sabnzbd.cfg.enable_https.set(False)
# Should have a translated message, but that's not available yet # Should have a translated message, but that's not available yet
#logging.error(Ta('HTTP and HTTPS ports cannot be the same')) #logging.error(T('HTTP and HTTPS ports cannot be the same'))
logging.error('HTTP and HTTPS ports cannot be the same') logging.error('HTTP and HTTPS ports cannot be the same')
return cherryhost, cherryport, browserhost, https_port return cherryhost, cherryport, browserhost, https_port
@ -1418,7 +1418,7 @@ def main():
create_https_certificates(https_cert, https_key) create_https_certificates(https_cert, https_key)
if not (os.path.exists(https_cert) and os.path.exists(https_key)): if not (os.path.exists(https_cert) and os.path.exists(https_key)):
logging.warning(Ta('Disabled HTTPS because of missing CERT and KEY files')) logging.warning(T('Disabled HTTPS because of missing CERT and KEY files'))
enable_https = False enable_https = False
# Determine if this system has multiple definitions for 'localhost' # Determine if this system has multiple definitions for 'localhost'
@ -1871,9 +1871,9 @@ if __name__ == '__main__':
args = [] args = []
for txt in sys.argv: for txt in sys.argv:
if ' ' in txt: if ' ' in txt:
txt = '"%s"' % latin1(txt) txt = '"%s"' % unicoder(txt)
else: else:
txt = latin1(txt) txt = unicoder(txt)
args.append(txt) args.append(txt)
sabnzbd.CMDLINE = ' '.join(args) sabnzbd.CMDLINE = ' '.join(args)

20
sabnzbd/__init__.py

@ -169,7 +169,7 @@ def sig_handler(signum = None, frame = None):
# Ignore the "logoff" event when running as a Win32 daemon # Ignore the "logoff" event when running as a Win32 daemon
return True return True
if type(signum) != type(None): if type(signum) != type(None):
logging.warning(Ta('Signal %s caught, saving and exiting...'), signum) logging.warning(T('Signal %s caught, saving and exiting...'), signum)
try: try:
save_state(flag=True) save_state(flag=True)
sabnzbd.zconfig.remove_server() sabnzbd.zconfig.remove_server()
@ -599,7 +599,7 @@ def add_nzbfile(nzbfile, pp=None, script=None, cat=None, priority=NORMAL_PRIORIT
os.write(f, nzbfile.file.read()) os.write(f, nzbfile.file.read())
os.close(f) os.close(f)
except: except:
logging.error(Ta('Cannot create temp file for %s'), filename) logging.error(T('Cannot create temp file for %s'), filename)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
if ext.lower() in VALID_ARCHIVES: if ext.lower() in VALID_ARCHIVES:
@ -616,7 +616,7 @@ def enable_server(server):
try: try:
config.get_config('servers', server).enable.set(1) config.get_config('servers', server).enable.set(1)
except: except:
logging.warning(Ta('Trying to set status of non-existing server %s'), server) logging.warning(T('Trying to set status of non-existing server %s'), server)
return return
config.save_config() config.save_config()
Downloader.do.update_server(server, server) Downloader.do.update_server(server, server)
@ -628,7 +628,7 @@ def disable_server(server):
try: try:
config.get_config('servers', server).enable.set(0) config.get_config('servers', server).enable.set(0)
except: except:
logging.warning(Ta('Trying to set status of non-existing server %s'), server) logging.warning(T('Trying to set status of non-existing server %s'), server)
return return
config.save_config() config.save_config()
Downloader.do.update_server(server, server) Downloader.do.update_server(server, server)
@ -769,7 +769,7 @@ def CheckFreeSpace():
""" """
if cfg.download_free() and not sabnzbd.downloader.Downloader.do.paused: if cfg.download_free() and not sabnzbd.downloader.Downloader.do.paused:
if misc.diskfree(cfg.download_dir.get_path()) < cfg.download_free.get_float() / GIGI: if misc.diskfree(cfg.download_dir.get_path()) < cfg.download_free.get_float() / GIGI:
logging.warning(Ta('Too little diskspace forcing PAUSE')) logging.warning(T('Too little diskspace forcing PAUSE'))
# Pause downloader, but don't save, since the disk is almost full! # Pause downloader, but don't save, since the disk is almost full!
Downloader.do.pause(save=False) Downloader.do.pause(save=False)
emailer.diskfull() emailer.diskfull()
@ -795,7 +795,7 @@ def get_new_id(prefix, folder, check_list=None):
if not check_list or tail not in check_list: if not check_list or tail not in check_list:
return tail return tail
except: except:
logging.error(Ta('Failure in tempfile.mkstemp')) logging.error(T('Failure in tempfile.mkstemp'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
# Cannot create unique id, crash the process # Cannot create unique id, crash the process
raise IOError raise IOError
@ -825,7 +825,7 @@ def save_data(data, _id, path, do_pickle = True, silent=False):
_f.flush() _f.flush()
_f.close() _f.close()
except: except:
logging.error(Ta('Saving %s failed'), path) logging.error(T('Saving %s failed'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -855,7 +855,7 @@ def load_data(_id, path, remove=True, do_pickle=True, silent=False):
if remove: if remove:
os.remove(path) os.remove(path)
except: except:
logging.error(Ta('Loading %s failed'), path) logging.error(T('Loading %s failed'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return None return None
@ -896,7 +896,7 @@ def save_admin(data, _id, do_pickle=True):
_f.flush() _f.flush()
_f.close() _f.close()
except: except:
logging.error(Ta('Saving %s failed'), path) logging.error(T('Saving %s failed'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -922,7 +922,7 @@ def load_admin(_id, remove=False, do_pickle=True):
os.remove(path) os.remove(path)
except: except:
excepterror = str(sys.exc_info()[0]) excepterror = str(sys.exc_info()[0])
logging.error(Ta('Loading %s failed with error %s'), path, excepterror) logging.error(T('Loading %s failed with error %s'), path, excepterror)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return None return None

4
sabnzbd/api.py

@ -1620,7 +1620,7 @@ def build_header(prim, webdir='', search=None):
header['speedlimit'] = "%s" % speed_limit header['speedlimit'] = "%s" % speed_limit
header['restart_req'] = sabnzbd.RESTART_REQ header['restart_req'] = sabnzbd.RESTART_REQ
header['have_warnings'] = str(sabnzbd.GUIHANDLER.count()) header['have_warnings'] = str(sabnzbd.GUIHANDLER.count())
header['last_warning'] = sabnzbd.GUIHANDLER.last().replace('WARNING', Ta('WARNING:')).replace('ERROR', Ta('ERROR:')) header['last_warning'] = sabnzbd.GUIHANDLER.last().replace('WARNING', ('WARNING:')).replace('ERROR', T('ERROR:'))
header['active_lang'] = cfg.language() header['active_lang'] = cfg.language()
header['my_lcldata'] = sabnzbd.DIR_LCLDATA header['my_lcldata'] = sabnzbd.DIR_LCLDATA
header['my_home'] = sabnzbd.DIR_HOME header['my_home'] = sabnzbd.DIR_HOME
@ -1707,7 +1707,7 @@ def build_history(start=None, limit=None, verbose=False, verbose_list=None, sear
try: try:
re_search = re.compile(search_text, re.I) re_search = re.compile(search_text, re.I)
except: except:
logging.error(Ta('Failed to compile regex for search term: %s'), search_text) logging.error(T('Failed to compile regex for search term: %s'), search_text)
return False return False
return re_search.search(text) return re_search.search(text)

14
sabnzbd/assembler.py

@ -43,7 +43,7 @@ from sabnzbd.articlecache import ArticleCache
from sabnzbd.postproc import PostProcessor from sabnzbd.postproc import PostProcessor
import sabnzbd.downloader import sabnzbd.downloader
from sabnzbd.utils.rarfile import RarFile, is_rarfile from sabnzbd.utils.rarfile import RarFile, is_rarfile
from sabnzbd.encoding import latin1, unicoder, is_utf8 from sabnzbd.encoding import unicoder, is_utf8
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -95,7 +95,7 @@ class Assembler(Thread):
else: else:
# 28 == disk full => pause downloader # 28 == disk full => pause downloader
if errno == 28: if errno == 28:
logging.error(Ta('Disk full! Forcing Pause')) logging.error(T('Disk full! Forcing Pause'))
else: else:
logging.error(T('Disk error on creating file %s'), filepath) logging.error(T('Disk error on creating file %s'), filepath)
# Pause without saving # Pause without saving
@ -114,18 +114,18 @@ class Assembler(Thread):
if check_encrypted_rar(nzo, filepath): if check_encrypted_rar(nzo, filepath):
if cfg.pause_on_pwrar() == 1: if cfg.pause_on_pwrar() == 1:
logging.warning(Ta('WARNING: Paused job "%s" because of encrypted RAR file'), latin1(nzo.final_name)) logging.warning(T('WARNING: Paused job "%s" because of encrypted RAR file'), nzo.final_name)
nzo.pause() nzo.pause()
else: else:
logging.warning(Ta('WARNING: Aborted job "%s" because of encrypted RAR file'), latin1(nzo.final_name)) logging.warning(T('WARNING: Aborted job "%s" because of encrypted RAR file'), nzo.final_name)
nzo.fail_msg = T('Aborted, encryption detected') nzo.fail_msg = T('Aborted, encryption detected')
import sabnzbd.nzbqueue import sabnzbd.nzbqueue
sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo) sabnzbd.nzbqueue.NzbQueue.do.end_job(nzo)
unwanted = rar_contains_unwanted_file(nzo, filepath) unwanted = rar_contains_unwanted_file(nzo, filepath)
if unwanted: if unwanted:
logging.warning(Ta('WARNING: In "%s" unwanted extension in RAR file. Unwanted file is %s '), latin1(nzo.final_name), unwanted) logging.warning(T('WARNING: In "%s" unwanted extension in RAR file. Unwanted file is %s '), nzo.final_name, unwanted)
logging.debug(Ta('Unwanted extension is in rar file %s'), filepath) logging.debug(T('Unwanted extension is in rar file %s'), filepath)
if cfg.action_on_unwanted_extensions() == 1 and nzo.unwanted_ext == 0: if cfg.action_on_unwanted_extensions() == 1 and nzo.unwanted_ext == 0:
logging.debug('Unwanted extension ... pausing') logging.debug('Unwanted extension ... pausing')
nzo.unwanted_ext = 1 nzo.unwanted_ext = 1
@ -168,7 +168,7 @@ def _assemble(nzf, path, dupe):
data = ArticleCache.do.load_article(article) data = ArticleCache.do.load_article(article)
if not data: if not data:
logging.info(Ta('%s missing'), article) logging.info(T('%s missing'), article)
else: else:
# yenc data already decoded, flush it out # yenc data already decoded, flush it out
if _type == 'yenc': if _type == 'yenc':

2
sabnzbd/bpsmeter.py

@ -250,7 +250,7 @@ class BPSMeter(object):
from sabnzbd.downloader import Downloader from sabnzbd.downloader import Downloader
if Downloader.do and not Downloader.do.paused: if Downloader.do and not Downloader.do.paused:
Downloader.do.pause() Downloader.do.pause()
logging.warning(Ta('Quota spent, pausing downloading')) logging.warning(T('Quota spent, pausing downloading'))
# Speedometer # Speedometer
try: try:

20
sabnzbd/config.py

@ -218,7 +218,7 @@ class OptionDir(Option):
if value and (self.__create or create): if value and (self.__create or create):
res, path = sabnzbd.misc.create_real_path(self.ident()[1], self.__root, value, self.__apply_umask) res, path = sabnzbd.misc.create_real_path(self.ident()[1], self.__root, value, self.__apply_umask)
if not res: if not res:
error = Ta("Cannot create %s folder %s") % (self.ident()[1], path) error = T('Cannot create %s folder %s') % (self.ident()[1], path)
if not error: if not error:
self._Option__set(value) self._Option__set(value)
return error return error
@ -795,7 +795,7 @@ def save_config(force=False):
# Check if file is writable # Check if file is writable
if not sabnzbd.misc.is_writable(filename): if not sabnzbd.misc.is_writable(filename):
logging.error(Ta('Cannot write to INI file %s'), filename) logging.error(T('Cannot write to INI file %s'), filename)
return res return res
# copy current file to backup # copy current file to backup
@ -803,7 +803,7 @@ def save_config(force=False):
shutil.copyfile(filename, bakname) shutil.copyfile(filename, bakname)
except: except:
# Something wrong with the backup, # Something wrong with the backup,
logging.error(Ta('Cannot create backup file for %s'), bakname) logging.error(T('Cannot create backup file for %s'), bakname)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return res return res
@ -813,7 +813,7 @@ def save_config(force=False):
modified = False modified = False
res = True res = True
except: except:
logging.error(Ta('Cannot write to INI file %s'), filename) logging.error(T('Cannot write to INI file %s'), filename)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
try: try:
os.remove(filename) os.remove(filename)
@ -942,7 +942,7 @@ def decode_password(pw, name):
try: try:
ch = chr( int(pw[n] + pw[n+1], 16) ) ch = chr( int(pw[n] + pw[n+1], 16) )
except ValueError: except ValueError:
logging.error(Ta('Incorrectly encoded password %s'), name) logging.error(T('Incorrectly encoded password %s'), name)
return '' return ''
decPW += ch decPW += ch
return decPW return decPW
@ -966,7 +966,7 @@ def validate_octal(value):
int(value, 8) int(value, 8)
return None, value return None, value
except: except:
return Ta('%s is not a correct octal value') % value, None return T('%s is not a correct octal value') % value, None
def validate_no_unc(root, value, default): def validate_no_unc(root, value, default):
@ -975,7 +975,7 @@ def validate_no_unc(root, value, default):
if value and not value.startswith(r'\\'): if value and not value.startswith(r'\\'):
return validate_notempty(root, value, default) return validate_notempty(root, value, default)
else: else:
return Ta('UNC path "%s" not allowed here') % value, None return T('UNC path "%s" not allowed here') % value, None
def validate_safedir(root, value, default): def validate_safedir(root, value, default):
@ -983,11 +983,11 @@ def validate_safedir(root, value, default):
On Windows path should be 80 max On Windows path should be 80 max
""" """
if sabnzbd.WIN32 and value and len(sabnzbd.misc.real_path(root, value)) > 80: if sabnzbd.WIN32 and value and len(sabnzbd.misc.real_path(root, value)) > 80:
return Ta('Error: Path length should be below 80.'), None return T('Error: Path length should be below 80.'), None
if sabnzbd.empty_queues(): if sabnzbd.empty_queues():
return validate_no_unc(root, value, default) return validate_no_unc(root, value, default)
else: else:
return Ta('Error: Queue not empty, cannot change folder.'), None return T('Error: Queue not empty, cannot change folder.'), None
def validate_dir_exists(root, value, default): def validate_dir_exists(root, value, default):
@ -996,7 +996,7 @@ def validate_dir_exists(root, value, default):
if os.path.exists(p): if os.path.exists(p):
return None, value return None, value
else: else:
return Ta('Folder "%s" does not exist') % p, None return T('Folder "%s" does not exist') % p, None
def validate_notempty(root, value, default): def validate_notempty(root, value, default):

10
sabnzbd/database.py

@ -120,11 +120,11 @@ class HistoryDB(object):
except: except:
error = str(sys.exc_value) error = str(sys.exc_value)
if 'readonly' in error: if 'readonly' in error:
logging.error(Ta('Cannot write to History database, check access rights!')) logging.error(T('Cannot write to History database, check access rights!'))
# Report back success, because there's no recovery possible # Report back success, because there's no recovery possible
return True return True
elif 'not a database' in error or 'malformed' in error: elif 'not a database' in error or 'malformed' in error:
logging.error(Ta('Damaged History database, created empty replacement')) logging.error(T('Damaged History database, created empty replacement'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
self.close() self.close()
try: try:
@ -133,7 +133,7 @@ class HistoryDB(object):
pass pass
self.connect() self.connect()
else: else:
logging.error(Ta('SQL Command Failed, see log')) logging.error(T('SQL Command Failed, see log'))
logging.debug("SQL: %s" , command) logging.debug("SQL: %s" , command)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
try: try:
@ -181,7 +181,7 @@ class HistoryDB(object):
try: try:
self.con.commit() self.con.commit()
except: except:
logging.error(Ta('SQL Commit Failed, see log')) logging.error(T('SQL Commit Failed, see log'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
def close(self): def close(self):
@ -189,7 +189,7 @@ class HistoryDB(object):
self.c.close() self.c.close()
self.con.close() self.con.close()
except: except:
logging.error(Ta('Failed to close database, see log')) logging.error(T('Failed to close database, see log'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
def remove_completed(self, search=None): def remove_completed(self, search=None):

10
sabnzbd/decoder.py

@ -104,7 +104,7 @@ class Decoder(Thread):
nzf.article_count += 1 nzf.article_count += 1
found = True found = True
except IOError, e: except IOError, e:
logme = Ta('Decoding %s failed') % art_id logme = T('Decoding %s failed') % art_id
logging.warning(logme) logging.warning(logme)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -117,7 +117,7 @@ class Decoder(Thread):
register = False register = False
except CrcError, e: except CrcError, e:
logme = Ta('CRC Error in %s (%s -> %s)') % (art_id, e.needcrc, e.gotcrc) logme = T('CRC Error in %s (%s -> %s)') % (art_id, e.needcrc, e.gotcrc)
logging.info(logme) logging.info(logme)
data = e.data data = e.data
@ -154,7 +154,7 @@ class Decoder(Thread):
logging.debug('Server has article %s', art_id) logging.debug('Server has article %s', art_id)
register = True register = True
elif not killed and not found: elif not killed and not found:
logme = Ta('Badly formed yEnc article in %s') % art_id logme = T('Badly formed yEnc article in %s') % art_id
logging.info(logme) logging.info(logme)
if not found or killed: if not found or killed:
@ -164,7 +164,7 @@ class Decoder(Thread):
logme = None logme = None
except: except:
logme = Ta('Unknown Error while decoding %s') % art_id logme = T('Unknown Error while decoding %s') % art_id
logging.info(logme) logging.info(logme)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -226,7 +226,7 @@ class Decoder(Thread):
logging.debug('%s => found at least one untested server', article) logging.debug('%s => found at least one untested server', article)
else: else:
msg = Ta('%s => missing from all servers, discarding') % article msg = T('%s => missing from all servers, discarding') % article
logging.info(msg) logging.info(msg)
article.nzf.nzo.inc_log('missing_art_log', msg) article.nzf.nzo.inc_log('missing_art_log', msg)

10
sabnzbd/dirscanner.py

@ -128,7 +128,7 @@ def ProcessArchiveFile(filename, path, pp=None, script=None, cat=None, catdir=No
try: try:
if not keep: os.remove(path) if not keep: os.remove(path)
except: except:
logging.error(Ta('Error removing %s'), path) logging.error(T('Error removing %s'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
status = 1 status = 1
else: else:
@ -166,7 +166,7 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
data = f.read() data = f.read()
f.close() f.close()
except: except:
logging.warning(Ta('Cannot read %s'), path) logging.warning(T('Cannot read %s'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return -2, nzo_ids return -2, nzo_ids
@ -199,7 +199,7 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
try: try:
if not keep: os.remove(path) if not keep: os.remove(path)
except: except:
logging.error(Ta('Error removing %s'), path) logging.error(T('Error removing %s'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return 1, nzo_ids return 1, nzo_ids
@ -299,7 +299,7 @@ class DirScanner(threading.Thread):
files = os.listdir(folder) files = os.listdir(folder)
except: except:
if not self.error_reported and not catdir: if not self.error_reported and not catdir:
logging.error(Ta('Cannot read Watched Folder %s'), folder) logging.error(T('Cannot read Watched Folder %s'), folder)
self.error_reported = True self.error_reported = True
files = [] files = []
@ -382,7 +382,7 @@ class DirScanner(threading.Thread):
list = os.listdir(dirscan_dir) list = os.listdir(dirscan_dir)
except: except:
if not self.error_reported: if not self.error_reported:
logging.error(Ta('Cannot read Watched Folder %s'), dirscan_dir) logging.error(T('Cannot read Watched Folder %s'), dirscan_dir)
self.error_reported = True self.error_reported = True
list = [] list = []

28
sabnzbd/downloader.py

@ -258,7 +258,7 @@ class Downloader(Thread):
if mx: if mx:
self.bandwidth_limit = mx * int(value) / 100 self.bandwidth_limit = mx * int(value) / 100
else: else:
logging.warning(Ta('You must set a maximum bandwidth before you can set a bandwidth limit')) logging.warning(T('You must set a maximum bandwidth before you can set a bandwidth limit'))
else: else:
self.speed_set() self.speed_set()
logging.info("Bandwidth limit set to %s%%", value) logging.info("Bandwidth limit set to %s%%", value)
@ -301,7 +301,7 @@ class Downloader(Thread):
server.bad_cons = 0 server.bad_cons = 0
server.active = False server.active = False
server.errormsg = T('Server %s will be ignored for %s minutes') % ('', _PENALTY_TIMEOUT) server.errormsg = T('Server %s will be ignored for %s minutes') % ('', _PENALTY_TIMEOUT)
logging.warning(Ta('Server %s will be ignored for %s minutes'), server.id, _PENALTY_TIMEOUT) logging.warning(T('Server %s will be ignored for %s minutes'), server.id, _PENALTY_TIMEOUT)
self.plan_server(server.id, _PENALTY_TIMEOUT) self.plan_server(server.id, _PENALTY_TIMEOUT)
# Remove all connections to server # Remove all connections to server
@ -394,7 +394,7 @@ class Downloader(Thread):
nw.thrdnum, server.id) nw.thrdnum, server.id)
nw.init_connect(self.write_fds) nw.init_connect(self.write_fds)
except: except:
logging.error(Ta('Failed to initialize %s@%s'), nw.thrdnum, server.id) logging.error(T('Failed to initialize %s@%s'), nw.thrdnum, server.id)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
self.__reset_nw(nw, "failed to initialize") self.__reset_nw(nw, "failed to initialize")
@ -526,30 +526,30 @@ class Downloader(Thread):
# Too many connections: remove this thread and reduce thread-setting for server # Too many connections: remove this thread and reduce thread-setting for server
# Plan to go back to the full number after a penalty timeout # Plan to go back to the full number after a penalty timeout
if server.active: if server.active:
server.errormsg = Ta('Too many connections to server %s') % display_msg server.errormsg = T('Too many connections to server %s') % display_msg
logging.error(Ta('Too many connections to server %s'), server.id) logging.error(T('Too many connections to server %s'), server.id)
self.__reset_nw(nw, None, warn=False, destroy=True, quit=True) self.__reset_nw(nw, None, warn=False, destroy=True, quit=True)
self.plan_server(server.id, _PENALTY_TOOMANY) self.plan_server(server.id, _PENALTY_TOOMANY)
server.threads -= 1 server.threads -= 1
elif ecode in ('502', '481') and clues_too_many_ip(msg): elif ecode in ('502', '481') and clues_too_many_ip(msg):
# Account sharing? # Account sharing?
if server.active: if server.active:
server.errormsg = Ta('Probable account sharing') + display_msg server.errormsg = T('Probable account sharing') + display_msg
name = ' (%s)' % server.id name = ' (%s)' % server.id
logging.error(Ta('Probable account sharing') + name) logging.error(T('Probable account sharing') + name)
penalty = _PENALTY_SHARE penalty = _PENALTY_SHARE
elif ecode in ('481', '482', '381') or (ecode == '502' and clues_login(msg)): elif ecode in ('481', '482', '381') or (ecode == '502' and clues_login(msg)):
# Cannot login, block this server # Cannot login, block this server
if server.active: if server.active:
server.errormsg = Ta('Failed login for server %s') % display_msg server.errormsg = T('Failed login for server %s') % display_msg
logging.error(Ta('Failed login for server %s'), server.id) logging.error(T('Failed login for server %s'), server.id)
penalty = _PENALTY_PERM penalty = _PENALTY_PERM
block = True block = True
elif ecode == '502': elif ecode == '502':
# Cannot connect (other reasons), block this server # Cannot connect (other reasons), block this server
if server.active: if server.active:
server.errormsg = Ta('Cannot connect to server %s [%s]') % ('', display_msg) server.errormsg = T('Cannot connect to server %s [%s]') % ('', display_msg)
logging.warning(Ta('Cannot connect to server %s [%s]'), server.id, msg) logging.warning(T('Cannot connect to server %s [%s]'), server.id, msg)
if clues_pay(msg): if clues_pay(msg):
penalty = _PENALTY_PERM penalty = _PENALTY_PERM
else: else:
@ -564,8 +564,8 @@ class Downloader(Thread):
else: else:
# Unknown error, just keep trying # Unknown error, just keep trying
if server.active: if server.active:
server.errormsg = Ta('Cannot connect to server %s [%s]') % ('', display_msg) server.errormsg = T('Cannot connect to server %s [%s]') % ('', display_msg)
logging.error(Ta('Cannot connect to server %s [%s]'), server.id, msg) logging.error(T('Cannot connect to server %s [%s]'), server.id, msg)
penalty = _PENALTY_UNKNOWN penalty = _PENALTY_UNKNOWN
if block or (penalty and server.optional): if block or (penalty and server.optional):
if server.active: if server.active:
@ -579,7 +579,7 @@ class Downloader(Thread):
self.__reset_nw(nw, None, warn=False, quit=True) self.__reset_nw(nw, None, warn=False, quit=True)
continue continue
except: except:
logging.error(Ta('Connecting %s@%s failed, message=%s'), logging.error(T('Connecting %s@%s failed, message=%s'),
nw.thrdnum, nw.server.id, nw.lines[0]) nw.thrdnum, nw.server.id, nw.lines[0])
# No reset-warning needed, above logging is sufficient # No reset-warning needed, above logging is sufficient
self.__reset_nw(nw, None, warn=False) self.__reset_nw(nw, None, warn=False)

6
sabnzbd/emailer.py

@ -30,11 +30,11 @@ import glob
from sabnzbd.constants import * from sabnzbd.constants import *
import sabnzbd import sabnzbd
from sabnzbd.misc import to_units, split_host, time_format from sabnzbd.misc import to_units, split_host, time_format
from sabnzbd.encoding import EmailFilter, latin1 from sabnzbd.encoding import EmailFilter
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
def errormsg(msg): def errormsg(msg):
logging.error(latin1(msg)) logging.error(msg)
return msg return msg
@ -178,7 +178,7 @@ def send_with_template(prefix, parm, test=None):
try: try:
lst = glob.glob(os.path.join(path, '%s-*.tmpl' % prefix)) lst = glob.glob(os.path.join(path, '%s-*.tmpl' % prefix))
except: except:
logging.error(Ta('Cannot find email templates in %s'), path) logging.error(T('Cannot find email templates in %s'), path)
else: else:
path = os.path.join(sabnzbd.DIR_PROG, DEF_EMAIL_TMPL) path = os.path.join(sabnzbd.DIR_PROG, DEF_EMAIL_TMPL)
tpath = os.path.join(path, '%s-%s.tmpl' % (prefix, cfg.language())) tpath = os.path.join(path, '%s-%s.tmpl' % (prefix, cfg.language()))

5
sabnzbd/encoding.py

@ -149,11 +149,6 @@ def xml_name(p, keep_escape=False, encoding=None):
return escape(p).encode('ascii', 'xmlcharrefreplace') return escape(p).encode('ascii', 'xmlcharrefreplace')
def latin1(txt):
""" When Unicode or UTF-8, convert to Latin-1 """
return unicoder(txt)
def encode_for_xml(ustr, encoding='ascii'): def encode_for_xml(ustr, encoding='ascii'):
""" """
Encode unicode_data for use as XML or HTML, with characters outside Encode unicode_data for use as XML or HTML, with characters outside

2
sabnzbd/growler.py

@ -31,7 +31,7 @@ from threading import Thread
import sabnzbd import sabnzbd
import sabnzbd.cfg import sabnzbd.cfg
from sabnzbd.encoding import unicoder, latin1 from sabnzbd.encoding import unicoder
from sabnzbd.constants import NOTIFY_KEYS from sabnzbd.constants import NOTIFY_KEYS
from gntp import GNTPRegister from gntp import GNTPRegister

18
sabnzbd/interface.py

@ -40,7 +40,7 @@ from sabnzbd.panic import panic_old_queue
from sabnzbd.newswrapper import GetServerParms from sabnzbd.newswrapper import GetServerParms
from sabnzbd.bpsmeter import BPSMeter from sabnzbd.bpsmeter import BPSMeter
from sabnzbd.encoding import TRANS, xml_name, LatinFilter, unicoder, special_fixer, \ from sabnzbd.encoding import TRANS, xml_name, LatinFilter, unicoder, special_fixer, \
platform_encode, latin1, encode_for_xml platform_encode, encode_for_xml
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import sabnzbd.newsunpack import sabnzbd.newsunpack
@ -172,10 +172,10 @@ def check_session(kwargs):
key = kwargs.get('apikey') key = kwargs.get('apikey')
msg = None msg = None
if not key: if not key:
logging.warning(Ta('Missing Session key')) logging.warning(T('Missing Session key'))
msg = T('Error: Session Key Required') msg = T('Error: Session Key Required')
elif key != cfg.api_key(): elif key != cfg.api_key():
logging.warning(Ta('Error: Session Key Incorrect')) logging.warning(T('Error: Session Key Incorrect'))
msg = T('Error: Session Key Incorrect') msg = T('Error: Session Key Incorrect')
return msg return msg
@ -213,14 +213,14 @@ def check_apikey(kwargs, nokey=False):
key = kwargs.get('apikey') key = kwargs.get('apikey')
if not key: if not key:
if not special: if not special:
log_warning(Ta('API Key missing, please enter the api key from Config->General into your 3rd party program:')) log_warning(T('API Key missing, please enter the api key from Config->General into your 3rd party program:'))
return report(output, 'API Key Required', callback=callback) return report(output, 'API Key Required', callback=callback)
elif req_access == 1 and key == cfg.nzb_key(): elif req_access == 1 and key == cfg.nzb_key():
return None return None
elif key == cfg.api_key(): elif key == cfg.api_key():
return None return None
else: else:
log_warning(Ta('API Key incorrect, Use the api key from Config->General in your 3rd party program:')) log_warning(T('API Key incorrect, Use the api key from Config->General in your 3rd party program:'))
return report(output, 'API Key Incorrect', callback=callback) return report(output, 'API Key Incorrect', callback=callback)
# No active APIKEY, check web credentials instead # No active APIKEY, check web credentials instead
@ -229,7 +229,7 @@ def check_apikey(kwargs, nokey=False):
pass pass
else: else:
if not special: if not special:
log_warning(Ta('Authentication missing, please enter username/password from Config->General into your 3rd party program:')) log_warning(T('Authentication missing, please enter username/password from Config->General into your 3rd party program:'))
return report(output, 'Missing authentication', callback=callback) return report(output, 'Missing authentication', callback=callback)
return None return None
@ -1470,7 +1470,7 @@ class ConfigGeneral(object):
cfg.bandwidth_perc.set(bandwidth_perc) cfg.bandwidth_perc.set(bandwidth_perc)
bandwidth_perc = cfg.bandwidth_perc() bandwidth_perc = cfg.bandwidth_perc()
if bandwidth_perc and not bandwidth_max: if bandwidth_perc and not bandwidth_max:
logging.warning(Ta('You must set a maximum bandwidth before you can set a bandwidth limit')) logging.warning(T('You must set a maximum bandwidth before you can set a bandwidth limit'))
config.save_config() config.save_config()
@ -1740,7 +1740,7 @@ class ConfigRss(object):
# Find a unique new Feed name # Find a unique new Feed name
unum = 1 unum = 1
txt = Ta('Feed') #: Used as default Feed name in Config->RSS txt = T('Feed') #: Used as default Feed name in Config->RSS
while txt + str(unum) in feeds: while txt + str(unum) in feeds:
unum += 1 unum += 1
conf['feed'] = txt + str(unum) conf['feed'] = txt + str(unum)
@ -2312,7 +2312,7 @@ class Status(object):
wlist = [] wlist = []
for w in sabnzbd.GUIHANDLER.content(): for w in sabnzbd.GUIHANDLER.content():
w = w.replace('WARNING', Ta('WARNING:')).replace('ERROR', Ta('ERROR:')) w = w.replace('WARNING', T('WARNING:')).replace('ERROR', T('ERROR:'))
wlist.insert(0, unicoder(w)) wlist.insert(0, unicoder(w))
header['warnings'] = wlist header['warnings'] = wlist

24
sabnzbd/misc.py

@ -42,7 +42,7 @@ from sabnzbd.decorators import synchronized
from sabnzbd.constants import DEFAULT_PRIORITY, FUTURE_Q_FOLDER, JOB_ADMIN, GIGI, Status, MEBI from sabnzbd.constants import DEFAULT_PRIORITY, FUTURE_Q_FOLDER, JOB_ADMIN, GIGI, Status, MEBI
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.encoding import unicoder, latin1, special_fixer, gUTF from sabnzbd.encoding import unicoder, special_fixer, gUTF
import sabnzbd.growler as growler import sabnzbd.growler as growler
RE_VERSION = re.compile('(\d+)\.(\d+)\.(\d+)([a-zA-Z]*)(\d*)') RE_VERSION = re.compile('(\d+)\.(\d+)\.(\d+)([a-zA-Z]*)(\d*)')
@ -405,13 +405,13 @@ def create_real_path(name, loc, path, umask=False):
if not os.path.exists(my_dir): if not os.path.exists(my_dir):
logging.info('%s directory: %s does not exist, try to create it', name, my_dir) logging.info('%s directory: %s does not exist, try to create it', name, my_dir)
if not create_all_dirs(my_dir, umask): if not create_all_dirs(my_dir, umask):
logging.error(Ta('Cannot create directory %s'), my_dir) logging.error(T('Cannot create directory %s'), my_dir)
return (False, my_dir) return (False, my_dir)
if os.access(my_dir, os.R_OK + os.W_OK): if os.access(my_dir, os.R_OK + os.W_OK):
return (True, my_dir) return (True, my_dir)
else: else:
logging.error(Ta('%s directory: %s error accessing'), name, my_dir) logging.error(T('%s directory: %s error accessing'), name, my_dir)
return (False, my_dir) return (False, my_dir)
else: else:
return (False, "") return (False, "")
@ -433,14 +433,14 @@ def get_user_shellfolders():
try: try:
hive = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER) hive = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER)
except WindowsError: except WindowsError:
logging.error(Ta('Cannot connect to registry hive HKEY_CURRENT_USER.')) logging.error(T('Cannot connect to registry hive HKEY_CURRENT_USER.'))
return values return values
# Then open the registry key where Windows stores the Shell Folder locations # Then open the registry key where Windows stores the Shell Folder locations
try: try:
key = _winreg.OpenKey(hive, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") key = _winreg.OpenKey(hive, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
except WindowsError: except WindowsError:
logging.error(Ta('Cannot open registry key "%s".'), r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") logging.error(T('Cannot open registry key "%s".'), r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
_winreg.CloseKey(hive) _winreg.CloseKey(hive)
return values return values
@ -454,7 +454,7 @@ def get_user_shellfolders():
return values return values
except WindowsError: except WindowsError:
# On error, return empty dict. # On error, return empty dict.
logging.error(Ta('Failed to read registry keys for special folders')) logging.error(T('Failed to read registry keys for special folders'))
_winreg.CloseKey(key) _winreg.CloseKey(key)
_winreg.CloseKey(hive) _winreg.CloseKey(hive)
return {} return {}
@ -511,7 +511,7 @@ def get_serv_parms(service):
except WindowsError: except WindowsError:
pass pass
for n in xrange(len(value)): for n in xrange(len(value)):
value[n] = latin1(value[n]) value[n] = value[n]
return value return value
@ -811,7 +811,7 @@ def create_dirs(dirpath):
if not os.path.exists(dirpath): if not os.path.exists(dirpath):
logging.info('Creating directories: %s', dirpath) logging.info('Creating directories: %s', dirpath)
if not create_all_dirs(dirpath, True): if not create_all_dirs(dirpath, True):
logging.error(Ta('Failed making (%s)'), dirpath) logging.error(T('Failed making (%s)'), dirpath)
return None return None
return dirpath return dirpath
@ -847,7 +847,7 @@ def move_to_path(path, new_path):
os.remove(path) os.remove(path)
except: except:
if not (cfg.marker_file() and cfg.marker_file() in path): if not (cfg.marker_file() and cfg.marker_file() in path):
logging.error(Ta('Failed moving %s to %s'), path, new_path) logging.error(T('Failed moving %s to %s'), path, new_path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
ok = False ok = False
return ok, new_path return ok, new_path
@ -1189,7 +1189,7 @@ def create_https_certificates(ssl_cert, ssl_key):
from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \ from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \
TYPE_RSA, serial TYPE_RSA, serial
except: except:
logging.warning(Ta('pyopenssl module missing, please install for https access')) logging.warning(T('pyopenssl module missing, please install for https access'))
return False return False
# Create the CA Certificate # Create the CA Certificate
@ -1207,7 +1207,7 @@ def create_https_certificates(ssl_cert, ssl_key):
open(ssl_key, 'w').write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey)) open(ssl_key, 'w').write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
open(ssl_cert, 'w').write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert)) open(ssl_cert, 'w').write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
except: except:
logging.error(Ta('Error creating SSL key and certificate')) logging.error(T('Error creating SSL key and certificate'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return False return False
@ -1391,7 +1391,7 @@ def set_chmod(path, permissions, report):
except: except:
lpath = path.lower() lpath = path.lower()
if report and '.appledouble' not in lpath and '.ds_store' not in lpath: if report and '.appledouble' not in lpath and '.ds_store' not in lpath:
logging.error(Ta('Cannot change permissions of %s'), path) logging.error(T('Cannot change permissions of %s'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)

12
sabnzbd/newsunpack.py

@ -30,7 +30,7 @@ import shutil
import sabnzbd import sabnzbd
from sabnzbd.encoding import TRANS, UNTRANS, unicode2local, name_fixer, \ from sabnzbd.encoding import TRANS, UNTRANS, unicode2local, name_fixer, \
reliable_unpack_names, unicoder, latin1, platform_encode, deunicode reliable_unpack_names, unicoder, platform_encode, deunicode
from sabnzbd.utils.rarfile import RarFile, is_rarfile from sabnzbd.utils.rarfile import RarFile, is_rarfile
from sabnzbd.misc import format_time_string, find_on_path, make_script_path, int_conv, \ from sabnzbd.misc import format_time_string, find_on_path, make_script_path, int_conv, \
flag_file, real_path, globber flag_file, real_path, globber
@ -188,7 +188,7 @@ def unpack_magic(nzo, workdir, workdir_complete, dele, one_folder, joinables, zi
""" Do a recursive unpack from all archives in 'workdir' to 'workdir_complete' """ Do a recursive unpack from all archives in 'workdir' to 'workdir_complete'
""" """
if depth > 5: if depth > 5:
logging.warning('Unpack nesting too deep [%s]', latin1(nzo.final_name)) logging.warning('Unpack nesting too deep [%s]', nzo.final_name)
return False, [] return False, []
depth += 1 depth += 1
@ -690,7 +690,7 @@ def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path
else: else:
filename = '???' filename = '???'
nzo.fail_msg = T('Unusable RAR file') nzo.fail_msg = T('Unusable RAR file')
msg = ('[%s][%s] '+ Ta('Unusable RAR file')) % (setname, latin1(filename)) msg = ('[%s][%s] '+ T('Unusable RAR file')) % (setname, filename)
nzo.set_unpack_info('Unpack', unicoder(msg), set=setname) nzo.set_unpack_info('Unpack', unicoder(msg), set=setname)
fail = 3 fail = 3
@ -723,7 +723,7 @@ def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path
logging.info('Skipping check of file %s', path) logging.info('Skipping check of file %s', path)
continue continue
fullpath = os.path.join(extraction_path, path) fullpath = os.path.join(extraction_path, path)
logging.debug("Checking existence of %s", latin1(fullpath)) logging.debug("Checking existence of %s", fullpath)
if path.endswith('/'): if path.endswith('/'):
# Folder # Folder
continue continue
@ -1697,10 +1697,10 @@ def sfv_check(sfv_path):
if crc_check(path, checksum): if crc_check(path, checksum):
logging.debug('File %s passed SFV check', path) logging.debug('File %s passed SFV check', path)
else: else:
logging.info('File %s did not pass SFV check', latin1(path)) logging.info('File %s did not pass SFV check', path)
failed.append(unicoder(filename)) failed.append(unicoder(filename))
else: else:
logging.info('File %s missing in SFV check', latin1(path)) logging.info('File %s missing in SFV check', path)
failed.append(unicoder(filename)) failed.append(unicoder(filename))
fp.close() fp.close()
return failed return failed

2
sabnzbd/newswrapper.py

@ -178,7 +178,7 @@ class NNTP(object):
self.sock = SSLConnection(ctx, socket.socket(af, socktype, proto)) self.sock = SSLConnection(ctx, socket.socket(af, socktype, proto))
elif sslenabled and not _ssl: elif sslenabled and not _ssl:
logging.error(Ta('Error importing OpenSSL module. Connecting with NON-SSL')) logging.error(T('Error importing OpenSSL module. Connecting with NON-SSL'))
self.sock = socket.socket(af, socktype, proto) self.sock = socket.socket(af, socktype, proto)
else: else:
self.sock = socket.socket(af, socktype, proto) self.sock = socket.socket(af, socktype, proto)

16
sabnzbd/nzbqueue.py

@ -42,7 +42,7 @@ from sabnzbd.articlecache import ArticleCache
import sabnzbd.downloader import sabnzbd.downloader
from sabnzbd.assembler import Assembler, file_has_articles from sabnzbd.assembler import Assembler, file_has_articles
import sabnzbd.growler as growler import sabnzbd.growler as growler
from sabnzbd.encoding import latin1, platform_encode from sabnzbd.encoding import platform_encode
from sabnzbd.bpsmeter import BPSMeter from sabnzbd.bpsmeter import BPSMeter
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -86,13 +86,13 @@ class NzbQueue(TryList):
queue_vers, nzo_ids, dummy = data queue_vers, nzo_ids, dummy = data
if not queue_vers == QUEUE_VERSION: if not queue_vers == QUEUE_VERSION:
nzo_ids = [] nzo_ids = []
logging.error(Ta('Incompatible queuefile found, cannot proceed')) logging.error(T('Incompatible queuefile found, cannot proceed'))
if not repair: if not repair:
panic_queue(os.path.join(cfg.admin_dir.get_path(), QUEUE_FILE_NAME)) panic_queue(os.path.join(cfg.admin_dir.get_path(), QUEUE_FILE_NAME))
exit_sab(2) exit_sab(2)
except ValueError: except ValueError:
nzo_ids = [] nzo_ids = []
logging.error(Ta('Error loading %s, corrupt file detected'), logging.error(T('Error loading %s, corrupt file detected'),
os.path.join(cfg.admin_dir.get_path(), QUEUE_FILE_NAME)) os.path.join(cfg.admin_dir.get_path(), QUEUE_FILE_NAME))
if not repair: if not repair:
return return
@ -183,16 +183,16 @@ class NzbQueue(TryList):
if not all_verified(path): if not all_verified(path):
filename = globber_full(path, '*.gz') filename = globber_full(path, '*.gz')
if len(filename) > 0: if len(filename) > 0:
logging.debug('Repair job %s by reparsing stored NZB', latin1(name)) logging.debug('Repair job %s by reparsing stored NZB', name)
nzo_id = sabnzbd.add_nzbfile(filename[0], pp=None, script=None, cat=None, priority=None, nzbname=name, reuse=True)[1] nzo_id = sabnzbd.add_nzbfile(filename[0], pp=None, script=None, cat=None, priority=None, nzbname=name, reuse=True)[1]
else: else:
logging.debug('Repair job %s without stored NZB', latin1(name)) logging.debug('Repair job %s without stored NZB', name)
nzo = NzbObject(name, pp=None, script=None, nzb='', cat=None, priority=None, nzbname=name, reuse=True) nzo = NzbObject(name, pp=None, script=None, nzb='', cat=None, priority=None, nzbname=name, reuse=True)
self.add(nzo) self.add(nzo)
nzo_id = nzo.nzo_id nzo_id = nzo.nzo_id
else: else:
remove_all(path, '*.gz') remove_all(path, '*.gz')
logging.debug('Repair job %s with new NZB (%s)', latin1(name), latin1(filename)) logging.debug('Repair job %s with new NZB (%s)', name, filename)
nzo_id = sabnzbd.add_nzbfile(new_nzb, pp=None, script=None, cat=None, priority=None, nzbname=name, reuse=True)[1] nzo_id = sabnzbd.add_nzbfile(new_nzb, pp=None, script=None, cat=None, priority=None, nzbname=name, reuse=True)[1]
return nzo_id return nzo_id
@ -301,7 +301,7 @@ class NzbQueue(TryList):
self.reset_try_list() self.reset_try_list()
except: except:
logging.error(Ta('Error while adding %s, removing'), nzo_id) logging.error(T('Error while adding %s, removing'), nzo_id)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
self.remove(nzo_id, False) self.remove(nzo_id, False)
else: else:
@ -796,7 +796,7 @@ class NzbQueue(TryList):
else: else:
if file_has_articles(nzf): if file_has_articles(nzf):
logging.warning(Ta('%s -> Unknown encoding'), filename) logging.warning(T('%s -> Unknown encoding'), filename)
if post_done: if post_done:
self.end_job(nzo) self.end_job(nzo)

34
sabnzbd/nzbstuff.py

@ -51,7 +51,7 @@ from sabnzbd.misc import to_units, cat_to_opts, cat_convert, sanitize_foldername
fix_unix_encoding fix_unix_encoding
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.trylist import TryList from sabnzbd.trylist import TryList
from sabnzbd.encoding import unicoder, platform_encode, latin1, name_fixer from sabnzbd.encoding import unicoder, platform_encode, name_fixer
from sabnzbd.database import get_history_handle from sabnzbd.database import get_history_handle
__all__ = ['Article', 'NzbFile', 'NzbObject'] __all__ = ['Article', 'NzbFile', 'NzbObject']
@ -413,7 +413,7 @@ class NzbParser(xml.sax.handler.ContentHandler):
# Create an NZF # Create an NZF
self.in_file = False self.in_file = False
if not self.article_db: if not self.article_db:
logging.warning(Ta('File %s is empty, skipping'), self.filename) logging.warning(T('File %s is empty, skipping'), self.filename)
return return
try: try:
tm = datetime.datetime.fromtimestamp(self.file_date) tm = datetime.datetime.fromtimestamp(self.file_date)
@ -458,7 +458,7 @@ class NzbParser(xml.sax.handler.ContentHandler):
self.nzo.avg_date = datetime.datetime.fromtimestamp(self.avg_age / files) self.nzo.avg_date = datetime.datetime.fromtimestamp(self.avg_age / files)
self.nzo.md5sum = self.md5.hexdigest() self.nzo.md5sum = self.md5.hexdigest()
if self.skipped_files: if self.skipped_files:
logging.warning(Ta('Failed to import %s files from %s'), logging.warning(T('Failed to import %s files from %s'),
self.skipped_files, self.nzo.filename) self.skipped_files, self.nzo.filename)
@ -651,13 +651,13 @@ class NzbObject(TryList):
except xml.sax.SAXParseException, err: except xml.sax.SAXParseException, err:
self.incomplete = True self.incomplete = True
if '</nzb>' not in nzb: if '</nzb>' not in nzb:
logging.warning(Ta('Incomplete NZB file %s'), filename) logging.warning(T('Incomplete NZB file %s'), filename)
else: else:
logging.warning(Ta('Invalid NZB file %s, skipping (reason=%s, line=%s)'), logging.warning(T('Invalid NZB file %s, skipping (reason=%s, line=%s)'),
filename, err.getMessage(), err.getLineNumber()) filename, err.getMessage(), err.getLineNumber())
except Exception, err: except Exception, err:
self.incomplete = True self.incomplete = True
logging.warning(Ta('Invalid NZB file %s, skipping (reason=%s, line=%s)'), filename, err, 0) logging.warning(T('Invalid NZB file %s, skipping (reason=%s, line=%s)'), filename, err, 0)
if self.incomplete: if self.incomplete:
if cfg.allow_incomplete_nzb(): if cfg.allow_incomplete_nzb():
@ -682,9 +682,9 @@ class NzbObject(TryList):
else: else:
mylog = logging.info mylog = logging.info
if self.url: if self.url:
mylog(Ta('Empty NZB file %s') + ' [%s]', filename, self.url) mylog(T('Empty NZB file %s') + ' [%s]', filename, self.url)
else: else:
mylog(Ta('Empty NZB file %s'), filename) mylog(T('Empty NZB file %s'), filename)
raise ValueError raise ValueError
if cat is None: if cat is None:
@ -753,12 +753,12 @@ class NzbObject(TryList):
self.priority = LOW_PRIORITY self.priority = LOW_PRIORITY
if duplicate and cfg.no_dupes() == 1: if duplicate and cfg.no_dupes() == 1:
if cfg.warn_dupl_jobs(): logging.warning(Ta('Ignoring duplicate NZB "%s"'), filename) if cfg.warn_dupl_jobs(): logging.warning(T('Ignoring duplicate NZB "%s"'), filename)
self.purge_data(keep_basic=False) self.purge_data(keep_basic=False)
raise TypeError raise TypeError
if duplicate or self.priority == DUP_PRIORITY: if duplicate or self.priority == DUP_PRIORITY:
if cfg.warn_dupl_jobs(): logging.warning(Ta('Pausing duplicate NZB "%s"'), filename) if cfg.warn_dupl_jobs(): logging.warning(T('Pausing duplicate NZB "%s"'), filename)
self.duplicate = True self.duplicate = True
self.pause() self.pause()
self.priority = NORMAL_PRIORITY self.priority = NORMAL_PRIORITY
@ -1011,19 +1011,19 @@ class NzbObject(TryList):
def final_name_pw(self): def final_name_pw(self):
prefix = '' prefix = ''
if self.duplicate: if self.duplicate:
prefix = Ta('DUPLICATE') + ' / ' #: Queue indicator for duplicate job prefix = T('DUPLICATE') + ' / ' #: Queue indicator for duplicate job
if self.encrypted and self.status == 'Paused': if self.encrypted and self.status == 'Paused':
prefix += Ta('ENCRYPTED') + ' / ' #: Queue indicator for encrypted job prefix += T('ENCRYPTED') + ' / ' #: Queue indicator for encrypted job
if self.oversized and self.status == 'Paused': if self.oversized and self.status == 'Paused':
prefix += Ta('TOO LARGE') + ' / ' #: Queue indicator for oversized job prefix += T('TOO LARGE') + ' / ' #: Queue indicator for oversized job
if self.incomplete and self.status == 'Paused': if self.incomplete and self.status == 'Paused':
prefix += Ta('INCOMPLETE') + ' / ' #: Queue indicator for incomplete NZB prefix += T('INCOMPLETE') + ' / ' #: Queue indicator for incomplete NZB
if self.unwanted_ext and self.status == 'Paused': if self.unwanted_ext and self.status == 'Paused':
prefix += Ta('UNWANTED') + ' / ' #: Queue indicator for unwanted extensions prefix += T('UNWANTED') + ' / ' #: Queue indicator for unwanted extensions
if isinstance(self.wait, float): if isinstance(self.wait, float):
dif = int(self.wait - time.time() + 0.5) dif = int(self.wait - time.time() + 0.5)
if dif > 0: if dif > 0:
prefix += Ta('WAIT %s sec') % dif + ' / ' #: Queue indicator for waiting URL fetch prefix += T('WAIT %s sec') % dif + ' / ' #: Queue indicator for waiting URL fetch
if self.password: if self.password:
return '%s%s / %s' % (prefix, self.final_name, self.password) return '%s%s / %s' % (prefix, self.final_name, self.password)
else: else:
@ -1168,7 +1168,7 @@ class NzbObject(TryList):
nzf.finish_import() nzf.finish_import()
# Still not finished? Something went wrong... # Still not finished? Something went wrong...
if not nzf.import_finished: if not nzf.import_finished:
logging.error(Ta('Error importing %s'), nzf) logging.error(T('Error importing %s'), nzf)
nzf_remove_list.append(nzf) nzf_remove_list.append(nzf)
continue continue
else: else:

20
sabnzbd/panic.py

@ -41,7 +41,7 @@ def MSG_BAD_NEWS():
return r''' return r'''
<html> <html>
<head> <head>
<title>''' + Ta('Problem with') + ''' %s %s</title> <title>''' + T('Problem with') + ''' %s %s</title>
</head> </head>
<body> <body>
<h1><font color="#0000FF"> %s %s</font></h1> <h1><font color="#0000FF"> %s %s</font></h1>
@ -129,7 +129,7 @@ def MSG_BAD_TEMPL():
''') ''')
def MSG_OTHER(): def MSG_OTHER():
return Ta('SABnzbd detected a fatal error:') + '<br>%s<br><br>%s<br>' return T('SABnzbd detected a fatal error:') + '<br>%s<br><br>%s<br>'
def MSG_OLD_QUEUE(): def MSG_OLD_QUEUE():
return Ta(r''' return Ta(r'''
@ -137,7 +137,7 @@ def MSG_OLD_QUEUE():
You can convert the queue by clicking "Repair" in Status-&gt;"Queue Repair".<br><br> You can convert the queue by clicking "Repair" in Status-&gt;"Queue Repair".<br><br>
You may choose to stop SABnzbd and finish the queue with the older program.<br><br> You may choose to stop SABnzbd and finish the queue with the older program.<br><br>
Click OK to proceed to SABnzbd''') + \ Click OK to proceed to SABnzbd''') + \
('''<br><br><FORM><input type="button" onclick="this.form.action='/.'; this.form.submit(); return false;" value="%s"/></FORM>''' % Ta('OK')) ('''<br><br><FORM><input type="button" onclick="this.form.action='/.'; this.form.submit(); return false;" value="%s"/></FORM>''' % T('OK'))
def MSG_SQLITE(): def MSG_SQLITE():
return Ta(r''' return Ta(r'''
@ -151,10 +151,10 @@ def panic_message(panic, a=None, b=None):
"""Create the panic message from templates """Create the panic message from templates
""" """
if sabnzbd.WIN32: if sabnzbd.WIN32:
os_str = Ta('Press Startkey+R and type the line (example):') os_str = T('Press Startkey+R and type the line (example):')
prog_path = '"%s"' % sabnzbd.MY_FULLNAME prog_path = '"%s"' % sabnzbd.MY_FULLNAME
else: else:
os_str = Ta('Open a Terminal window and type the line (example):') os_str = T('Open a Terminal window and type the line (example):')
prog_path = sabnzbd.MY_FULLNAME prog_path = sabnzbd.MY_FULLNAME
if panic == PANIC_PORT: if panic == PANIC_PORT:
@ -174,7 +174,7 @@ def panic_message(panic, a=None, b=None):
msg = MSG_BAD_QUEUE() % (a, os_str, prog_path) msg = MSG_BAD_QUEUE() % (a, os_str, prog_path)
elif panic == PANIC_FWALL: elif panic == PANIC_FWALL:
if a: if a:
msg = MSG_BAD_FWALL() % Ta('It is likely that you are using ZoneAlarm on Vista.<br>') msg = MSG_BAD_FWALL() % T('It is likely that you are using ZoneAlarm on Vista.<br>')
else: else:
msg = MSG_BAD_FWALL() % "<br>" msg = MSG_BAD_FWALL() % "<br>"
elif panic == PANIC_SQLITE: elif panic == PANIC_SQLITE:
@ -185,7 +185,7 @@ def panic_message(panic, a=None, b=None):
msg = MSG_OTHER() % (a, b) msg = MSG_OTHER() % (a, b)
msg = MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg = MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__,
msg, Ta('Program did not start!')) msg, T('Program did not start!'))
if sabnzbd.WIN_SERVICE: if sabnzbd.WIN_SERVICE:
sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg) sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg)
@ -210,7 +210,7 @@ def panic_host(host, port):
def panic_xport(host, port): def panic_xport(host, port):
launch_a_browser(panic_message(PANIC_XPORT, host, port)) launch_a_browser(panic_message(PANIC_XPORT, host, port))
logging.error(Ta('You have no permisson to use port %s'), port) logging.error(T('You have no permisson to use port %s'), port)
def panic_queue(name): def panic_queue(name):
launch_a_browser(panic_message(PANIC_QUEUE, name, 0)) launch_a_browser(panic_message(PANIC_QUEUE, name, 0))
@ -226,7 +226,7 @@ def panic_old_queue():
return MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, '') return MSG_BAD_NEWS() % (sabnzbd.MY_NAME, sabnzbd.__version__, sabnzbd.MY_NAME, sabnzbd.__version__, msg, '')
def panic(reason, remedy=""): def panic(reason, remedy=""):
print "\n%s:\n %s\n%s" % (Ta('Fatal error'), reason, remedy) print "\n%s:\n %s\n%s" % (T('Fatal error'), reason, remedy)
launch_a_browser(panic_message(PANIC_OTHER, reason, remedy)) launch_a_browser(panic_message(PANIC_OTHER, reason, remedy))
@ -250,7 +250,7 @@ def launch_a_browser(url, force=False):
url = 'file:///%s' % url url = 'file:///%s' % url
webbrowser.open(url, 2, 1) webbrowser.open(url, 2, 1)
except: except:
logging.warning(Ta('Cannot launch the browser, probably not found')) logging.warning(T('Cannot launch the browser, probably not found'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)

14
sabnzbd/postproc.py

@ -124,7 +124,7 @@ class PostProcessor(Thread):
self.history_queue.remove(nzo) self.history_queue.remove(nzo)
except: except:
nzo_id = getattr(nzo, 'nzo_id', 'unknown id') nzo_id = getattr(nzo, 'nzo_id', 'unknown id')
logging.error(Ta('Failed to remove nzo from postproc queue (id)') + ' ' + nzo_id) logging.error(T('Failed to remove nzo from postproc queue (id)') + ' ' + nzo_id)
logging.info('Traceback: ', exc_info = True) logging.info('Traceback: ', exc_info = True)
self.save() self.save()
@ -408,7 +408,7 @@ def process_job(nzo):
try: try:
newfiles = rename_and_collapse_folder(tmp_workdir_complete, workdir_complete, newfiles) newfiles = rename_and_collapse_folder(tmp_workdir_complete, workdir_complete, newfiles)
except: except:
logging.error(Ta('Error renaming "%s" to "%s"'), tmp_workdir_complete, workdir_complete) logging.error(T('Error renaming "%s" to "%s"'), tmp_workdir_complete, workdir_complete)
logging.info('Traceback: ', exc_info = True) logging.info('Traceback: ', exc_info = True)
# Better disable sorting because filenames are all off now # Better disable sorting because filenames are all off now
file_sorter.sort_file = None file_sorter.sort_file = None
@ -503,7 +503,7 @@ def process_job(nzo):
nzo.status = Status.FAILED nzo.status = Status.FAILED
except: except:
logging.error(Ta('Post Processing Failed for %s (%s)'), filename, crash_msg) logging.error(T('Post Processing Failed for %s (%s)'), filename, crash_msg)
if not crash_msg: if not crash_msg:
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
crash_msg = T('see logfile') crash_msg = T('see logfile')
@ -539,7 +539,7 @@ def process_job(nzo):
logging.info('Cleaning up %s (keep_basic=%s)', filename, str(not all_ok)) logging.info('Cleaning up %s (keep_basic=%s)', filename, str(not all_ok))
sabnzbd.nzbqueue.NzbQueue.do.cleanup_nzo(nzo, keep_basic=not all_ok) sabnzbd.nzbqueue.NzbQueue.do.cleanup_nzo(nzo, keep_basic=not all_ok)
except: except:
logging.error(Ta('Cleanup of %s failed.'), nzo.final_name) logging.error(T('Cleanup of %s failed.'), nzo.final_name)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
## Remove download folder ## Remove download folder
@ -549,7 +549,7 @@ def process_job(nzo):
logging.debug('Removing workdir %s', workdir) logging.debug('Removing workdir %s', workdir)
remove_all(workdir, recursive=True) remove_all(workdir, recursive=True)
except: except:
logging.error(Ta('Error removing workdir (%s)'), workdir) logging.error(T('Error removing workdir (%s)'), workdir)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
# Use automatic retry link on par2 errors and encrypted/bad RARs # Use automatic retry link on par2 errors and encrypted/bad RARs
@ -697,7 +697,7 @@ def cleanup_list(wdir, skip_nzb):
logging.info("Removing unwanted file %s", path) logging.info("Removing unwanted file %s", path)
os.remove(path) os.remove(path)
except: except:
logging.error(Ta('Removing %s failed'), path) logging.error(T('Removing %s failed'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
if files: if files:
try: try:
@ -772,7 +772,7 @@ def remove_samples(path):
logging.info("Removing unwanted sample file %s", path) logging.info("Removing unwanted sample file %s", path)
os.remove(path) os.remove(path)
except: except:
logging.error(Ta('Removing %s failed'), path) logging.error(T('Removing %s failed'), path)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)

16
sabnzbd/powersup.py

@ -24,8 +24,6 @@ import subprocess
import logging import logging
import time import time
from sabnzbd.encoding import latin1
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Power management for Windows # Power management for Windows
@ -36,7 +34,7 @@ def win_hibernate():
subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Hibernate") subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Hibernate")
time.sleep(10) time.sleep(10)
except: except:
logging.error(Ta('Failed to hibernate system')) logging.error(T('Failed to hibernate system'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -47,7 +45,7 @@ def win_standby():
subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Standby") subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Standby")
time.sleep(10) time.sleep(10)
except: except:
logging.error(Ta('Failed to standby system')) logging.error(T('Failed to standby system'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -78,7 +76,7 @@ def osx_shutdown():
try: try:
subprocess.call(['osascript', '-e', 'tell app "System Events" to shut down']) subprocess.call(['osascript', '-e', 'tell app "System Events" to shut down'])
except: except:
logging.error(Ta('Error while shutting down system')) logging.error(T('Error while shutting down system'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
os._exit(0) os._exit(0)
@ -90,7 +88,7 @@ def osx_standby():
subprocess.call(['osascript', '-e','tell app "System Events" to sleep']) subprocess.call(['osascript', '-e','tell app "System Events" to sleep'])
time.sleep(10) time.sleep(10)
except: except:
logging.error(Ta('Failed to standby system')) logging.error(T('Failed to standby system'))
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -174,7 +172,7 @@ def linux_shutdown():
try: try:
proxy.Stop(dbus_interface=interface) proxy.Stop(dbus_interface=interface)
except dbus.exceptions.DBusException, msg: except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg)) logging.info('Received a DBus exception %s', msg)
else: else:
logging.info('DBus does not support Stop (shutdown)') logging.info('DBus does not support Stop (shutdown)')
os._exit(0) os._exit(0)
@ -198,7 +196,7 @@ def linux_hibernate():
try: try:
proxy.Hibernate(dbus_interface=interface) proxy.Hibernate(dbus_interface=interface)
except dbus.exceptions.DBusException, msg: except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg)) logging.info('Received a DBus exception %s', msg)
else: else:
logging.info('DBus does not support Hibernate') logging.info('DBus does not support Hibernate')
time.sleep(10) time.sleep(10)
@ -222,7 +220,7 @@ def linux_standby():
try: try:
proxy.Suspend(dbus_interface=interface) proxy.Suspend(dbus_interface=interface)
except dbus.exceptions.DBusException, msg: except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg)) logging.info('Received a DBus exception %s', msg)
else: else:
logging.info('DBus does not support Suspend (standby)') logging.info('DBus does not support Suspend (standby)')
time.sleep(10) time.sleep(10)

18
sabnzbd/rss.py

@ -34,7 +34,7 @@ import sabnzbd.cfg as cfg
from sabnzbd.misc import cat_convert, sanitize_foldername, wildcard_to_re, cat_to_opts, \ from sabnzbd.misc import cat_convert, sanitize_foldername, wildcard_to_re, cat_to_opts, \
match_str, from_units, int_conv match_str, from_units, int_conv
import sabnzbd.emailer as emailer import sabnzbd.emailer as emailer
from sabnzbd.encoding import latin1, unicoder, xml_name from sabnzbd.encoding import unicoder, xml_name
import sabnzbd.utils.feedparser as feedparser import sabnzbd.utils.feedparser as feedparser
@ -277,7 +277,7 @@ class RSSQueue(object):
try: try:
feeds = config.get_rss()[feed] feeds = config.get_rss()[feed]
except KeyError: except KeyError:
logging.error(Ta('Incorrect RSS feed description "%s"'), feed) logging.error(T('Incorrect RSS feed description "%s"'), feed)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return T('Incorrect RSS feed description "%s"') % feed return T('Incorrect RSS feed description "%s"') % feed
@ -338,27 +338,27 @@ class RSSQueue(object):
d = feedparser.parse(uri.replace('feed://', 'http://')) d = feedparser.parse(uri.replace('feed://', 'http://'))
logging.debug("Done parsing %s", uri) logging.debug("Done parsing %s", uri)
if not d: if not d:
msg = Ta('Failed to retrieve RSS from %s: %s') % (uri, '?') msg = T('Failed to retrieve RSS from %s: %s') % (uri, '?')
logging.info(msg) logging.info(msg)
return unicoder(msg) return unicoder(msg)
status = d.get('status', 999) status = d.get('status', 999)
if status in (401, 402, 403): if status in (401, 402, 403):
msg = Ta('Do not have valid authentication for feed %s') % feed msg = T('Do not have valid authentication for feed %s') % feed
logging.info(msg) logging.info(msg)
return unicoder(msg) return unicoder(msg)
if status >= 500 and status <=599: if status >= 500 and status <=599:
msg = Ta('Server side error (server code %s); could not get %s on %s') % (status, feed, uri) msg = T('Server side error (server code %s); could not get %s on %s') % (status, feed, uri)
logging.info(msg) logging.info(msg)
return unicoder(msg) return unicoder(msg)
entries = d.get('entries') entries = d.get('entries')
if 'bozo_exception' in d and not entries: if 'bozo_exception' in d and not entries:
msg = Ta('Failed to retrieve RSS from %s: %s') % (uri, xml_name(str(d['bozo_exception']))) msg = T('Failed to retrieve RSS from %s: %s') % (uri, xml_name(str(d['bozo_exception'])))
logging.info(msg) logging.info(msg)
return unicoder(msg) return unicoder(msg)
if not entries: if not entries:
msg = Ta('RSS Feed %s was empty') % uri msg = T('RSS Feed %s was empty') % uri
logging.info(msg) logging.info(msg)
if feed not in self.jobs: if feed not in self.jobs:
@ -385,7 +385,7 @@ class RSSQueue(object):
link = None link = None
category = u'' category = u''
size = 0L size = 0L
logging.info(Ta('Incompatible feed') + ' ' + uri) logging.info(T('Incompatible feed') + ' ' + uri)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return T('Incompatible feed') return T('Incompatible feed')
title = entry.title title = entry.title
@ -683,7 +683,7 @@ def _get_link(uri, entry):
category = '' category = ''
return link, category, size return link, category, size
else: else:
logging.warning(Ta('Empty RSS entry found (%s)'), link) logging.warning(T('Empty RSS entry found (%s)'), link)
return None, '', 0L return None, '', 0L

8
sabnzbd/scheduler.py

@ -80,7 +80,7 @@ def init():
m = int(m) m = int(m)
h = int(h) h = int(h)
except: except:
logging.warning(Ta('Bad schedule %s at %s:%s'), action_name, m, h) logging.warning(T('Bad schedule %s at %s:%s'), action_name, m, h)
continue continue
if d.isdigit(): if d.isdigit():
@ -145,7 +145,7 @@ def init():
action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio
arguments = [HIGH_PRIORITY] arguments = [HIGH_PRIORITY]
else: else:
logging.warning(Ta('Unknown action: %s'), action_name) logging.warning(T('Unknown action: %s'), action_name)
continue continue
logging.debug("scheduling %s(%s) on days %s at %02d:%02d", action_name, arguments, d, h, m) logging.debug("scheduling %s(%s) on days %s at %02d:%02d", action_name, arguments, d, h, m)
@ -345,12 +345,12 @@ def analyse(was_paused=False, priority=None):
try: try:
servers[value] = 1 servers[value] = 1
except: except:
logging.warning(Ta('Schedule for non-existing server %s'), value) logging.warning(T('Schedule for non-existing server %s'), value)
elif action == 'disable_server': elif action == 'disable_server':
try: try:
servers[value] = 0 servers[value] = 0
except: except:
logging.warning(Ta('Schedule for non-existing server %s'), value) logging.warning(T('Schedule for non-existing server %s'), value)
# Special case, a priority was passed, so evaluate only that and return state # Special case, a priority was passed, so evaluate only that and return state
if priority == LOW_PRIORITY: if priority == LOW_PRIORITY:

16
sabnzbd/tvsort.py

@ -31,7 +31,7 @@ from sabnzbd.misc import move_to_path, cleanup_empty_directories, get_unique_pat
get_unique_filename, get_ext, renamer, sanitize_foldername get_unique_filename, get_ext, renamer, sanitize_foldername
from sabnzbd.constants import series_match, date_match, year_match, sample_match from sabnzbd.constants import series_match, date_match, year_match, sample_match
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.encoding import titler, latin1 from sabnzbd.encoding import titler
RE_SAMPLE = re.compile(sample_match, re.I) RE_SAMPLE = re.compile(sample_match, re.I)
# Do not rename .vob files as they are usually DVD's # Do not rename .vob files as they are usually DVD's
@ -173,7 +173,7 @@ class Sorter(object):
try: try:
renamer(old, workdir_complete) renamer(old, workdir_complete)
except: except:
logging.error(Ta('Cannot create directory %s'), workdir_complete) logging.error(T('Cannot create directory %s'), workdir_complete)
workdir_complete = old workdir_complete = old
ok = False ok = False
return workdir_complete, ok return workdir_complete, ok
@ -324,7 +324,7 @@ class SeriesSorter(object):
return True return True
except: except:
logging.error(Ta('Error getting TV info (%s)'), self.original_dirname) logging.error(T('Error getting TV info (%s)'), self.original_dirname)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
return False return False
@ -693,7 +693,7 @@ class GenericSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath) logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath) renamer(filepath, newpath)
except: except:
logging.error(Ta('Failed to rename: %s to %s'), filepath, newpath) logging.error(T('Failed to rename: %s to %s'), filepath, newpath)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
rename_similar(current_path, ext, self.filename_set, ()) rename_similar(current_path, ext, self.filename_set, ())
@ -717,7 +717,7 @@ class GenericSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath) logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath) renamer(filepath, newpath)
except: except:
logging.error(Ta('Failed to rename: %s to %s'), filepath, newpath) logging.error(T('Failed to rename: %s to %s'), filepath, newpath)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
rename_similar(current_path, ext, self.filename_set, renamed) rename_similar(current_path, ext, self.filename_set, renamed)
else: else:
@ -905,7 +905,7 @@ class DateSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath) logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath) renamer(filepath, newpath)
except: except:
logging.error(Ta('Failed to rename: %s to %s'), current_path, newpath) logging.error(T('Failed to rename: %s to %s'), current_path, newpath)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
rename_similar(current_path, ext, self.filename_set, ()) rename_similar(current_path, ext, self.filename_set, ())
break break
@ -1026,7 +1026,7 @@ def get_descriptions(nzo, match, name):
like ' - Description' or '_-_Description' like ' - Description' or '_-_Description'
''' '''
if nzo: if nzo:
ep_name = latin1(nzo.nzo_info.get('episodename') or nzo.meta.get('episodename', (None,))[0]) ep_name = nzo.nzo_info.get('episodename') or nzo.meta.get('episodename', (None,))[0]
else: else:
ep_name = '' ep_name = ''
if not ep_name: if not ep_name:
@ -1145,7 +1145,7 @@ def rename_similar(folder, skip_ext, name, skipped_files):
logging.debug("Rename: %s to %s", path, newpath) logging.debug("Rename: %s to %s", path, newpath)
renamer(path, newpath) renamer(path, newpath)
except: except:
logging.error(Ta('Failed to rename similar file: %s to %s'), path, newpath) logging.error(T('Failed to rename similar file: %s to %s'), path, newpath)
logging.info("Traceback: ", exc_info=True) logging.info("Traceback: ", exc_info=True)
cleanup_empty_directories(folder) cleanup_empty_directories(folder)

Loading…
Cancel
Save