Spaces:
Running
Running
Upload python/helpers/settings.py with huggingface_hub
Browse files- python/helpers/settings.py +14 -6
python/helpers/settings.py
CHANGED
|
@@ -1571,12 +1571,20 @@ def _dict_to_env(data_dict):
|
|
| 1571 |
def set_root_password(password: str):
|
| 1572 |
if not runtime.is_dockerized():
|
| 1573 |
raise Exception("root password can only be set in dockerized environments")
|
| 1574 |
-
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
|
| 1578 |
-
|
| 1579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1580 |
dotenv.save_dotenv_value(dotenv.KEY_ROOT_PASSWORD, password)
|
| 1581 |
|
| 1582 |
|
|
|
|
| 1571 |
def set_root_password(password: str):
|
| 1572 |
if not runtime.is_dockerized():
|
| 1573 |
raise Exception("root password can only be set in dockerized environments")
|
| 1574 |
+
try:
|
| 1575 |
+
_result = subprocess.run(
|
| 1576 |
+
["sudo", "chpasswd"],
|
| 1577 |
+
input=f"root:{password}".encode(),
|
| 1578 |
+
capture_output=True,
|
| 1579 |
+
check=True,
|
| 1580 |
+
)
|
| 1581 |
+
except subprocess.CalledProcessError:
|
| 1582 |
+
_result = subprocess.run(
|
| 1583 |
+
["chpasswd"],
|
| 1584 |
+
input=f"root:{password}".encode(),
|
| 1585 |
+
capture_output=True,
|
| 1586 |
+
check=True,
|
| 1587 |
+
)
|
| 1588 |
dotenv.save_dotenv_value(dotenv.KEY_ROOT_PASSWORD, password)
|
| 1589 |
|
| 1590 |
|