Update update_script.py

This commit is contained in:
Saifeddine ALOUI 2024-09-03 09:15:23 +02:00 committed by GitHub
parent a3569a81e9
commit ee2ac53a52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -80,12 +80,33 @@ def run_git_pull():
ASCIIColors.error(error_message)
show_error_dialog(error_message)
return False
def get_valid_input():
while True:
update_prompt = "New code is updated. Do you want to update the requirements? (y/n): "
user_response = input(update_prompt).strip().lower()
if user_response in ['y', 'yes']:
return 'yes'
elif user_response in ['n', 'no']:
return 'no'
else:
print("Invalid input. Please respond with 'y' or 'n'.")
def install_requirements():
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "-r", "requirements.txt"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "-e", "lollms_core"])
ASCIIColors.success("Successfully installed requirements")
# Get valid input from the user
user_choice = get_valid_input()
# Enhance the text based on the user's response
if user_choice == 'yes':
enhanced_text = "Great choice! Updating requirements ensures your project stays up-to-date with the latest changes."
print(enhanced_text)
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "-r", "requirements.txt"])
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "-e", "lollms_core"])
ASCIIColors.success("Successfully installed requirements")
else: # user_choice == 'no'
enhanced_text = "Understood. Skipping the requirements update. Make sure to update them later if needed."
print(enhanced_text)
except subprocess.CalledProcessError as e:
error_message = f"Error during pip install: {str(e)}"
ASCIIColors.error(error_message)