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.cfg
import sabnzbd.downloader
from sabnzbd.encoding import unicoder, latin1, deunicode
from sabnzbd.encoding import unicoder, deunicode
import sabnzbd.growler as growler
import sabnzbd.zconfig
@ -325,7 +325,7 @@ def daemonize():
def Bail_Out(browserhost, cherryport, err=''):
"""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 '13' in err:
panic_xport(browserhost, cherryport)
@ -363,7 +363,7 @@ def Web_Template(key, defweb, wdir):
if defweb == DEF_STDCONFIG:
return ''
# 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_main = real_path(full_dir, DEF_MAIN_TMPL)
if not os.path.exists(full_main):
@ -489,14 +489,14 @@ def print_modules():
logging.info("_yenc module... found!")
else:
if hasattr(sys, "frozen"):
logging.error(Ta('_yenc module... NOT found!'))
logging.error(T('_yenc module... NOT found!'))
else:
logging.info("_yenc module... NOT found!")
if sabnzbd.newsunpack.PAR2_COMMAND:
logging.info("par2 binary... found (%s)", sabnzbd.newsunpack.PAR2_COMMAND)
else:
logging.error(Ta('par2 binary... NOT found!'))
logging.error(T('par2 binary... NOT found!'))
if 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:
logging.info("unrar binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND)
else:
logging.warning(Ta('unrar binary... NOT found'))
logging.warning(T('unrar binary... NOT found'))
if sabnzbd.newsunpack.ZIP_COMMAND:
logging.info("unzip binary... found (%s)", sabnzbd.newsunpack.ZIP_COMMAND)
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:
logging.info("7za binary... found (%s)", sabnzbd.newsunpack.SEVEN_COMMAND)
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 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")
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:
# 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():
sabnzbd.cfg.enable_https.set(False)
# 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')
return cherryhost, cherryport, browserhost, https_port
@ -1418,7 +1418,7 @@ def main():
create_https_certificates(https_cert, 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
# Determine if this system has multiple definitions for 'localhost'
@ -1871,9 +1871,9 @@ if __name__ == '__main__':
args = []
for txt in sys.argv:
if ' ' in txt:
txt = '"%s"' % latin1(txt)
txt = '"%s"' % unicoder(txt)
else:
txt = latin1(txt)
txt = unicoder(txt)
args.append(txt)
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
return True
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:
save_state(flag=True)
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.close(f)
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)
if ext.lower() in VALID_ARCHIVES:
@ -616,7 +616,7 @@ def enable_server(server):
try:
config.get_config('servers', server).enable.set(1)
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
config.save_config()
Downloader.do.update_server(server, server)
@ -628,7 +628,7 @@ def disable_server(server):
try:
config.get_config('servers', server).enable.set(0)
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
config.save_config()
Downloader.do.update_server(server, server)
@ -769,7 +769,7 @@ def CheckFreeSpace():
"""
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:
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!
Downloader.do.pause(save=False)
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:
return tail
except:
logging.error(Ta('Failure in tempfile.mkstemp'))
logging.error(T('Failure in tempfile.mkstemp'))
logging.info("Traceback: ", exc_info = True)
# Cannot create unique id, crash the process
raise IOError
@ -825,7 +825,7 @@ def save_data(data, _id, path, do_pickle = True, silent=False):
_f.flush()
_f.close()
except:
logging.error(Ta('Saving %s failed'), path)
logging.error(T('Saving %s failed'), path)
logging.info("Traceback: ", exc_info = True)
@ -855,7 +855,7 @@ def load_data(_id, path, remove=True, do_pickle=True, silent=False):
if remove:
os.remove(path)
except:
logging.error(Ta('Loading %s failed'), path)
logging.error(T('Loading %s failed'), path)
logging.info("Traceback: ", exc_info = True)
return None
@ -896,7 +896,7 @@ def save_admin(data, _id, do_pickle=True):
_f.flush()
_f.close()
except:
logging.error(Ta('Saving %s failed'), path)
logging.error(T('Saving %s failed'), path)
logging.info("Traceback: ", exc_info = True)
@ -922,7 +922,7 @@ def load_admin(_id, remove=False, do_pickle=True):
os.remove(path)
except:
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)
return None

4
sabnzbd/api.py

@ -1620,7 +1620,7 @@ def build_header(prim, webdir='', search=None):
header['speedlimit'] = "%s" % speed_limit
header['restart_req'] = sabnzbd.RESTART_REQ
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['my_lcldata'] = sabnzbd.DIR_LCLDATA
header['my_home'] = sabnzbd.DIR_HOME
@ -1707,7 +1707,7 @@ def build_history(start=None, limit=None, verbose=False, verbose_list=None, sear
try:
re_search = re.compile(search_text, re.I)
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 re_search.search(text)

14
sabnzbd/assembler.py

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

2
sabnzbd/bpsmeter.py

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

20
sabnzbd/config.py

@ -218,7 +218,7 @@ class OptionDir(Option):
if value and (self.__create or create):
res, path = sabnzbd.misc.create_real_path(self.ident()[1], self.__root, value, self.__apply_umask)
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:
self._Option__set(value)
return error
@ -795,7 +795,7 @@ def save_config(force=False):
# Check if file is writable
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
# copy current file to backup
@ -803,7 +803,7 @@ def save_config(force=False):
shutil.copyfile(filename, bakname)
except:
# 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)
return res
@ -813,7 +813,7 @@ def save_config(force=False):
modified = False
res = True
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)
try:
os.remove(filename)
@ -942,7 +942,7 @@ def decode_password(pw, name):
try:
ch = chr( int(pw[n] + pw[n+1], 16) )
except ValueError:
logging.error(Ta('Incorrectly encoded password %s'), name)
logging.error(T('Incorrectly encoded password %s'), name)
return ''
decPW += ch
return decPW
@ -966,7 +966,7 @@ def validate_octal(value):
int(value, 8)
return None, value
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):
@ -975,7 +975,7 @@ def validate_no_unc(root, value, default):
if value and not value.startswith(r'\\'):
return validate_notempty(root, value, default)
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):
@ -983,11 +983,11 @@ def validate_safedir(root, value, default):
On Windows path should be 80 max
"""
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():
return validate_no_unc(root, value, default)
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):
@ -996,7 +996,7 @@ def validate_dir_exists(root, value, default):
if os.path.exists(p):
return None, value
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):

10
sabnzbd/database.py

@ -120,11 +120,11 @@ class HistoryDB(object):
except:
error = str(sys.exc_value)
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
return True
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)
self.close()
try:
@ -133,7 +133,7 @@ class HistoryDB(object):
pass
self.connect()
else:
logging.error(Ta('SQL Command Failed, see log'))
logging.error(T('SQL Command Failed, see log'))
logging.debug("SQL: %s" , command)
logging.info("Traceback: ", exc_info = True)
try:
@ -181,7 +181,7 @@ class HistoryDB(object):
try:
self.con.commit()
except:
logging.error(Ta('SQL Commit Failed, see log'))
logging.error(T('SQL Commit Failed, see log'))
logging.info("Traceback: ", exc_info = True)
def close(self):
@ -189,7 +189,7 @@ class HistoryDB(object):
self.c.close()
self.con.close()
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)
def remove_completed(self, search=None):

10
sabnzbd/decoder.py

@ -104,7 +104,7 @@ class Decoder(Thread):
nzf.article_count += 1
found = True
except IOError, e:
logme = Ta('Decoding %s failed') % art_id
logme = T('Decoding %s failed') % art_id
logging.warning(logme)
logging.info("Traceback: ", exc_info = True)
@ -117,7 +117,7 @@ class Decoder(Thread):
register = False
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)
data = e.data
@ -154,7 +154,7 @@ class Decoder(Thread):
logging.debug('Server has article %s', art_id)
register = True
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)
if not found or killed:
@ -164,7 +164,7 @@ class Decoder(Thread):
logme = None
except:
logme = Ta('Unknown Error while decoding %s') % art_id
logme = T('Unknown Error while decoding %s') % art_id
logging.info(logme)
logging.info("Traceback: ", exc_info = True)
@ -226,7 +226,7 @@ class Decoder(Thread):
logging.debug('%s => found at least one untested server', article)
else:
msg = Ta('%s => missing from all servers, discarding') % article
msg = T('%s => missing from all servers, discarding') % article
logging.info(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:
if not keep: os.remove(path)
except:
logging.error(Ta('Error removing %s'), path)
logging.error(T('Error removing %s'), path)
logging.info("Traceback: ", exc_info = True)
status = 1
else:
@ -166,7 +166,7 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
data = f.read()
f.close()
except:
logging.warning(Ta('Cannot read %s'), path)
logging.warning(T('Cannot read %s'), path)
logging.info("Traceback: ", exc_info = True)
return -2, nzo_ids
@ -199,7 +199,7 @@ def ProcessSingleFile(filename, path, pp=None, script=None, cat=None, catdir=Non
try:
if not keep: os.remove(path)
except:
logging.error(Ta('Error removing %s'), path)
logging.error(T('Error removing %s'), path)
logging.info("Traceback: ", exc_info = True)
return 1, nzo_ids
@ -299,7 +299,7 @@ class DirScanner(threading.Thread):
files = os.listdir(folder)
except:
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
files = []
@ -382,7 +382,7 @@ class DirScanner(threading.Thread):
list = os.listdir(dirscan_dir)
except:
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
list = []

28
sabnzbd/downloader.py

@ -258,7 +258,7 @@ class Downloader(Thread):
if mx:
self.bandwidth_limit = mx * int(value) / 100
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:
self.speed_set()
logging.info("Bandwidth limit set to %s%%", value)
@ -301,7 +301,7 @@ class Downloader(Thread):
server.bad_cons = 0
server.active = False
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)
# Remove all connections to server
@ -394,7 +394,7 @@ class Downloader(Thread):
nw.thrdnum, server.id)
nw.init_connect(self.write_fds)
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)
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
# Plan to go back to the full number after a penalty timeout
if server.active:
server.errormsg = Ta('Too many connections to server %s') % display_msg
logging.error(Ta('Too many connections to server %s'), server.id)
server.errormsg = T('Too many connections to server %s') % display_msg
logging.error(T('Too many connections to server %s'), server.id)
self.__reset_nw(nw, None, warn=False, destroy=True, quit=True)
self.plan_server(server.id, _PENALTY_TOOMANY)
server.threads -= 1
elif ecode in ('502', '481') and clues_too_many_ip(msg):
# Account sharing?
if server.active:
server.errormsg = Ta('Probable account sharing') + display_msg
server.errormsg = T('Probable account sharing') + display_msg
name = ' (%s)' % server.id
logging.error(Ta('Probable account sharing') + name)
logging.error(T('Probable account sharing') + name)
penalty = _PENALTY_SHARE
elif ecode in ('481', '482', '381') or (ecode == '502' and clues_login(msg)):
# Cannot login, block this server
if server.active:
server.errormsg = Ta('Failed login for server %s') % display_msg
logging.error(Ta('Failed login for server %s'), server.id)
server.errormsg = T('Failed login for server %s') % display_msg
logging.error(T('Failed login for server %s'), server.id)
penalty = _PENALTY_PERM
block = True
elif ecode == '502':
# Cannot connect (other reasons), block this server
if server.active:
server.errormsg = Ta('Cannot connect to server %s [%s]') % ('', display_msg)
logging.warning(Ta('Cannot connect to server %s [%s]'), server.id, msg)
server.errormsg = T('Cannot connect to server %s [%s]') % ('', display_msg)
logging.warning(T('Cannot connect to server %s [%s]'), server.id, msg)
if clues_pay(msg):
penalty = _PENALTY_PERM
else:
@ -564,8 +564,8 @@ class Downloader(Thread):
else:
# Unknown error, just keep trying
if server.active:
server.errormsg = Ta('Cannot connect to server %s [%s]') % ('', display_msg)
logging.error(Ta('Cannot connect to server %s [%s]'), server.id, msg)
server.errormsg = T('Cannot connect to server %s [%s]') % ('', display_msg)
logging.error(T('Cannot connect to server %s [%s]'), server.id, msg)
penalty = _PENALTY_UNKNOWN
if block or (penalty and server.optional):
if server.active:
@ -579,7 +579,7 @@ class Downloader(Thread):
self.__reset_nw(nw, None, warn=False, quit=True)
continue
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])
# No reset-warning needed, above logging is sufficient
self.__reset_nw(nw, None, warn=False)

6
sabnzbd/emailer.py

@ -30,11 +30,11 @@ import glob
from sabnzbd.constants import *
import sabnzbd
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
def errormsg(msg):
logging.error(latin1(msg))
logging.error(msg)
return msg
@ -178,7 +178,7 @@ def send_with_template(prefix, parm, test=None):
try:
lst = glob.glob(os.path.join(path, '%s-*.tmpl' % prefix))
except:
logging.error(Ta('Cannot find email templates in %s'), path)
logging.error(T('Cannot find email templates in %s'), path)
else:
path = os.path.join(sabnzbd.DIR_PROG, DEF_EMAIL_TMPL)
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')
def latin1(txt):
""" When Unicode or UTF-8, convert to Latin-1 """
return unicoder(txt)
def encode_for_xml(ustr, encoding='ascii'):
"""
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.cfg
from sabnzbd.encoding import unicoder, latin1
from sabnzbd.encoding import unicoder
from sabnzbd.constants import NOTIFY_KEYS
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.bpsmeter import BPSMeter
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.cfg as cfg
import sabnzbd.newsunpack
@ -172,10 +172,10 @@ def check_session(kwargs):
key = kwargs.get('apikey')
msg = None
if not key:
logging.warning(Ta('Missing Session key'))
logging.warning(T('Missing Session key'))
msg = T('Error: Session Key Required')
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')
return msg
@ -213,14 +213,14 @@ def check_apikey(kwargs, nokey=False):
key = kwargs.get('apikey')
if not key:
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)
elif req_access == 1 and key == cfg.nzb_key():
return None
elif key == cfg.api_key():
return None
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)
# No active APIKEY, check web credentials instead
@ -229,7 +229,7 @@ def check_apikey(kwargs, nokey=False):
pass
else:
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 None
@ -1470,7 +1470,7 @@ class ConfigGeneral(object):
cfg.bandwidth_perc.set(bandwidth_perc)
bandwidth_perc = cfg.bandwidth_perc()
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()
@ -1740,7 +1740,7 @@ class ConfigRss(object):
# Find a unique new Feed name
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:
unum += 1
conf['feed'] = txt + str(unum)
@ -2312,7 +2312,7 @@ class Status(object):
wlist = []
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))
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
import sabnzbd.config as config
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
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):
logging.info('%s directory: %s does not exist, try to create it', name, my_dir)
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)
if os.access(my_dir, os.R_OK + os.W_OK):
return (True, my_dir)
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)
else:
return (False, "")
@ -433,14 +433,14 @@ def get_user_shellfolders():
try:
hive = _winreg.ConnectRegistry(None, _winreg.HKEY_CURRENT_USER)
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
# Then open the registry key where Windows stores the Shell Folder locations
try:
key = _winreg.OpenKey(hive, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
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)
return values
@ -454,7 +454,7 @@ def get_user_shellfolders():
return values
except WindowsError:
# 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(hive)
return {}
@ -511,7 +511,7 @@ def get_serv_parms(service):
except WindowsError:
pass
for n in xrange(len(value)):
value[n] = latin1(value[n])
value[n] = value[n]
return value
@ -811,7 +811,7 @@ def create_dirs(dirpath):
if not os.path.exists(dirpath):
logging.info('Creating directories: %s', dirpath)
if not create_all_dirs(dirpath, True):
logging.error(Ta('Failed making (%s)'), dirpath)
logging.error(T('Failed making (%s)'), dirpath)
return None
return dirpath
@ -847,7 +847,7 @@ def move_to_path(path, new_path):
os.remove(path)
except:
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)
ok = False
return ok, new_path
@ -1189,7 +1189,7 @@ def create_https_certificates(ssl_cert, ssl_key):
from sabnzbd.utils.certgen import createKeyPair, createCertRequest, createCertificate, \
TYPE_RSA, serial
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
# 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_cert, 'w').write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert))
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)
return False
@ -1391,7 +1391,7 @@ def set_chmod(path, permissions, report):
except:
lpath = path.lower()
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)

12
sabnzbd/newsunpack.py

@ -30,7 +30,7 @@ import shutil
import sabnzbd
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.misc import format_time_string, find_on_path, make_script_path, int_conv, \
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'
"""
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, []
depth += 1
@ -690,7 +690,7 @@ def rar_extract_core(rarfile, numrars, one_folder, nzo, setname, extraction_path
else:
filename = '???'
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)
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)
continue
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('/'):
# Folder
continue
@ -1697,10 +1697,10 @@ def sfv_check(sfv_path):
if crc_check(path, checksum):
logging.debug('File %s passed SFV check', path)
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))
else:
logging.info('File %s missing in SFV check', latin1(path))
logging.info('File %s missing in SFV check', path)
failed.append(unicoder(filename))
fp.close()
return failed

2
sabnzbd/newswrapper.py

@ -178,7 +178,7 @@ class NNTP(object):
self.sock = SSLConnection(ctx, socket.socket(af, socktype, proto))
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)
else:
self.sock = socket.socket(af, socktype, proto)

16
sabnzbd/nzbqueue.py

@ -42,7 +42,7 @@ from sabnzbd.articlecache import ArticleCache
import sabnzbd.downloader
from sabnzbd.assembler import Assembler, file_has_articles
import sabnzbd.growler as growler
from sabnzbd.encoding import latin1, platform_encode
from sabnzbd.encoding import platform_encode
from sabnzbd.bpsmeter import BPSMeter
#-------------------------------------------------------------------------------
@ -86,13 +86,13 @@ class NzbQueue(TryList):
queue_vers, nzo_ids, dummy = data
if not queue_vers == QUEUE_VERSION:
nzo_ids = []
logging.error(Ta('Incompatible queuefile found, cannot proceed'))
logging.error(T('Incompatible queuefile found, cannot proceed'))
if not repair:
panic_queue(os.path.join(cfg.admin_dir.get_path(), QUEUE_FILE_NAME))
exit_sab(2)
except ValueError:
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))
if not repair:
return
@ -183,16 +183,16 @@ class NzbQueue(TryList):
if not all_verified(path):
filename = globber_full(path, '*.gz')
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]
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)
self.add(nzo)
nzo_id = nzo.nzo_id
else:
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]
return nzo_id
@ -301,7 +301,7 @@ class NzbQueue(TryList):
self.reset_try_list()
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)
self.remove(nzo_id, False)
else:
@ -796,7 +796,7 @@ class NzbQueue(TryList):
else:
if file_has_articles(nzf):
logging.warning(Ta('%s -> Unknown encoding'), filename)
logging.warning(T('%s -> Unknown encoding'), filename)
if post_done:
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
import sabnzbd.cfg as cfg
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
__all__ = ['Article', 'NzbFile', 'NzbObject']
@ -413,7 +413,7 @@ class NzbParser(xml.sax.handler.ContentHandler):
# Create an NZF
self.in_file = False
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
try:
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.md5sum = self.md5.hexdigest()
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)
@ -651,13 +651,13 @@ class NzbObject(TryList):
except xml.sax.SAXParseException, err:
self.incomplete = True
if '</nzb>' not in nzb:
logging.warning(Ta('Incomplete NZB file %s'), filename)
logging.warning(T('Incomplete NZB file %s'), filename)
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())
except Exception, err:
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 cfg.allow_incomplete_nzb():
@ -682,9 +682,9 @@ class NzbObject(TryList):
else:
mylog = logging.info
if self.url:
mylog(Ta('Empty NZB file %s') + ' [%s]', filename, self.url)
mylog(T('Empty NZB file %s') + ' [%s]', filename, self.url)
else:
mylog(Ta('Empty NZB file %s'), filename)
mylog(T('Empty NZB file %s'), filename)
raise ValueError
if cat is None:
@ -753,12 +753,12 @@ class NzbObject(TryList):
self.priority = LOW_PRIORITY
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)
raise TypeError
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.pause()
self.priority = NORMAL_PRIORITY
@ -1011,19 +1011,19 @@ class NzbObject(TryList):
def final_name_pw(self):
prefix = ''
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':
prefix += Ta('ENCRYPTED') + ' / ' #: Queue indicator for encrypted job
prefix += T('ENCRYPTED') + ' / ' #: Queue indicator for encrypted job
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':
prefix += Ta('INCOMPLETE') + ' / ' #: Queue indicator for incomplete NZB
prefix += T('INCOMPLETE') + ' / ' #: Queue indicator for incomplete NZB
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):
dif = int(self.wait - time.time() + 0.5)
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:
return '%s%s / %s' % (prefix, self.final_name, self.password)
else:
@ -1168,7 +1168,7 @@ class NzbObject(TryList):
nzf.finish_import()
# Still not finished? Something went wrong...
if not nzf.import_finished:
logging.error(Ta('Error importing %s'), nzf)
logging.error(T('Error importing %s'), nzf)
nzf_remove_list.append(nzf)
continue
else:

20
sabnzbd/panic.py

@ -41,7 +41,7 @@ def MSG_BAD_NEWS():
return r'''
<html>
<head>
<title>''' + Ta('Problem with') + ''' %s %s</title>
<title>''' + T('Problem with') + ''' %s %s</title>
</head>
<body>
<h1><font color="#0000FF"> %s %s</font></h1>
@ -129,7 +129,7 @@ def MSG_BAD_TEMPL():
''')
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():
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 may choose to stop SABnzbd and finish the queue with the older program.<br><br>
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():
return Ta(r'''
@ -151,10 +151,10 @@ def panic_message(panic, a=None, b=None):
"""Create the panic message from templates
"""
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
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
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)
elif panic == PANIC_FWALL:
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:
msg = MSG_BAD_FWALL() % "<br>"
elif panic == PANIC_SQLITE:
@ -185,7 +185,7 @@ def panic_message(panic, a=None, b=None):
msg = MSG_OTHER() % (a, b)
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:
sabnzbd.WIN_SERVICE.ErrLogger('Panic exit', msg)
@ -210,7 +210,7 @@ def panic_host(host, port):
def 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):
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, '')
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))
@ -250,7 +250,7 @@ def launch_a_browser(url, force=False):
url = 'file:///%s' % url
webbrowser.open(url, 2, 1)
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)

14
sabnzbd/postproc.py

@ -124,7 +124,7 @@ class PostProcessor(Thread):
self.history_queue.remove(nzo)
except:
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)
self.save()
@ -408,7 +408,7 @@ def process_job(nzo):
try:
newfiles = rename_and_collapse_folder(tmp_workdir_complete, workdir_complete, newfiles)
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)
# Better disable sorting because filenames are all off now
file_sorter.sort_file = None
@ -503,7 +503,7 @@ def process_job(nzo):
nzo.status = Status.FAILED
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:
logging.info("Traceback: ", exc_info = True)
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))
sabnzbd.nzbqueue.NzbQueue.do.cleanup_nzo(nzo, keep_basic=not all_ok)
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)
## Remove download folder
@ -549,7 +549,7 @@ def process_job(nzo):
logging.debug('Removing workdir %s', workdir)
remove_all(workdir, recursive=True)
except:
logging.error(Ta('Error removing workdir (%s)'), workdir)
logging.error(T('Error removing workdir (%s)'), workdir)
logging.info("Traceback: ", exc_info = True)
# 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)
os.remove(path)
except:
logging.error(Ta('Removing %s failed'), path)
logging.error(T('Removing %s failed'), path)
logging.info("Traceback: ", exc_info = True)
if files:
try:
@ -772,7 +772,7 @@ def remove_samples(path):
logging.info("Removing unwanted sample file %s", path)
os.remove(path)
except:
logging.error(Ta('Removing %s failed'), path)
logging.error(T('Removing %s failed'), path)
logging.info("Traceback: ", exc_info = True)

16
sabnzbd/powersup.py

@ -24,8 +24,6 @@ import subprocess
import logging
import time
from sabnzbd.encoding import latin1
#------------------------------------------------------------------------------
# Power management for Windows
@ -36,7 +34,7 @@ def win_hibernate():
subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Hibernate")
time.sleep(10)
except:
logging.error(Ta('Failed to hibernate system'))
logging.error(T('Failed to hibernate system'))
logging.info("Traceback: ", exc_info = True)
@ -47,7 +45,7 @@ def win_standby():
subprocess.Popen("rundll32 powrprof.dll,SetSuspendState Standby")
time.sleep(10)
except:
logging.error(Ta('Failed to standby system'))
logging.error(T('Failed to standby system'))
logging.info("Traceback: ", exc_info = True)
@ -78,7 +76,7 @@ def osx_shutdown():
try:
subprocess.call(['osascript', '-e', 'tell app "System Events" to shut down'])
except:
logging.error(Ta('Error while shutting down system'))
logging.error(T('Error while shutting down system'))
logging.info("Traceback: ", exc_info = True)
os._exit(0)
@ -90,7 +88,7 @@ def osx_standby():
subprocess.call(['osascript', '-e','tell app "System Events" to sleep'])
time.sleep(10)
except:
logging.error(Ta('Failed to standby system'))
logging.error(T('Failed to standby system'))
logging.info("Traceback: ", exc_info = True)
@ -174,7 +172,7 @@ def linux_shutdown():
try:
proxy.Stop(dbus_interface=interface)
except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg))
logging.info('Received a DBus exception %s', msg)
else:
logging.info('DBus does not support Stop (shutdown)')
os._exit(0)
@ -198,7 +196,7 @@ def linux_hibernate():
try:
proxy.Hibernate(dbus_interface=interface)
except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg))
logging.info('Received a DBus exception %s', msg)
else:
logging.info('DBus does not support Hibernate')
time.sleep(10)
@ -222,7 +220,7 @@ def linux_standby():
try:
proxy.Suspend(dbus_interface=interface)
except dbus.exceptions.DBusException, msg:
logging.info('Received a DBus exception %s', latin1(msg))
logging.info('Received a DBus exception %s', msg)
else:
logging.info('DBus does not support Suspend (standby)')
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, \
match_str, from_units, int_conv
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
@ -277,7 +277,7 @@ class RSSQueue(object):
try:
feeds = config.get_rss()[feed]
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)
return T('Incorrect RSS feed description "%s"') % feed
@ -338,27 +338,27 @@ class RSSQueue(object):
d = feedparser.parse(uri.replace('feed://', 'http://'))
logging.debug("Done parsing %s", uri)
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)
return unicoder(msg)
status = d.get('status', 999)
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)
return unicoder(msg)
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)
return unicoder(msg)
entries = d.get('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)
return unicoder(msg)
if not entries:
msg = Ta('RSS Feed %s was empty') % uri
msg = T('RSS Feed %s was empty') % uri
logging.info(msg)
if feed not in self.jobs:
@ -385,7 +385,7 @@ class RSSQueue(object):
link = None
category = u''
size = 0L
logging.info(Ta('Incompatible feed') + ' ' + uri)
logging.info(T('Incompatible feed') + ' ' + uri)
logging.info("Traceback: ", exc_info = True)
return T('Incompatible feed')
title = entry.title
@ -683,7 +683,7 @@ def _get_link(uri, entry):
category = ''
return link, category, size
else:
logging.warning(Ta('Empty RSS entry found (%s)'), link)
logging.warning(T('Empty RSS entry found (%s)'), link)
return None, '', 0L

8
sabnzbd/scheduler.py

@ -80,7 +80,7 @@ def init():
m = int(m)
h = int(h)
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
if d.isdigit():
@ -145,7 +145,7 @@ def init():
action = sabnzbd.nzbqueue.NzbQueue.do.resume_on_prio
arguments = [HIGH_PRIORITY]
else:
logging.warning(Ta('Unknown action: %s'), action_name)
logging.warning(T('Unknown action: %s'), action_name)
continue
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:
servers[value] = 1
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':
try:
servers[value] = 0
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
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
from sabnzbd.constants import series_match, date_match, year_match, sample_match
import sabnzbd.cfg as cfg
from sabnzbd.encoding import titler, latin1
from sabnzbd.encoding import titler
RE_SAMPLE = re.compile(sample_match, re.I)
# Do not rename .vob files as they are usually DVD's
@ -173,7 +173,7 @@ class Sorter(object):
try:
renamer(old, workdir_complete)
except:
logging.error(Ta('Cannot create directory %s'), workdir_complete)
logging.error(T('Cannot create directory %s'), workdir_complete)
workdir_complete = old
ok = False
return workdir_complete, ok
@ -324,7 +324,7 @@ class SeriesSorter(object):
return True
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)
return False
@ -693,7 +693,7 @@ class GenericSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath)
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)
rename_similar(current_path, ext, self.filename_set, ())
@ -717,7 +717,7 @@ class GenericSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath)
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)
rename_similar(current_path, ext, self.filename_set, renamed)
else:
@ -905,7 +905,7 @@ class DateSorter(object):
logging.debug("Rename: %s to %s", filepath, newpath)
renamer(filepath, newpath)
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)
rename_similar(current_path, ext, self.filename_set, ())
break
@ -1026,7 +1026,7 @@ def get_descriptions(nzo, match, name):
like ' - Description' or '_-_Description'
'''
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:
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)
renamer(path, newpath)
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)
cleanup_empty_directories(folder)

Loading…
Cancel
Save