diff --git a/notebook/auth/security.py b/notebook/auth/security.py index 7441d5409..8f69148ee 100644 --- a/notebook/auth/security.py +++ b/notebook/auth/security.py @@ -9,8 +9,8 @@ import io import json import os import random -import sys import traceback +import warnings from ipython_genutils.py3compat import cast_bytes, str_to_bytes, cast_unicode from traitlets.config import Config, ConfigFileNotFound, JSONFileConfigLoader @@ -133,9 +133,10 @@ def persist_config(config_file=None, mode=0o600): try: os.chmod(config_file, mode) - except Exception: - print("Failed to set permissions on %s:" % config_file, file=sys.stderr) - traceback.print_exc(file=sys.stderr) + except Exception as e: + tb = traceback.format_exc() + warnings.warn("Failed to set permissions on %s:\n%s" % (config_file, tb), + RuntimeWarning) def set_password(password=None, config_file=None): diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 82b68c5dd..ed14daa5c 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -331,9 +331,11 @@ class NotebookPasswordApp(JupyterApp): and removes the need for token-based authentication. """ + description = __doc__ + def _config_file_default(self): return os.path.join(self.config_dir, 'jupyter_notebook_config.json') - description = __doc__ + def start(self): from .auth.security import set_password set_password(config_file=self.config_file)