diff --git a/SABnzbd.py b/SABnzbd.py index c253822..e120a44 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -106,6 +106,16 @@ def guard_loglevel(): LOG_FLAG = True +def warning_helpfull(*args, **kwargs): + """ Wrapper to ignore helpfull warnings if desired """ + if sabnzbd.cfg.helpfull_warnings(): + return logging.warning(*args, **kwargs) + return logging.info(*args, **kwargs) + + +logging.warning_helpfull = warning_helpfull + + class GUIHandler(logging.Handler): """ Logging handler collects the last warnings/errors/exceptions to be displayed in the web-gui @@ -280,7 +290,7 @@ def identify_web_template(key, defweb, wdir): full_main = real_path(full_dir, DEF_MAIN_TMPL) if not os.path.exists(full_main): - logging.warning(T("Cannot find web template: %s, trying standard template"), full_main) + logging.warning_helpfull(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): @@ -423,10 +433,12 @@ def print_modules(): logging.info("UNRAR binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND) # Report problematic unrar - if sabnzbd.newsunpack.RAR_PROBLEM and not sabnzbd.cfg.ignore_wrong_unrar(): + if sabnzbd.newsunpack.RAR_PROBLEM: have_str = "%.2f" % (float(sabnzbd.newsunpack.RAR_VERSION) / 100) want_str = "%.2f" % (float(sabnzbd.constants.REC_RAR_VERSION) / 100) - logging.warning(T("Your UNRAR version is %s, we recommend version %s or higher.
"), have_str, want_str) + logging.warning_helpfull( + T("Your UNRAR version is %s, we recommend version %s or higher.
"), have_str, want_str + ) elif not (sabnzbd.WIN32 or sabnzbd.DARWIN): logging.info("UNRAR binary version %.2f", (float(sabnzbd.newsunpack.RAR_VERSION) / 100)) else: @@ -596,7 +608,9 @@ 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(T("Please be aware the 0.0.0.0 hostname will need an IPv6 address for external access")) + logging.warning_helpfull( + 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 @@ -847,7 +861,6 @@ def main(): pid_path = None pid_file = None new_instance = False - osx_console = False ipv6_hosting = None _service, sab_opts, _serv_opts, upload_nzbs = commandline_handler() @@ -1157,7 +1170,7 @@ def main(): # On Linux/FreeBSD/Unix "UTF-8" is strongly, strongly adviced: if not sabnzbd.WIN32 and not sabnzbd.DARWIN and not ("utf-8" in sabnzbd.encoding.CODEPAGE.lower()): - logging.warning( + logging.warning_helpfull( T( "SABnzbd was started with encoding %s, this should be UTF-8. Expect problems with Unicoded file and directory names in downloads." ), diff --git a/sabnzbd/cfg.py b/sabnzbd/cfg.py index f84caf5..4a54540 100644 --- a/sabnzbd/cfg.py +++ b/sabnzbd/cfg.py @@ -254,17 +254,16 @@ enable_filejoin = OptionBool("misc", "enable_filejoin", True) enable_tsjoin = OptionBool("misc", "enable_tsjoin", True) overwrite_files = OptionBool("misc", "overwrite_files", False) ignore_unrar_dates = OptionBool("misc", "ignore_unrar_dates", False) -ignore_wrong_unrar = OptionBool("misc", "ignore_wrong_unrar", False) backup_for_duplicates = OptionBool("misc", "backup_for_duplicates", True) empty_postproc = OptionBool("misc", "empty_postproc", False) wait_for_dfolder = OptionBool("misc", "wait_for_dfolder", False) -warn_empty_nzb = OptionBool("misc", "warn_empty_nzb", True) rss_filenames = OptionBool("misc", "rss_filenames", False) api_logging = OptionBool("misc", "api_logging", True) html_login = OptionBool("misc", "html_login", True) osx_menu = OptionBool("misc", "osx_menu", True) osx_speed = OptionBool("misc", "osx_speed", True) warn_dupl_jobs = OptionBool("misc", "warn_dupl_jobs", True) +helpfull_warnings = OptionBool("misc", "helpfull_warnings", True) keep_awake = OptionBool("misc", "keep_awake", True) win_menu = OptionBool("misc", "win_menu", True) allow_incomplete_nzb = OptionBool("misc", "allow_incomplete_nzb", False) diff --git a/sabnzbd/downloader.py b/sabnzbd/downloader.py index 91c912c..814373e 100644 --- a/sabnzbd/downloader.py +++ b/sabnzbd/downloader.py @@ -326,7 +326,7 @@ class Downloader(Thread): if mx: self.bandwidth_limit = mx * self.bandwidth_perc / 100 else: - logging.warning(T("You must set a maximum bandwidth before you can set a bandwidth limit")) + logging.warning_helpfull(T("You must set a maximum bandwidth before you can set a bandwidth limit")) else: self.bandwidth_limit = from_units(value) if mx: diff --git a/sabnzbd/interface.py b/sabnzbd/interface.py index 57ed65d..f943a0a 100644 --- a/sabnzbd/interface.py +++ b/sabnzbd/interface.py @@ -1325,11 +1325,11 @@ SPECIAL_BOOL_LIST = ( "start_paused", "no_penalties", "fast_fail", - "ignore_wrong_unrar", "overwrite_files", "enable_par_cleanup", "queue_complete_pers", "api_warnings", + "helpfull_warnings", "ampm", "enable_unrar", "enable_unzip", @@ -1348,7 +1348,6 @@ SPECIAL_BOOL_LIST = ( "html_login", "wait_for_dfolder", "max_art_opt", - "warn_empty_nzb", "enable_bonjour", "warn_dupl_jobs", "replace_illegal", @@ -1536,7 +1535,7 @@ class ConfigGeneral: cfg.bandwidth_perc.set(bandwidth_perc) bandwidth_perc = cfg.bandwidth_perc() if bandwidth_perc and not bandwidth_max: - logging.warning(T("You must set a maximum bandwidth before you can set a bandwidth limit")) + logging.warning_helpfull(T("You must set a maximum bandwidth before you can set a bandwidth limit")) config.save_config() diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index fc31cfa..878790a 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -431,7 +431,7 @@ def check_latest_version(): url = url_beta if testver and current < latest: - # This is a test version, but user has't seen the + # This is a test version, but user hasn't seen the # "Final" of this one yet, so show the Final sabnzbd.NEW_VERSION = (latest_label, url) elif current < latest: @@ -528,7 +528,7 @@ def caller_name(skip=2): parentframe = sys._getframe(skip) function_name = parentframe.f_code.co_name - # Modulename not available in the binaries, we can use the filename instead + # Module name is not available in the binaries, we can use the filename instead if hasattr(sys, "frozen"): module_name = inspect.getfile(parentframe) else: @@ -792,7 +792,7 @@ def get_all_passwords(nzo): # Check size if len(pws) > 30: - logging.warning( + logging.warning_helpfull( T( "Your password file contains more than 30 passwords, testing all these passwords takes a lot of time. Try to only list useful passwords." ) diff --git a/sabnzbd/nzbstuff.py b/sabnzbd/nzbstuff.py index ff71476..24fe96f 100644 --- a/sabnzbd/nzbstuff.py +++ b/sabnzbd/nzbstuff.py @@ -753,14 +753,10 @@ class NzbObject(TryList): if not self.files and not reuse: self.purge_data() - if cfg.warn_empty_nzb(): - mylog = logging.warning - else: - mylog = logging.info if self.url: - mylog(T("Empty NZB file %s") + " [%s]", filename, self.url) + logging.warning(T("Empty NZB file %s") + " [%s]", filename, self.url) else: - mylog(T("Empty NZB file %s"), filename) + logging.warning(T("Empty NZB file %s"), filename) raise ValueError if cat is None: diff --git a/sabnzbd/postproc.py b/sabnzbd/postproc.py index 8a23c56..68ecb48 100644 --- a/sabnzbd/postproc.py +++ b/sabnzbd/postproc.py @@ -220,7 +220,7 @@ class PostProcessor(Thread): # First we do a dircheck complete_dir = sabnzbd.cfg.complete_dir.get_path() if sabnzbd.utils.checkdir.isFAT(complete_dir): - logging.warning( + logging.warning_helpfull( T("Completed Download Folder %s is on FAT file system, limiting maximum file size to 4GB") % complete_dir )