Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add jmx manager #2

Merged
merged 1 commit into from
Apr 29, 2023
Merged
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
18 changes: 12 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
logger.add(
sink=sys.stderr,
format="<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | "
"<level>{level: <4}</level> | "
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
"<level>{level: <4}</level> | "
"<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>",
level="INFO",
)

app = FastAPI()
app = FastAPI(title="Jmeter ToolKit")

JMX_FILE_PATH = Path("jmx_files")
JTL_FILES_PATH = Path("jtl_files")



class ExecuteJmxResponse(BaseModel):
output_file_path: str
cost_time: str
Expand Down Expand Up @@ -140,7 +139,11 @@ async def list_files(file_type: FileType):
else:
raise HTTPException(status_code=400, detail="Invalid file type")

files = [f for f in os.listdir(dir_path) if isfile(os.path.join(dir_path, f)) and f.endswith(ext)]
files = [
f
for f in os.listdir(dir_path)
if isfile(os.path.join(dir_path, f)) and f.endswith(ext)
]
return {"files": files}


Expand All @@ -154,13 +157,16 @@ async def get_file_content(filename: str, file_type: FileType):
raise HTTPException(status_code=400, detail="Invalid file type")

if not file.exists():
raise HTTPException(status_code=404, detail=f"File not found, file={file.absolute()}")
raise HTTPException(
status_code=404, detail=f"File not found, file={file.absolute()}"
)

with open(file, "r") as f:
content = f.read()

return {"filename": filename, "content": content}


if __name__ == "__main__":
import uvicorn

Expand Down