Check if an argument is given

If NOTEBOOK_PASSWORD env var is not set
this script would fail.

I also changed to use notebook.auth as is
the one in Jupyter docs for hashing passwords.

This fix #138.
This commit is contained in:
Alexandre Vicenzi
2019-08-16 23:08:45 +02:00
parent acd0f3a64f
commit 29648ecac3
2 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
jupyter notebook --port=8888 --no-browser --allow-root --ip=0.0.0.0 --NotebookApp.token="" --NotebookApp.password="$(python set_password.py $NOTEBOOK_PASSWORD)"
jupyter notebook --port=8888 --no-browser --allow-root --ip=0.0.0.0 --NotebookApp.token="" --NotebookApp.password="$(./set_password.py $NOTEBOOK_PASSWORD)"
+18 -3
View File
@@ -1,4 +1,19 @@
#!/usr/bin/env python3
import sys
from IPython.lib import passwd
password = passwd(sys.argv[1])
print(password)
from notebook.auth import passwd
def run():
password = sys.argv[1:].pop()
if not password:
print('Error: Missing or empty password.', file=sys.stderr)
else:
encoded = passwd(password)
print(encoded)
if __name__ == '__main__':
run()