-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
test: | ||
./scripts/test.sh | ||
|
||
check-all: | ||
python3 ./scripts/check-all.py |
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,48 @@ | ||
import os | ||
import subprocess | ||
from concurrent.futures import ThreadPoolExecutor | ||
|
||
|
||
def run_kcl_command(path): | ||
""" | ||
Executes the kcl run command | ||
""" | ||
print(f"Running 'kcl run' in {path}...") | ||
result = subprocess.run(["kcl", "run"], cwd=path, capture_output=True, text=True) | ||
if result.stderr: | ||
print(f"Error running 'kcl run' in {path}: {result.stderr}") | ||
else: | ||
print(f"Output from running 'kcl run' in {path}: {result.stdout}") | ||
|
||
|
||
def find_and_run_kcl(paths_list): | ||
""" | ||
Concurrently executes the kcl run command in paths containing kcl.mod | ||
""" | ||
with ThreadPoolExecutor() as executor: | ||
executor.map(run_kcl_command, paths_list) | ||
|
||
|
||
def find_kcl_mod_files(directory): | ||
""" | ||
Recursively searches for paths containing the kcl.mod file | ||
""" | ||
paths_with_kcl_mod = [] | ||
for root, dirs, files in os.walk(directory): | ||
if "kcl.mod" in files: | ||
paths_with_kcl_mod.append(root) | ||
return paths_with_kcl_mod | ||
|
||
|
||
def main(): | ||
examples_dir = "examples" # Set the path of the examples folder | ||
paths_with_kcl_mod = find_kcl_mod_files(examples_dir) | ||
if paths_with_kcl_mod: | ||
print(f"Found {len(paths_with_kcl_mod)} paths with 'kcl.mod'.") | ||
find_and_run_kcl(paths_with_kcl_mod) | ||
else: | ||
print("No 'kcl.mod' files found in the directory.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |