Skip to content

Commit

Permalink
Updated 'Upgrade App' option
Browse files Browse the repository at this point in the history
  • Loading branch information
haseeb-heaven committed Mar 4, 2024
1 parent 8477527 commit 09fd0f0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
20 changes: 19 additions & 1 deletion libs/interpreter_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,25 @@ def interpreter_main(self):

# UPGRAGE - Command section.
elif task.lower() == '/upgrade':
command_output,_ = self.code_interpreter.execute_command('pip install open-code-interpreter --upgrade && pip install -r requirements.txt --upgrade')

# Download the requirements file
requirements_file_url = 'https://raw.githubusercontent.com/haseeb-heaven/code-interpreter/main/requirements.txt'
requirements_file_downloaded = self.utility_manager.download_file(requirements_file_url,'requirements.txt')

# Commands to execute.
command_pip_upgrade = 'pip install open-code-interpreter --upgrade'
command_pip_requirements = 'pip install -r requirements.txt --upgrade'

# Execute the commands.
command_output,_ = self.code_interpreter.execute_command(command_pip_upgrade)
display_markdown_message(f"Command Upgrade executed successfully.")
if requirements_file_downloaded:
command_output,_ = self.code_interpreter.execute_command(command_pip_requirements)
display_markdown_message(f"Command Requirements executed successfully.")
else:
self.logger.warn(f"Requirements file not downloaded.")
display_markdown_message(f"Warning: Requirements file not downloaded.")

if command_output:
self.logger.info(f"Command executed successfully.")
display_code(command_output)
Expand Down
19 changes: 18 additions & 1 deletion libs/utility_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,21 @@ def display_version(self,version):
display_markdown_message(f"Interpreter - v{version}")

def clear_screen(self):
os.system('cls' if os.name == 'nt' else 'clear')
os.system('cls' if os.name == 'nt' else 'clear')

# method to download file from Web and save it

def download_file(self,url,file_name):
try:
import requests
self.logger.info(f"Downloading file: {url}")
response = requests.get(url, allow_redirects=True)
response.raise_for_status()

with open(file_name, 'wb') as file:
file.write(response.content)
self.logger.info(f"Reuquirements.txt file downloaded.")
return True
except Exception as exception:
self.logger.error(f"Error in downloading file: {str(exception)}")
return False

0 comments on commit 09fd0f0

Please sign in to comment.