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

Source of the "ValueError: too many values to unpack (expected 2)" error #604

Open
fergusL opened this issue Sep 4, 2023 · 0 comments
Open
Labels

Comments

@fergusL
Copy link
Contributor

fergusL commented Sep 4, 2023

This error keeps popping up sporadically and I have confirmed that is a resulting from some form of error from TheSkyX and a parsing error in panoptes.pocs.utils.theskyx. What is going on is as follows:

pocs issues a command via TheSkyX which fails in some way and returns a response

In [4]: pocs.observatory.dome.unpark()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], line 1
----> 1 pocs.observatory.dome.unpark()

File /opt/conda/lib/python3.10/site-packages/huntsman/pocs/dome/musca.py:266, in HuntsmanDome.unpark(self, timeout)
    264 while not timer.expired():
    265     try:
--> 266         response = self.read()
    267     except TheSkyXTimeout:
    268         continue

File /opt/conda/lib/python3.10/site-packages/panoptes/pocs/dome/bisque.py:156, in Dome.read(self, timeout)
    154 def read(self, timeout=5):
    155     while True:
--> 156         response = self.theskyx.read()
    157         if response is not None or timeout == 0:
    158             break

File /opt/conda/lib/python3.10/site-packages/panoptes/pocs/utils/theskyx.py:62, in TheSkyX.read(self, timeout)
     59     response, err = response.split('|')
     61 if 'Error:' in response:
---> 62     response, err = response.split(':')
     64 if err is not None and 'No error' not in err:
     65     if 'Error = 303' in err:

ValueError: too many values to unpack (expected 2)

If we capture the response object returned from TheSkyX we can see what is going wrong:

In [13]: dome.write(dome._get_command('dome/unpark.js'))

In [14]: response = dome.theskyx.socket.recv(2048).decode()

In [15]: response
Out[15]: 'TypeError: Error: command failed. Error = 206.|No error. Error = 0.'

In [16]: response, err = response.split('|')

In [17]: response
Out[17]: 'TypeError: Error: command failed. Error = 206.'

In [18]: response, err = response.split(':')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[18], line 1
----> 1 response, err = response.split(':')

ValueError: too many values to unpack (expected 2)

So the panoptes.pocs.utils.theskyx.read() assumes there will only ever be one ":" character in the response string, so when it splits on this response it creates three strings instead of two.

This presents a bit of annoying problem as we have frozen ours pocs version so we can't just submit a PR to POCS....

@fergusL fergusL added the bug label Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant