-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lestarch: restrict fpp from regenerating on any locs change, fpp tool…
…s verion checking (#1087) * lestarch: changes necessary to restrict fpp from regenerating on any loc change * lestarch: fixing prev locs hole on crash * lestarch: formatting Python * lestarch: appeasing CI * lestarch: fpp tools installation checks version
- Loading branch information
Showing
12 changed files
with
267 additions
and
71 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
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
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,58 @@ | ||
import os | ||
import sys | ||
import argparse | ||
import difflib | ||
from fprime_ac.utils.buildroot import ( | ||
build_root_relative_path, | ||
set_build_roots, | ||
) | ||
|
||
|
||
def main(): | ||
"""Process arguments: file old, file new, module deps to see if any mod deps has changed""" | ||
set_build_roots(os.environ["BUILD_ROOT"]) | ||
parser = argparse.ArgumentParser( | ||
description="Has a module dependency changed within the locs file." | ||
) | ||
parser.add_argument("new_locs", help="New locs file") | ||
parser.add_argument("prev_locs", help="Original locs file") | ||
parser.add_argument("file_deps", nargs="+", help="Module deps") | ||
|
||
args_ns = parser.parse_args() | ||
|
||
if not os.path.exists(args_ns.new_locs): | ||
print(f"[ERROR] Failed to open {args_ns.new_locs}") | ||
sys.exit(1) | ||
# Previous files not generated | ||
if not os.path.exists(args_ns.prev_locs): | ||
print(f"No pervious locations") | ||
sys.exit(1) | ||
|
||
with open(args_ns.prev_locs, "r") as prev_locs_fh: | ||
prev_lines = prev_locs_fh.readlines() | ||
with open(args_ns.new_locs, "r") as new_locs_fh: | ||
new_lines = new_locs_fh.readlines() | ||
|
||
diff_output = list(difflib.unified_diff(prev_lines, new_lines, n=0, lineterm="\n")) | ||
subtracted_lines = [ | ||
diff | ||
for diff in diff_output | ||
if diff.startswith("-") and not diff.startswith("---") | ||
] | ||
relative_mod_paths = [line.split()[-1].strip('"') for line in subtracted_lines] | ||
subtractions = [ | ||
os.path.abspath(os.path.join(os.path.dirname(args_ns.new_locs), rel_path)) | ||
for rel_path in relative_mod_paths | ||
] | ||
changed = [] | ||
for subtraction in subtractions: | ||
if subtraction in args_ns.file_deps: | ||
changed.append(os.path.basename(subtraction)) | ||
if changed: | ||
print(f"{', '.join(changed)}") | ||
sys.exit(2) | ||
sys.exit(0) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,18 @@ | ||
#!/bin/bash | ||
|
||
# Grab the removal file from the first argument | ||
REMOVE_FILE="$1" | ||
|
||
# Nab the program as the first argument, and shift it away | ||
PROGRAM="$2" | ||
shift | ||
shift | ||
|
||
# Run the wrapped program with the properly wrapped remaining arguments | ||
"${PROGRAM}" "$@" | ||
RET="$?" | ||
if (( $RET != 0 )) | ||
then | ||
rm -f "${REMOVE_FILE}" | ||
fi | ||
exit $RET |
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
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
Oops, something went wrong.