Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonOstrez committed Sep 29, 2023
1 parent 4c1fe83 commit f5feb62
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
8 changes: 3 additions & 5 deletions pilot/helpers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@
import threading
import queue
import time
import uuid
import platform

from utils.style import yellow, green, white, red, yellow_bold, white_bold
from utils.style import yellow, green, red, yellow_bold, white_bold
from database.database import get_saved_command_run, save_command_run
from const.function_calls import DEBUG_STEPS_BREAKDOWN
from helpers.exceptions.TooDeepRecursionError import TooDeepRecursionError
from helpers.exceptions.TokenLimitError import TokenLimitError
from prompts.prompts import ask_user
from utils.questionary import styled_text
from const.code_execution import MAX_COMMAND_DEBUG_TRIES, MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH
from const.code_execution import MIN_COMMAND_RUN_TIME, MAX_COMMAND_RUN_TIME, MAX_COMMAND_OUTPUT_LENGTH

interrupted = False

Expand Down Expand Up @@ -108,6 +105,7 @@ def execute_command(project, command, timeout=None, force=False):
answer = ask_user(
project,
f'Can I execute the command: `' + yellow_bold(command) + f'` with {timeout}ms timeout?',
False,
hint='If yes, just press ENTER'
)

Expand Down
3 changes: 0 additions & 3 deletions pilot/main.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# main.py
from __future__ import print_function, unicode_literals
import builtins
import json
import os

import sys
import traceback
from dotenv import load_dotenv
load_dotenv()
from termcolor import colored
from helpers.ipc import IPCClient
from const.ipc import MESSAGE_TYPE
from utils.utils import json_serial
from utils.style import red

from helpers.Project import Project
Expand Down
14 changes: 7 additions & 7 deletions pilot/utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import sys
import uuid
from getpass import getuser
from termcolor import colored
from database.database import get_app, get_app_by_user_workspace
from utils.style import green_bold


def get_arguments():
Expand Down Expand Up @@ -44,18 +44,18 @@ def get_arguments():
arguments['name'] = app.name
# Add any other fields from the App model you wish to include

print(colored('\n------------------ LOADING PROJECT ----------------------', 'green', attrs=['bold']))
print(colored(f'{app.name} (app_id={arguments["app_id"]})', 'green', attrs=['bold']))
print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold']))
print(green_bold('\n------------------ LOADING PROJECT ----------------------'))
print(green_bold(f'{app.name} (app_id={arguments["app_id"]})'))
print(green_bold('--------------------------------------------------------------\n'))
except ValueError as e:
print(e)
# Handle the error as needed, possibly exiting the script
else:
arguments['app_id'] = str(uuid.uuid4())
print(colored('\n------------------ STARTING NEW PROJECT ----------------------', 'green', attrs=['bold']))
print(green_bold('\n------------------ STARTING NEW PROJECT ----------------------'))
print("If you wish to continue with this project in future run:")
print(colored(f'python {sys.argv[0]} app_id={arguments["app_id"]}', 'green', attrs=['bold']))
print(colored('--------------------------------------------------------------\n', 'green', attrs=['bold']))
print(green_bold(f'python {sys.argv[0]} app_id={arguments["app_id"]}'))
print(green_bold('--------------------------------------------------------------\n'))

if 'email' not in arguments:
arguments['email'] = get_email()
Expand Down
9 changes: 7 additions & 2 deletions pilot/utils/questionary.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from prompt_toolkit.styles import Style
import questionary
from utils.style import yellow_bold

import re
from database.database import save_user_input, get_saved_user_input
from const.ipc import MESSAGE_TYPE

custom_style = Style.from_dict({
'question': '#FFFFFF bold', # the color and style of the question
Expand All @@ -14,6 +13,11 @@
})


def remove_ansi_codes(s: str) -> str:
ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
return ansi_escape.sub('', s)


def styled_select(*args, **kwargs):
kwargs["style"] = custom_style # Set style here
return questionary.select(*args, **kwargs).unsafe_ask() # .ask() is included here
Expand All @@ -34,6 +38,7 @@ def styled_text(project, question, ignore_user_input_count=False):
config = {
'style': custom_style,
}
question = remove_ansi_codes(question) # Colorama and questionary are not compatible and styling doesn't work
response = questionary.text(question, **config).unsafe_ask() # .ask() is included here
else:
response = print(question, type='user_input_request')
Expand Down
1 change: 0 additions & 1 deletion pilot/utils/style.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from termcolor import colored
from colorama import Fore, Style

def red(text):
Expand Down

0 comments on commit f5feb62

Please sign in to comment.