GCP-XXXX: Split Script Across Multiple Files #34
Merged
Conversation
tedkahwaji
commented
Oct 10, 2025
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| signal.signal(signal.SIGINT, lambda _, __: sys.exit(0)) |
Collaborator
Author
There was a problem hiding this comment.
Handles SigTerm gracefully
There was a problem hiding this comment.
Consider adding a SIGINT handler, something like:
def sigint_handler(signal, frame):
print("Script terminating.")
sys.exit(0)
....
if __name__ == "__main__":
signal.signal(signal.SIGINT, lambda _, __: sigint_handler))
main()
dtru-ddog
reviewed
Oct 10, 2025
| ensure_login() | ||
| except Exception as e: | ||
| if "gcloud: command not found" in str(e): | ||
| print("You must install the GCloud CLI and log in to run this script.") |
There was a problem hiding this comment.
nit: would add link to guide users to install via Google's guide
Suggested change
| print("You must install the GCloud CLI and log in to run this script.") | |
| print("You must install the GCloud CLI and log in to run this script.\nhttps://cloud.google.com/sdk/docs/install") |
21fe680 to
8bb9a47
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This change refactors the single-file script into a modular structure, splitting it across multiple files for better organization and maintainability. All components are now bundled into a single
.pyzexecutable:gcp_integration_quickstart.pyz.What's new:
Modular structure
The codebase has been split into multiple files and directories while preserving functionality. This improves readability, testing, and future extensibility.
Executable
.pyzarchiveThe project is now packaged as a
.pyz(Python executable zip), allowing it to be distributed and run as a single file:Gcloud CLI check
The script now explicitly checks for the presence of the Google Cloud CLI and informs the user if it is not installed.
Graceful shutdown on SIGTERM
Tracebacks are now suppressed when the script receives a SIGTERM signal