Skip to content

Commit

Permalink
Merge pull request #2
Browse files Browse the repository at this point in the history
feat: add jmx manager
  • Loading branch information
lihuacai168 authored Apr 29, 2023
2 parents 0eceae5 + c9e4bb3 commit 8eae72d
Showing 1 changed file with 12 additions and 6 deletions.
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

0 comments on commit 8eae72d

Please sign in to comment.