diff --git a/pygeoweaver/sc_resetpassword.py b/pygeoweaver/sc_resetpassword.py index b605ecc..bb5d303 100644 --- a/pygeoweaver/sc_resetpassword.py +++ b/pygeoweaver/sc_resetpassword.py @@ -1,11 +1,26 @@ +import getpass +from logging import getLogger import subprocess from pygeoweaver.utils import ( + check_ipython, download_geoweaver_jar, get_geoweaver_jar_path, get_java_bin_path, get_root_dir, ) +logger = getLogger(__name__) + +def get_password_twice(): + while True: + password1 = getpass.getpass('Enter password: ') + password2 = getpass.getpass('Re-enter password: ') + + if password1 == password2: + return password1 + else: + print("Passwords don't match. Please try again.") + def reset_password(): """ @@ -13,11 +28,27 @@ def reset_password(): Reset password for localhost """ download_geoweaver_jar() - subprocess.run( - [ - get_java_bin_path(), - "-jar", - get_geoweaver_jar_path(), - "resetpassword", - ] - ) + + if check_ipython(): + logger.debug("ipython is here") + password = get_password_twice() + subprocess.run( + [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "resetpassword", + "-p", + password + ] + ) + else: + logger.debug("not ipython") + subprocess.run( + [ + get_java_bin_path(), + "-jar", + get_geoweaver_jar_path(), + "resetpassword", + ] + ) diff --git a/pyproject.toml b/pyproject.toml index 205377b..f595037 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pygeoweaver" -version = "0.6.17" +version = "0.6.19" authors = [ { name="Geoweaver team", email="geoweaver.app@gmail.com" }, ] @@ -22,7 +22,7 @@ classifiers = [ [tool.poetry] name = "pygeoweaver" -version = "0.6.17" +version = "0.6.19" description = "This is a wrapper package of the Geoweaver app." authors = ["Geoweaver team "] readme = "README.md"