-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import logging | ||
import os | ||
import subprocess | ||
|
||
from tqdm import tqdm | ||
from tqdm.contrib.logging import logging_redirect_tqdm | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s" | ||
) | ||
|
||
|
||
def main(artifacts_path, custom_cwd): | ||
java_command = "/usr/lib/jvm/java-11-openjdk-amd64/bin/java" | ||
java_options = "-Xmx8g" | ||
classpath = "target/dependency/*:target/thesis-1.0-SNAPSHOT.jar" | ||
main_class = "nl.tudelft.cornul11.thesis.corpus.MainApp" | ||
mode = "-m IDENTIFICATION_MODE" | ||
|
||
for root, dirs, files in tqdm(os.walk(artifacts_path)): | ||
for file in files: | ||
if file.endswith(".jar"): | ||
jar_path = os.path.join(root, file) | ||
output_path = jar_path.replace(".jar", ".json") | ||
command = [ | ||
java_command, | ||
java_options, | ||
"-cp", | ||
classpath, | ||
main_class, | ||
mode, | ||
"-f", | ||
jar_path, | ||
"-o", | ||
output_path, | ||
] | ||
|
||
logging.info(f"Running command: {' '.join(command)}") | ||
result = subprocess.run(command, cwd=custom_cwd, shell=True) | ||
if result.returncode != 0: | ||
tqdm_log(f"Failed to run command: {' '.join(command)}") | ||
else: | ||
tqdm_log(f"Successfully ran command: {' '.join(command)}") | ||
|
||
|
||
def tqdm_log(msg): | ||
with logging_redirect_tqdm(): | ||
logging.error(msg) | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
|
||
artifacts_path = sys.argv[1] | ||
custom_cwd = sys.argv[2] | ||
main(artifacts_path, custom_cwd) |