Runner py
unknown
python
a year ago
1.4 kB
5
Indexable
import os
import subprocess
from pathlib import Path
import tqdm
# Paths for output, plugin, and repo prefix
DETECTOR_OUTPUT = Path('F:/MS/Thesis/PyNose/analysis/output')
PLUGIN_ROOT = Path('F:/MS/Thesis/Pynose CLI Mode/PyNose-ASE2021')
REPO_PREFIX = Path('F:/MS/Thesis/PyNose/analysis/inputRepos')
PYTHON_INTERPRETER_NAME = 'C:/Users/User/AppData/Local/Programs/Python/Python38/python.exe'
PROJECT_LIST = [p for p in REPO_PREFIX.iterdir() if p.is_dir()]
# Create output directory if it doesn't exist
DETECTOR_OUTPUT.mkdir(parents=True, exist_ok=True)
# Initialize log file
with (DETECTOR_OUTPUT / 'log.txt').open('w') as f:
pass
# Process each project
for project in tqdm.tqdm(PROJECT_LIST):
process = subprocess.run(
[PLUGIN_ROOT / ('gradlew.bat' if os.name == 'nt' else 'gradlew'), '-p', str(PLUGIN_ROOT), 'runIde',
f'-PmyPath="{project}"' if os.name == 'nt' else f'-PmyPath={project}',
f'-PmyPython="{PYTHON_INTERPRETER_NAME}"' if os.name == 'nt' else f'-PmyPython={PYTHON_INTERPRETER_NAME}',
f'-PmyOutDir="{DETECTOR_OUTPUT}"' if os.name == 'nt' else f'-PmyOutDir={DETECTOR_OUTPUT}'],
capture_output=True,
text=True
)
# Log output and errors
with (DETECTOR_OUTPUT / 'log.txt').open('a') as f:
f.write(f'{project=}\n====STDOUT====\n{process.stdout}\n====STDERR===={process.stderr}\n\n')
Editor is loading...
Leave a Comment