-
Notifications
You must be signed in to change notification settings - Fork 97
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
Improve visualization branch + Feature comparing #50
Open
kntrain
wants to merge
45
commits into
JohannesEbke:master
Choose a base branch
from
kntrain:feature_comparing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
74c794c
Bring Python to 3.9 in Travis
gliptak 1a5e53a
Merge pull request #44 from gliptak/patch-2
JohannesEbke 5ab67b4
-boto3 update and recreate caches
kntrain 976688e
-updated boto3
kntrain 8c300df
Merge pull request #46 from kntrain/boto3-update-1.16.21
JohannesEbke 67defae
-added additional show options
kntrain faec31c
-moved modifications in resources to filter class
kntrain 889c555
-fixed restructuring issues
kntrain d7a4a21
-removed call to file-reference filter in listing
kntrain 2f65155
recreate_caches: Only accept "Host not found" as error, also Warn if …
JohannesEbke 6d8fcc7
Upgrade to boto3 1.16.57
JohannesEbke e4a37de
Add heuristic for new host prefixes and recreate caches
JohannesEbke 173a70b
Fix up tests
JohannesEbke 80c4c8c
Yapf
JohannesEbke f2d06fc
-renamed Listing -> RawListing
kntrain 65a4788
changed fixing_filters to always apply
kntrain 3199531
- new feature branch for visual improvements
kntrain a7016d5
- added html search feature
kntrain 06537d5
- fixed changing column width
kntrain 63df2d0
- fixed dynamically changing count number
kntrain 1076f6b
- upgraded html style
kntrain b5a8b61
- added finish time to html
kntrain c92bb38
- added handling in case special ops are specified
kntrain 5d120bb
- removed empty line
kntrain 8e40189
- added unfilter options description
kntrain 1ea97ae
Create HTML header and footer
kntrain a6c788f
Add comparing feature to available commands
kntrain 9753209
Fix dependent ops and show command flags Bugs
kntrain 5855f94
Implement compare command between 2 directories
kntrain ec3fa8e
Move html related code to generate-html.py
kntrain 4c05e52
Restructure to get resource ID during query
kntrain aefb2a5
Remove stray comment and unfilter-list conversion
kntrain 3d0565f
Add error-handling to JSON-file dependent function
kntrain dbe60a7
Adopt suggestions from errorhandle-branch
kntrain 7e2cde7
Fix wrong do_list_files behaviour for errors
kntrain 2055571
Add ResultListing as return Obj of acquire_listing
kntrain 436a66c
Enhance visualization-feature
kntrain 02b15a9
Fix comparing algorithm bug
kntrain 5f4e644
Merge pull request #49 from kntrain/improve-errorhandle
JohannesEbke e7b75a4
Do minor restrcuturing in main and generate_html
kntrain 5d92c58
Incorporate print-html into new command 'view'
kntrain 320f99e
Incorporate html+compare option into show command
kntrain 7b26c47
Fix html-file save location
kntrain e5d169f
Change creation and generating of html-content
kntrain eec28a0
Merge branch 'master' into feature_comparing
kntrain 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
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 |
---|---|---|
|
@@ -2,14 +2,17 @@ | |
from __future__ import print_function | ||
|
||
import os | ||
import sys | ||
import webbrowser | ||
from resource import getrlimit, setrlimit, RLIMIT_NOFILE | ||
from argparse import ArgumentParser | ||
from sys import exit, stderr | ||
|
||
from .generate_html import before_content, after_content | ||
from .introspection import ( | ||
get_listing_operations, get_services, get_verbs, introspect_regions_for_service, recreate_caches | ||
) | ||
from .query import do_list_files, do_query | ||
from .query import do_list_files, do_query, print_query, compare_list_files | ||
|
||
|
||
def increase_limit_nofiles(): | ||
|
@@ -72,6 +75,12 @@ def main(): | |
action='append', | ||
help='Restrict querying to the given operation (can be specified multiple times)' | ||
) | ||
query.add_argument( | ||
'-u', | ||
'--unfilter', | ||
action='append', | ||
help='Exclude given default-value filter from being applied (can be specified multiple times)' | ||
) | ||
query.add_argument('-p', '--parallel', default=32, type=int, help='Number of request to do in parallel') | ||
query.add_argument('-d', '--directory', default='.', help='Directory to save result listings to') | ||
query.add_argument('-v', '--verbose', action='count', help='Print detailed info during run') | ||
|
@@ -83,6 +92,15 @@ def main(): | |
) | ||
show.add_argument('listingfile', nargs='*', help='listing file(s) to load and print') | ||
show.add_argument('-v', '--verbose', action='count', help='print given listing files with detailed info') | ||
show.add_argument('-n', '--not_found', default=False, action='store_true', help='additionally print listing files of resources not found') | ||
show.add_argument('-e', '--errors', default=False, action='store_true', help='additionally print listing files of resources where queries resulted in errors') | ||
show.add_argument('-d', '--denied', default=False, action='store_true', help='additionally print listing files of resources with "missing permission" errors') | ||
show.add_argument( | ||
'-u', | ||
'--unfilter', | ||
action='append', | ||
help='Exclude given default-value filter from being applied (can be specified multiple times)' | ||
) | ||
|
||
# Introspection debugging is not the main function. So we put it all into a subcommand. | ||
introspect = subparsers.add_parser( | ||
|
@@ -119,6 +137,47 @@ def main(): | |
) | ||
introspecters.add_parser('debug', description='Debug information', help='Debug information') | ||
|
||
# Print the findings from query to an HTML file to be viewed in a browser | ||
viewhtml = subparsers.add_parser( | ||
'print-html', description='Print a listing to an HTML file to be viewed in a browser', | ||
help='Create browser view of listing' | ||
) | ||
viewhtml.add_argument( | ||
'-s', | ||
'--service', | ||
action='append', | ||
help='Restrict querying to the given service (can be specified multiple times)' | ||
) | ||
viewhtml.add_argument( | ||
'-r', | ||
'--region', | ||
action='append', | ||
help='Restrict querying to the given region (can be specified multiple times)' | ||
) | ||
viewhtml.add_argument( | ||
'-o', | ||
'--operation', | ||
action='append', | ||
help='Restrict querying to the given operation (can be specified multiple times)' | ||
) | ||
viewhtml.add_argument( | ||
'-u', | ||
'--unfilter', | ||
action='append', | ||
help='Exclude given default-value filter from being applied (can be specified multiple times)' | ||
) | ||
viewhtml.add_argument('-p', '--parallel', default=32, type=int, help='Number of request to do in parallel') | ||
viewhtml.add_argument('-d', '--directory', default='.', help='Directory to save result listings to') | ||
viewhtml.add_argument('-v', '--verbose', action='count', help='Print detailed info during run') | ||
viewhtml.add_argument('-c', '--profile', help='Use a specific .aws/credentials profile.') | ||
|
||
# Visually compare and display the differences in listings from two directories | ||
compare = subparsers.add_parser( | ||
'compare', description='Compare listings from two different directories', help='Compare saved listings' | ||
) | ||
compare.add_argument('-b', '--basedir', nargs='*', default='.', help='Listing file(s) used as comparison base') | ||
compare.add_argument('-m', '--moddir', nargs='*', default='.', help='Listing file(s) to be compared') | ||
|
||
# Finally, refreshing the service/region caches comes last. | ||
caches = subparsers.add_parser( | ||
'recreate-caches', | ||
|
@@ -156,12 +215,20 @@ def main(): | |
args.operation, | ||
verbose=args.verbose or 0, | ||
parallel=args.parallel, | ||
selected_profile=args.profile | ||
selected_profile=args.profile, | ||
unfilter=args.unfilter | ||
) | ||
elif args.command == 'show': | ||
if args.listingfile: | ||
increase_limit_nofiles() | ||
do_list_files(args.listingfile, verbose=args.verbose or 0) | ||
do_list_files( | ||
args.listingfile, | ||
verbose=args.verbose or 0, | ||
not_found=args.not_found, | ||
errors=args.errors, | ||
denied=args.denied, | ||
unfilter=args.unfilter | ||
) | ||
else: | ||
show.print_help() | ||
return 1 | ||
|
@@ -183,6 +250,45 @@ def main(): | |
else: | ||
introspect.print_help() | ||
return 1 | ||
elif args.command == 'print-html': | ||
origout = before_content('test.html') | ||
if args.directory: | ||
try: | ||
os.makedirs(args.directory) | ||
except OSError: | ||
pass | ||
os.chdir(args.directory) | ||
increase_limit_nofiles() | ||
services = args.service or get_services() | ||
print_query( | ||
services, | ||
args.region, | ||
args.operation, | ||
verbose=args.verbose or 0, | ||
parallel=args.parallel, | ||
selected_profile=args.profile, | ||
unfilter=args.unfilter | ||
) | ||
after_content(origout) | ||
|
||
new = 2 | ||
path_up = os.path.dirname(os.getcwd()) | ||
os.chdir(path_up) | ||
url = os.getcwd() + "/test.html" | ||
webbrowser.open(url,new=new) | ||
elif args.command == 'compare': | ||
origout = before_content('compare.html') | ||
if args.basedir and args.moddir: | ||
increase_limit_nofiles() | ||
compare_list_files( | ||
args.basedir, | ||
args.moddir | ||
) | ||
after_content(origout) | ||
|
||
new = 2 | ||
url = os.getcwd() + "/compare.html" | ||
webbrowser.open(url,new=new) | ||
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. This section should go into its own module |
||
elif args.command == 'recreate-caches': | ||
increase_limit_nofiles() | ||
recreate_caches(args.update_packaged_values) | ||
|
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,152 @@ | ||
import json | ||
import os | ||
import sys | ||
|
||
from .fixing_filter import * | ||
from .resource_filter import * | ||
|
||
def apply_filters(listing, unfilterList, response, complete): | ||
"""Apply filters for operations to be handled in a special way or | ||
to remove default resources from the response""" | ||
apply_complete = complete | ||
|
||
if not('cloudfront' in unfilterList): | ||
filter = CloudfrontFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('medialive' in unfilterList): | ||
filter = MedialiveFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ssmListCommands' in unfilterList): | ||
filter = SSMListCommandsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('snsListSubscriptions' in unfilterList): | ||
filter = SNSListSubscriptionsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('athenaWorkGroups' in unfilterList): | ||
filter = AthenaWorkGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('listEventBuses' in unfilterList): | ||
filter = ListEventBusesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('xRayGroups' in unfilterList): | ||
filter = XRayGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('route53Resolver' in unfilterList): | ||
filter = Route53ResolverFilter() | ||
filter.execute(listing, response) | ||
|
||
filter = CountFilter(apply_complete) | ||
filter.execute(listing, response) | ||
apply_complete = filter.complete | ||
|
||
filter = QuantityFilter(apply_complete) | ||
filter.execute(listing, response) | ||
apply_complete = filter.complete | ||
|
||
filter = NeutralThingFilter() | ||
filter.execute(listing, response) | ||
|
||
filter = BadThingFilter(apply_complete) | ||
filter.execute(listing, response) | ||
apply_complete = filter.complete | ||
|
||
if not('kmsListAliases' in unfilterList): | ||
filter = KMSListAliasesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('appstreamImages' in unfilterList): | ||
filter = AppstreamImagesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('cloudsearch' in unfilterList): | ||
filter = CloudsearchFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('cloudTrail' in unfilterList): | ||
filter = CloudTrailFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('cloudWatch' in unfilterList): | ||
filter = CloudWatchFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('iamPolicies' in unfilterList): | ||
filter = IAMPoliciesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('s3Owner' in unfilterList): | ||
filter = S3OwnerFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ecsClustersFailure' in unfilterList): | ||
filter = ECSClustersFailureFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('pinpointGetApps' in unfilterList): | ||
filter = PinpointGetAppsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ssmBaselines' in unfilterList): | ||
filter = SSMBaselinesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('dbSecurityGroups' in unfilterList): | ||
filter = DBSecurityGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('dbParameterGroups' in unfilterList): | ||
filter = DBParameterGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('dbClusterParameterGroups' in unfilterList): | ||
filter = DBClusterParameterGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('dbOptionGroups' in unfilterList): | ||
filter = DBOptionGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2VPC' in unfilterList): | ||
filter = EC2VPCFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2Subnets' in unfilterList): | ||
filter = EC2SubnetsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2SecurityGroups' in unfilterList): | ||
filter = EC2SecurityGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2RouteTables' in unfilterList): | ||
filter = EC2RouteTablesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2NetworkAcls' in unfilterList): | ||
filter = EC2NetworkAclsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('ec2FpgaImages' in unfilterList): | ||
filter = EC2FpgaImagesFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('workmailDeletedOrganizations' in unfilterList): | ||
filter = WorkmailDeletedOrganizationsFilter() | ||
filter.execute(listing, response) | ||
|
||
if not('elasticacheSubnetGroups' in unfilterList): | ||
filter = ElasticacheSubnetGroupsFilter() | ||
filter.execute(listing, response) | ||
|
||
filter = NextTokenFilter(apply_complete) | ||
filter.execute(listing, response) | ||
apply_complete = getattr(filter, 'complete') | ||
|
||
return apply_complete |
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.
Shouldn't viewhtml be more similar to "show"? This looks like it's doing all the querying again.