Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions patchwork/common/tools/grep_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def execute(
is_case_sensitive: bool = False,
) -> str:
if pattern is None:
raise ValueError("pattern argument is required!")
return "`pattern` argument is required!"

if path is None:
path = Path(self.__working_dir)
Expand All @@ -173,9 +173,12 @@ def execute(
if is_case_sensitive:
matcher = fnmatch.fnmatchcase

path = Path(path).resolve()
try:
path = Path(path).resolve()
except FileNotFoundError:
return f"`path` does not exist"
if not path.is_relative_to(self.__working_dir):
raise ValueError("Path must be relative to working dir")
return f"Path must be relative to working dir {self.__working_dir}"

if path.is_file():
paths = [path]
Expand Down
6 changes: 5 additions & 1 deletion patchwork/common/tools/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ def execute_logging_wrapper(self, *args, **kwargs):
arg_text += f"kwargs: {kwargs}"

logger.info(f"Executing Tool: {self.name} with {arg_text}")
return func(self, *args, **kwargs)
try:
return func(self, *args, **kwargs)
except Exception as e:
logger.error(f"Error executing Tool: {self.name}: {e}")
return f"Error: {e}"

return execute_logging_wrapper
8 changes: 4 additions & 4 deletions patchwork/common/utils/zoho_token_manager.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import yaml
import time
import requests
from typing import Dict, Optional, Callable
from pathlib import Path
from typing import Callable, Dict, Optional

import requests
import yaml


class ZohoTokenManager:
Expand Down
Loading