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 handling and output in some scripts could use tweaking: get_lastRun, get_curr_exp, ... #98

Open
klauer opened this issue Jan 28, 2022 · 0 comments

Comments

@klauer
Copy link
Contributor

klauer commented Jan 28, 2022

Expected Behavior

  • If a hutch can't be determined or an experiment can't be found (for example), return a fixed value without error messages to the user
  • Wrapping these scripts with Python code is common and really should never fail, and should be usable on machines more typically used for testing

Current Behavior

As we were trying to make filenames for gige cameras to save to by way of hutch + experiment name + run number, we ran into the following:

[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_lastRun
ERROR:__main__:No runs?
Traceback (most recent call last):
  File "/reg/g/pcds/engineering_tools/R2.0.1/scripts/get_info", line 164, in <module>
    exp = resp.json().get("value", {}).get("name")
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
No runs taken yet
[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_hutch_name
lfe
[klauer@lfe-console  ~]$ /reg/g/pcds/engineering_tools/lfe/scripts/get_curr_exp
Traceback (most recent call last):
  File "/reg/g/pcds/engineering_tools/R2.0.1/scripts/get_info", line 158, in <module>
    exp = resp.json().get("value", {}).get("name")
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/reg/g/pcds/pyps/conda/py36/envs/pcds-3.4.0/lib/python3.6/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
/reg/g/pcds/engineering_tools/lfe/scripts/get_curr_exp: line 43: [: ==: unary operator expected
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

1 participant