use a warning for failure to set file permissions

instead of print
This commit is contained in:
Min RK 2017-01-03 14:50:56 +01:00
parent cd7e0a939c
commit 53f809d407
2 changed files with 8 additions and 5 deletions

View File

@ -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):

View File

@ -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)