Browse Source

Add option to disable helpful warnings

Closes #1112
pull/1579/head
Safihre 5 years ago
parent
commit
1f554816b6
  1. 25
      SABnzbd.py
  2. 3
      sabnzbd/cfg.py
  3. 2
      sabnzbd/downloader.py
  4. 5
      sabnzbd/interface.py
  5. 6
      sabnzbd/misc.py
  6. 8
      sabnzbd/nzbstuff.py
  7. 2
      sabnzbd/postproc.py

25
SABnzbd.py

@ -106,6 +106,16 @@ def guard_loglevel():
LOG_FLAG = True 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): class GUIHandler(logging.Handler):
""" Logging handler collects the last warnings/errors/exceptions """ Logging handler collects the last warnings/errors/exceptions
to be displayed in the web-gui 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) full_main = real_path(full_dir, DEF_MAIN_TMPL)
if not os.path.exists(full_main): 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_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):
@ -423,10 +433,12 @@ def print_modules():
logging.info("UNRAR binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND) logging.info("UNRAR binary... found (%s)", sabnzbd.newsunpack.RAR_COMMAND)
# Report problematic unrar # 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) have_str = "%.2f" % (float(sabnzbd.newsunpack.RAR_VERSION) / 100)
want_str = "%.2f" % (float(sabnzbd.constants.REC_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.<br />"), have_str, want_str) logging.warning_helpfull(
T("Your UNRAR version is %s, we recommend version %s or higher.<br />"), have_str, want_str
)
elif not (sabnzbd.WIN32 or sabnzbd.DARWIN): elif not (sabnzbd.WIN32 or sabnzbd.DARWIN):
logging.info("UNRAR binary version %.2f", (float(sabnzbd.newsunpack.RAR_VERSION) / 100)) logging.info("UNRAR binary version %.2f", (float(sabnzbd.newsunpack.RAR_VERSION) / 100))
else: else:
@ -596,7 +608,9 @@ 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(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: 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
@ -847,7 +861,6 @@ def main():
pid_path = None pid_path = None
pid_file = None pid_file = None
new_instance = False new_instance = False
osx_console = False
ipv6_hosting = None ipv6_hosting = None
_service, sab_opts, _serv_opts, upload_nzbs = commandline_handler() _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: # 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()): if not sabnzbd.WIN32 and not sabnzbd.DARWIN and not ("utf-8" in sabnzbd.encoding.CODEPAGE.lower()):
logging.warning( logging.warning_helpfull(
T( T(
"SABnzbd was started with encoding %s, this should be UTF-8. Expect problems with Unicoded file and directory names in downloads." "SABnzbd was started with encoding %s, this should be UTF-8. Expect problems with Unicoded file and directory names in downloads."
), ),

3
sabnzbd/cfg.py

@ -254,17 +254,16 @@ enable_filejoin = OptionBool("misc", "enable_filejoin", True)
enable_tsjoin = OptionBool("misc", "enable_tsjoin", True) enable_tsjoin = OptionBool("misc", "enable_tsjoin", True)
overwrite_files = OptionBool("misc", "overwrite_files", False) overwrite_files = OptionBool("misc", "overwrite_files", False)
ignore_unrar_dates = OptionBool("misc", "ignore_unrar_dates", 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) backup_for_duplicates = OptionBool("misc", "backup_for_duplicates", True)
empty_postproc = OptionBool("misc", "empty_postproc", False) empty_postproc = OptionBool("misc", "empty_postproc", False)
wait_for_dfolder = OptionBool("misc", "wait_for_dfolder", 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) rss_filenames = OptionBool("misc", "rss_filenames", False)
api_logging = OptionBool("misc", "api_logging", True) api_logging = OptionBool("misc", "api_logging", True)
html_login = OptionBool("misc", "html_login", True) html_login = OptionBool("misc", "html_login", True)
osx_menu = OptionBool("misc", "osx_menu", True) osx_menu = OptionBool("misc", "osx_menu", True)
osx_speed = OptionBool("misc", "osx_speed", True) osx_speed = OptionBool("misc", "osx_speed", True)
warn_dupl_jobs = OptionBool("misc", "warn_dupl_jobs", True) warn_dupl_jobs = OptionBool("misc", "warn_dupl_jobs", True)
helpfull_warnings = OptionBool("misc", "helpfull_warnings", True)
keep_awake = OptionBool("misc", "keep_awake", True) keep_awake = OptionBool("misc", "keep_awake", True)
win_menu = OptionBool("misc", "win_menu", True) win_menu = OptionBool("misc", "win_menu", True)
allow_incomplete_nzb = OptionBool("misc", "allow_incomplete_nzb", False) allow_incomplete_nzb = OptionBool("misc", "allow_incomplete_nzb", False)

2
sabnzbd/downloader.py

@ -326,7 +326,7 @@ class Downloader(Thread):
if mx: if mx:
self.bandwidth_limit = mx * self.bandwidth_perc / 100 self.bandwidth_limit = mx * self.bandwidth_perc / 100
else: 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: else:
self.bandwidth_limit = from_units(value) self.bandwidth_limit = from_units(value)
if mx: if mx:

5
sabnzbd/interface.py

@ -1325,11 +1325,11 @@ SPECIAL_BOOL_LIST = (
"start_paused", "start_paused",
"no_penalties", "no_penalties",
"fast_fail", "fast_fail",
"ignore_wrong_unrar",
"overwrite_files", "overwrite_files",
"enable_par_cleanup", "enable_par_cleanup",
"queue_complete_pers", "queue_complete_pers",
"api_warnings", "api_warnings",
"helpfull_warnings",
"ampm", "ampm",
"enable_unrar", "enable_unrar",
"enable_unzip", "enable_unzip",
@ -1348,7 +1348,6 @@ SPECIAL_BOOL_LIST = (
"html_login", "html_login",
"wait_for_dfolder", "wait_for_dfolder",
"max_art_opt", "max_art_opt",
"warn_empty_nzb",
"enable_bonjour", "enable_bonjour",
"warn_dupl_jobs", "warn_dupl_jobs",
"replace_illegal", "replace_illegal",
@ -1536,7 +1535,7 @@ class ConfigGeneral:
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(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() config.save_config()

6
sabnzbd/misc.py

@ -431,7 +431,7 @@ def check_latest_version():
url = url_beta url = url_beta
if testver and current < latest: 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 # "Final" of this one yet, so show the Final
sabnzbd.NEW_VERSION = (latest_label, url) sabnzbd.NEW_VERSION = (latest_label, url)
elif current < latest: elif current < latest:
@ -528,7 +528,7 @@ def caller_name(skip=2):
parentframe = sys._getframe(skip) parentframe = sys._getframe(skip)
function_name = parentframe.f_code.co_name 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"): if hasattr(sys, "frozen"):
module_name = inspect.getfile(parentframe) module_name = inspect.getfile(parentframe)
else: else:
@ -792,7 +792,7 @@ def get_all_passwords(nzo):
# Check size # Check size
if len(pws) > 30: if len(pws) > 30:
logging.warning( logging.warning_helpfull(
T( T(
"Your password file contains more than 30 passwords, testing all these passwords takes a lot of time. Try to only list useful passwords." "Your password file contains more than 30 passwords, testing all these passwords takes a lot of time. Try to only list useful passwords."
) )

8
sabnzbd/nzbstuff.py

@ -753,14 +753,10 @@ class NzbObject(TryList):
if not self.files and not reuse: if not self.files and not reuse:
self.purge_data() self.purge_data()
if cfg.warn_empty_nzb():
mylog = logging.warning
else:
mylog = logging.info
if self.url: 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: else:
mylog(T("Empty NZB file %s"), filename) logging.warning(T("Empty NZB file %s"), filename)
raise ValueError raise ValueError
if cat is None: if cat is None:

2
sabnzbd/postproc.py

@ -220,7 +220,7 @@ class PostProcessor(Thread):
# First we do a dircheck # First we do a dircheck
complete_dir = sabnzbd.cfg.complete_dir.get_path() complete_dir = sabnzbd.cfg.complete_dir.get_path()
if sabnzbd.utils.checkdir.isFAT(complete_dir): 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") T("Completed Download Folder %s is on FAT file system, limiting maximum file size to 4GB")
% complete_dir % complete_dir
) )

Loading…
Cancel
Save