Leon4gr45 commited on
Commit
3252eab
·
verified ·
1 Parent(s): 49f3ad5

Upload python/helpers/settings.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. 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
- _result = subprocess.run(
1575
- ["chpasswd"],
1576
- input=f"root:{password}".encode(),
1577
- capture_output=True,
1578
- check=True,
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