Add python 3.10 support back to CLI +fixes

This commit is contained in:
Thiago Moretto
2024-08-29 14:37:34 -03:00
parent 345f1eacde
commit 9a10cc15f4
3 changed files with 15 additions and 5 deletions

View File

@@ -2,6 +2,8 @@ from os import getenv
import requests import requests
from crewai.cli.deploy.utils import get_crewai_version
class CrewAPI: class CrewAPI:
""" """
@@ -13,6 +15,7 @@ class CrewAPI:
self.headers = { self.headers = {
"Authorization": f"Bearer {api_key}", "Authorization": f"Bearer {api_key}",
"Content-Type": "application/json", "Content-Type": "application/json",
"User-Agent": f"CrewAI-CLI/{get_crewai_version()}",
} }
self.base_url = getenv( self.base_url = getenv(
"CREWAI_BASE_URL", "https://dev.crewai.com/crewai_plus/api/v1/crews" "CREWAI_BASE_URL", "https://dev.crewai.com/crewai_plus/api/v1/crews"

View File

@@ -113,6 +113,11 @@ class DeployCommand:
env_vars = fetch_and_json_env_file() env_vars = fetch_and_json_env_file()
remote_repo_url = get_git_remote_url() remote_repo_url = get_git_remote_url()
if remote_repo_url is None:
console.print("No remote repository URL found.", style="bold red")
console.print("Please ensure your project has a valid remote repository.", style="yellow")
return
self._confirm_input(env_vars, remote_repo_url) self._confirm_input(env_vars, remote_repo_url)
payload = self._create_payload(env_vars, remote_repo_url) payload = self._create_payload(env_vars, remote_repo_url)

View File

@@ -1,10 +1,13 @@
import sys import sys
import re import re
import subprocess import subprocess
import ast
from rich.console import Console
from ..authentication.utils import TokenManager from ..authentication.utils import TokenManager
console = Console()
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
@@ -53,13 +56,12 @@ def get_git_remote_url() -> str:
if matches: if matches:
return matches[0] # Return the first match (origin URL) return matches[0] # Return the first match (origin URL)
else: else:
print("No origin remote found.") console.print("No origin remote found.", style="bold red")
return "No remote URL found"
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
return f"Error running trying to fetch the Git Repository: {e}" console.print(f"Error running trying to fetch the Git Repository: {e}", style="bold red")
except FileNotFoundError: except FileNotFoundError:
return "Git command not found. Make sure Git is installed and in your PATH." console.print("Git command not found. Make sure Git is installed and in your PATH.", style="bold red")
def get_project_name(pyproject_path: str = "pyproject.toml"): def get_project_name(pyproject_path: str = "pyproject.toml"):