Skip to content
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

Error message when access is done with wrong password #12

Closed
SmartC2016 opened this issue Nov 17, 2019 · 7 comments
Closed

Error message when access is done with wrong password #12

SmartC2016 opened this issue Nov 17, 2019 · 7 comments

Comments

@SmartC2016
Copy link
Contributor

SmartC2016 commented Nov 17, 2019

When I try:

fc = fritzconnection.FritzConnection(address='192.168.90.1', password='wrong_password')
fc.call_action('WLANConfiguration', 'GetInfo')

I get a trace back error:


 /home/heti/Development/fritzconnection/fritzconnection/core/soaper.py(53)raise_fritzconnection_error()
-> root = etree.fromstring(response.content)
(Pdb) l
 48  	    Will raise a FritzConnectionException or a subclass.
 49  	    """
 50  	    parts = []
 51  	    error_code = None
 52  	    import pdb;pdb.set_trace()
 53  ->	    root = etree.fromstring(response.content)
 54  	    detail = root.find('.//detail')
 55  	    for node in detail.iterdescendants():
 56  	        tag = node.tag.split('}')[-1]
 57  	        text = node.text.strip()
 58  	        if tag == 'errorCode':
(Pdb) p response.content
b'<HTML><HEAD><TITLE>401 Unauthorized (ERR_NONE)</TITLE></HEAD><BODY><H1>401 Unauthorized</H1><BR>ERR_NONE<HR><B>Webserver</B> Sun, 17 Nov 2019 10:17:47 GMT</BODY></HTML>\r\n'
(Pdb) c

Traceback (most recent call last):

File "/home/heti/.local/share/virtualenvs/fritzconnection-ehIjW6m7/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3326, in run_code
  exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-5-5cee539ecdc0>", line 1, in <module>
  fc.call_action('WLANConfiguration', 'GetInfo')

File "/home/heti/Development/fritzconnection/fritzconnection/core/fritzconnection.py", line 124, in call_action
  return self.soaper.execute(service, action_name, arguments)

File "/home/heti/Development/fritzconnection/fritzconnection/core/soaper.py", line 140, in execute
  raise_fritzconnection_error(response)

File "/home/heti/Development/fritzconnection/fritzconnection/core/soaper.py", line 53, in raise_fritzconnection_error
  root = etree.fromstring(response.content)

File "src/lxml/etree.pyx", line 3222, in lxml.etree.fromstring

File "src/lxml/parser.pxi", line 1877, in lxml.etree._parseMemoryDocument

File "src/lxml/parser.pxi", line 1765, in lxml.etree._parseDoc

File "src/lxml/parser.pxi", line 1127, in lxml.etree._BaseParser._parseDoc

File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc

File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult

File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError

File "<string>", line 1
XMLSyntaxError: Opening and ending tag mismatch: HR line 1 and BODY, line 1, column 162

@kbr
Copy link
Owner

kbr commented Nov 17, 2019

Will check this next weekend when I have access to the hardware.

@Themanwithoutaplan
Copy link
Contributor

I can't replicate that error on the 1.0 branch but I do have trouble connecting even with the correct password from the CLI

fritzconnection charlieclark$ fritzconnection -i fritz.box -p pw

FritzConnection v1.0a1
Traceback (most recent call last):
  File "/Users/charlieclark/Projects/fritzconnection/bin/fritzconnection", line 11, in <module>
    load_entry_point('fritzconnection', 'console_scripts', 'fritzconnection')()
  File "/Users/charlieclark/Projects/fritzconnection/fritzconnection/cli/fritzinspection.py", line 139, in main
    inspector.view_header()
  File "/Users/charlieclark/Projects/fritzconnection/fritzconnection/cli/fritzinspection.py", line 35, in view_header
    print(self.fc)
  File "/Users/charlieclark/Projects/fritzconnection/fritzconnection/core/fritzconnection.py", line 77, in __repr__
    return f'{self.device_manager.modelname} at ip {self.soaper.address}'
  File "/Users/charlieclark/Projects/fritzconnection/fritzconnection/core/devices.py", line 33, in modelname
    return self.descriptions[0].device_model_name
IndexError: list index out of range

@Themanwithoutaplan
Copy link
Contributor

On the same system, in Python itself I can usually connect but get a different exception.

fc.call_action('WLANConfiguration1', 'GetInfo')
Traceback (most recent call last):
  Python Shell, prompt 7, line 121
builtins.KeyError: 'WLANConfiguration1'

During handling of the above exception, another exception was raised:

Traceback (most recent call last):
  Python Shell, prompt 7, line 1
    # Used internally for debug sandbox under external interpreter
  File "/Users/charlieclark/Projects/fritzconnection/fritzconnection/core/fritzconnection.py", line 123, in call_action
    raise FritzServiceError(f'unknown service: "{service_name}"')
fritzconnection.core.exceptions.FritzServiceError: unknown service: "WLANConfiguration1"

@kbr
Copy link
Owner

kbr commented Nov 17, 2019

Seems the box is unable to read the description files. May be a side effect of removing lxml. I can go to this by end of the week. Sorry, no sooner. Should set up a VPN then.

@kbr
Copy link
Owner

kbr commented Nov 18, 2019

I suppose I found it – at least in theory: the documentation of DeviceManager.add_description is misleading. The parameter source is not the xml-source but the url where to retrieve the source from the box. lxml can handle this, but ElementTree from the stdlib can't. So this should be fixed in __init__ of FritzConnection to send the sources to add_description and not the url.

This and Christians topic are two different issues.

@Themanwithoutaplan
Copy link
Contributor

Agreed. I think there are two separate additional issues: the transient one relating to model name (I've had this in the CLI and in the Python shell) and the service description thingy. I'll create some tickets and see if I can run some low level tests for more meaningful data.
@SmartC2016 can you add the model number to your description?

@kbr
Copy link
Owner

kbr commented Dec 15, 2019

There have been some subtle issues left in error raising. Is fixed now by 21499f7

@kbr kbr closed this as completed Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants