forked from awslabs/damo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
damo_features.py
39 lines (32 loc) · 1.18 KB
/
damo_features.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# SPDX-License-Identifier: GPL-2.0
import json
import _damon
import _damon_args
def set_argparser(parser):
parser.add_argument('type', nargs='?',
choices=['supported', 'unsupported', 'all', 'json'], default='all',
help='type of features to listed')
_damon_args.set_common_argparser(parser)
def main(args=None):
if not args:
parser = argparse.ArgumentParser()
set_argparser(parser)
args = parser.parse_args()
_damon.ensure_root_and_initialized(args)
feature_supports, err = _damon.get_feature_supports()
if err != None:
print('getting feature supports info failed (%s)' % err)
exit(1)
for feature in sorted(feature_supports.keys()):
supported = feature_supports[feature]
if args.type == 'all':
print('%s: %s' % (feature,
'Supported' if supported else 'Unsupported'))
elif args.type == 'supported' and supported:
print(feature)
elif args.type == 'unsupported' and not supported:
print(feature)
if args.type == 'json':
print(json.dumps(feature_supports, indent=4, sort_keys=True))
if __name__ == '__main__':
main()