sdague / amt

Python tools for interacting with Intel's AMT hardware control interfaces
Apache License 2.0
65 stars 30 forks source link

http status codes not handled #15

Closed Rixillo closed 7 years ago

Rixillo commented 7 years ago

"amtctrl status" crashes with stack dump when it receives an http status code of 401 - Unauthorized.

I find the error handler in client.py, line 97:

        if resp.status_code == 200:
...
        else:
            print("Status: %s" % resp.status_code)
            print(pp_xml(resp.content))
            return 1

but seems it is not catching

Traceback (most recent call last):
  File "/usr/bin/amtctrl", line 5, in <module>
    pkg_resources.run_script('amt==0.6.0', 'amtctrl')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1455, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 114, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/EGG-INFO/scripts/amtctrl", line 102, in main
    print(amt.wsman.friendly_power_state(client.power_status()))
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 145, in power_status
    "PowerState")
  File "/usr/lib/python2.7/site-packages/amt-0.6.0-py2.7.egg/amt/client.py", line 171, in _find_value
    doc = ElementTree.fromstring(content)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1300, in XML
    parser.feed(text)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: syntax error: line 1, column 63
sdague commented 7 years ago

I think this is fixed with https://github.com/sdague/amt/commit/2f82054c2a6ab721655f9d5c3670738d4a56801b

sdague commented 7 years ago

if not, reopen the issue.

Rixillo commented 7 years ago

OK now. Thanks for fixing.