在GCE实例上运行gcloud info --format json
时,我得到以下异常:
% gcloud info --format json
Traceback (most recent call last):
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 175, in <module>
main()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 171, in main
_cli.Execute()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 385, in Execute
post_run_hooks=self.__post_run_hooks, kwargs=kwargs)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/frontend.py", line 274, in _Execute
pre_run_hooks=pre_run_hooks, post_run_hooks=post_run_hooks)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 930, in Run
output_formatter(result)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 922, in Format
resource_printer.Print(obj, args.format or 'yaml', out=log.out)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/core/util/resource_printer.py", line 421, in Print
formatter.PrintSingleRecord(resources)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/core/util/resource_printer.py", line 88, in PrintSingleRecord
separators=(',', ': '))
File "/home/Tradelab/anaconda/lib/python2.7/json/__init__.py", line 189, in dump
for chunk in iterable:
File "/home/Tradelab/anaconda/lib/python2.7/json/encoder.py", line 442, in _iterencode
o = _default(o)
File "/home/Tradelab/anaconda/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <__calliope__command__.93a535615504421c846125f4c0a6cb7e.gcloud.info.InfoHolder object at 0x7f70752ad950> is not JSON serializable
我可以通过编辑resource-printer.py
来避免这种情况,但我正在寻找更清晰的解决方案。