Merge remote-tracking branch 'origin/main' into feature/home_page_filter_links
This commit is contained in:
commit
96c60a90f3
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
function error_handler() {
|
||||
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
||||
exit "$2"
|
||||
}
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset
|
||||
|
||||
# HELP: remove all unused functions from python files
|
||||
|
||||
if ! command -v dead >/dev/null 2>&1; then
|
||||
echo "dead is not installed. installing..."
|
||||
echo "pip install dead"
|
||||
fi
|
||||
|
||||
list_of_unused_things="$(dead | grep -E '^[a-z].*is never read')"
|
||||
|
||||
filename_patterns_to_ignore="(codemod|migrations/versions|conftest.py|noxfile.py)"
|
||||
|
||||
while read -r line; do
|
||||
function_name="$(echo "$line" | awk '{print $1}')"
|
||||
echo "possible function_name: ${function_name}"
|
||||
file_name_and_line_number="$(echo "$line" | perl -p -e "s/.*is never read, defined in //g")"
|
||||
file_name="$(echo "$file_name_and_line_number" | awk -F ':' '{print $1}')"
|
||||
if ! grep "def $function_name" "$file_name" >/dev/null 2>&1; then
|
||||
echo "skipping $function_name in ${file_name} because it's not a function"
|
||||
continue
|
||||
fi
|
||||
if grep -E "$filename_patterns_to_ignore" <<< "$file_name" >/dev/null 2>&1; then
|
||||
echo "skipping ${file_name} because it's in the list of files to ignore (probably because it is a false positive and actually used)"
|
||||
continue
|
||||
fi
|
||||
echo "trying to remove $function_name from: ${file_name}"
|
||||
|
||||
if python bin/codemod/update_file_to_remove_function.py "$file_name" "$function_name"; then
|
||||
# TODO: run exhaustive tests, and if they pass, report success
|
||||
echo "function ${function_name} removed from ${file_name}. yay!"
|
||||
exit 0
|
||||
fi
|
||||
done <<< "$list_of_unused_things"
|
|
@ -0,0 +1,33 @@
|
|||
from bowler import Query
|
||||
from bowler.types import Leaf
|
||||
|
||||
# This came about because vulture (actually dead, from the list of Similar programs at https://pypi.org/project/vulture/)
|
||||
# actually found unused stuff, and I wanted to remove it.
|
||||
# See also https://github.com/craigds/decrapify
|
||||
|
||||
def remove_function(filename: str, function_name: str) -> None:
|
||||
|
||||
def remove_statement(node, capture, filename):
|
||||
node.remove()
|
||||
|
||||
bowler_query = (Query(filename)
|
||||
.select_function(function_name)
|
||||
.modify(remove_statement)
|
||||
.execute(write=True, silent=True, interactive=False))
|
||||
|
||||
if len(bowler_query.exceptions) > 0:
|
||||
print(f"Failed to remove function {function_name} from {filename}.")
|
||||
raise Exception(bowler_query.exceptions[0])
|
||||
|
||||
print(f"Function {function_name} successfully removed from {filename}.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser(description="Remove a function from a Python file while preserving comments.")
|
||||
parser.add_argument("filename", help="the file to modify")
|
||||
parser.add_argument("function_name", help="the name of the function to remove")
|
||||
args = parser.parse_args()
|
||||
|
||||
remove_function(args.filename, args.function_name)
|
|
@ -11,17 +11,6 @@ from spiffworkflow_backend.services.process_instance_processor import (
|
|||
from spiffworkflow_backend.services.process_instance_service import (
|
||||
ProcessInstanceService,
|
||||
)
|
||||
|
||||
|
||||
def print_process_instance_count(process_model_identifier_ticket: str) -> None:
|
||||
"""Print process instance count."""
|
||||
process_instances = ProcessInstanceModel.query.filter_by(
|
||||
process_model_identifier=process_model_identifier_ticket
|
||||
).all()
|
||||
process_instance_count = len(process_instances)
|
||||
print(f"process_instance_count: {process_instance_count}")
|
||||
|
||||
|
||||
def main():
|
||||
"""Main."""
|
||||
app = get_hacked_up_app_for_script()
|
||||
|
|
|
@ -91,6 +91,13 @@ class ServiceTaskDelegate:
|
|||
json_parse_error = e
|
||||
parsed_response = {}
|
||||
|
||||
if "spiff__logs" in parsed_response:
|
||||
for log in parsed_response["spiff__logs"]:
|
||||
current_app.logger.info(f"Log from connector {name}: {log}")
|
||||
if "api_response" in parsed_response:
|
||||
parsed_response = parsed_response["api_response"]
|
||||
response_text = json.dumps(parsed_response)
|
||||
|
||||
if proxied_response.status_code >= 300:
|
||||
message = ServiceTaskDelegate.get_message_for_status(proxied_response.status_code)
|
||||
error = f"Received an unexpected response from service {name} : {message}"
|
||||
|
|
Loading…
Reference in New Issue