forked from UAVLab-SLU/DRV_public
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 167 HTML file Support #171
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -154,79 +154,65 @@ def process_gcs_directory(prefix, result, fuzzy_path_value): | |
Processes blobs in a GCS directory and populates the result dictionary. | ||
""" | ||
blobs = bucket.list_blobs(prefix=prefix) | ||
|
||
def extract_fuzzy_value(fuzzy_path): | ||
return fuzzy_path.split("_")[-1] if fuzzy_path else "" | ||
|
||
def classify_and_append(blob_name, file_data): | ||
for monitor_type in result.keys(): | ||
if monitor_type in blob_name: | ||
result[monitor_type].append(file_data) | ||
break | ||
|
||
for blob in blobs: | ||
file_name = os.path.basename(blob.name) | ||
if blob.name.endswith('.txt'): | ||
# Download the text content | ||
file_contents = blob.download_as_text() | ||
|
||
info_content = get_info_contents(file_contents, "INFO", {}) | ||
pass_content = get_info_contents(file_contents, "PASS", {}) | ||
fail_content = get_info_contents(file_contents, "FAIL", {}) | ||
fuzzy_value = extract_fuzzy_value(fuzzy_path_value) | ||
|
||
if blob.name.endswith('.html'): | ||
# Generate a public URL for the HTML file | ||
html_url = blob.public_url | ||
|
||
file_data = { | ||
"name": file_name, | ||
"type": "text/plain", | ||
"type": "text/html", | ||
"fuzzyPath": fuzzy_path_value, | ||
"fuzzyValue": fuzzy_path_value.split("_")[-1] if fuzzy_path_value else "", | ||
"content": file_contents, | ||
"infoContent": info_content, | ||
"passContent": pass_content, | ||
"failContent": fail_content | ||
"fuzzyValue": fuzzy_value, | ||
"content": html_url, | ||
"infoContent": get_info_contents(html_url, "INFO", {}), | ||
"passContent": get_info_contents(html_url, "PASS", {}), | ||
"failContent": get_info_contents(html_url, "FAIL", {}) | ||
} | ||
classify_and_append(blob.name, file_data) | ||
|
||
# Determine the monitor type and append the file data | ||
if "UnorderedWaypointMonitor" in blob.name: | ||
result["UnorderedWaypointMonitor"].append(file_data) | ||
elif "CircularDeviationMonitor" in blob.name: | ||
result["CircularDeviationMonitor"].append(file_data) | ||
elif "CollisionMonitor" in blob.name: | ||
result["CollisionMonitor"].append(file_data) | ||
elif "LandspaceMonitor" in blob.name: | ||
result["LandspaceMonitor"].append(file_data) | ||
elif "OrderedWaypointMonitor" in blob.name: | ||
result["OrderedWaypointMonitor"].append(file_data) | ||
elif "PointDeviationMonitor" in blob.name: | ||
result["PointDeviationMonitor"].append(file_data) | ||
elif "MinSepDistMonitor" in blob.name: | ||
result["MinSepDistMonitor"].append(file_data) | ||
elif "NoFlyZoneMonitor" in blob.name: | ||
result["NoFlyZoneMonitor"].append(file_data) | ||
elif blob.name.endswith('.txt'): | ||
file_contents = blob.download_as_text() | ||
|
||
file_data = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. repeat of above, some way to reduce code repition |
||
"name": file_name, | ||
"type": "text/plain", | ||
"fuzzyPath": fuzzy_path_value, | ||
"fuzzyValue": fuzzy_value, | ||
"content": file_contents, | ||
"infoContent": get_info_contents(html_url, "INFO", {}), | ||
"passContent": get_info_contents(html_url, "PASS", {}), | ||
"failContent": get_info_contents(html_url, "FAIL", {}) | ||
} | ||
classify_and_append(blob.name, file_data) | ||
|
||
elif blob.name.endswith('.png'): | ||
# Download and encode the image in base64 | ||
image_content = blob.download_as_bytes() | ||
encoded_string = base64.b64encode(image_content).decode('utf-8') | ||
|
||
# Assume corresponding HTML exists | ||
html_path = blob.name.replace("_plot.png", "_interactive.html") | ||
|
||
file_data = { | ||
"name": file_name, | ||
"type": "image/png", | ||
"fuzzyPath": fuzzy_path_value, | ||
"fuzzyValue": fuzzy_path_value.split("_")[-1] if fuzzy_path_value else "", | ||
"fuzzyValue": fuzzy_value, | ||
"imgContent": encoded_string, | ||
"path": html_path | ||
} | ||
|
||
# Determine the monitor type and append the file data | ||
if "UnorderedWaypointMonitor" in blob.name: | ||
result["UnorderedWaypointMonitor"].append(file_data) | ||
elif "CircularDeviationMonitor" in blob.name: | ||
result["CircularDeviationMonitor"].append(file_data) | ||
elif "CollisionMonitor" in blob.name: | ||
result["CollisionMonitor"].append(file_data) | ||
elif "LandspaceMonitor" in blob.name: | ||
result["LandspaceMonitor"].append(file_data) | ||
elif "OrderedWaypointMonitor" in blob.name: | ||
result["OrderedWaypointMonitor"].append(file_data) | ||
elif "PointDeviationMonitor" in blob.name: | ||
result["PointDeviationMonitor"].append(file_data) | ||
elif "MinSepDistMonitor" in blob.name: | ||
result["MinSepDistMonitor"].append(file_data) | ||
elif "NoFlyZoneMonitor" in blob.name: | ||
result["NoFlyZoneMonitor"].append(file_data) | ||
classify_and_append(blob.name, file_data) | ||
|
||
def get_info_contents(file_contents, keyword, drone_map): | ||
""" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe change this to case switch/ pattern matching to make more readable