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

Foscam Camera: Adding exception handling when fetching the camera image to avoid python exception errors when host is not reachable or rather any url error to camera #6964

Merged
merged 3 commits into from
Apr 7, 2017

Conversation

viswa-swami
Copy link
Contributor

@viswa-swami viswa-swami commented Apr 6, 2017

Description:

Added exception handling for the requests.get call in the foscam camera component. Earlier code was just trying to get the image from the camera url directly and without checking for response validity, just returns the response back to the parent caller. This caused the requests.get() to fail when host is not reachable. Added the exception handling around the requests.get() call.

Related issue (if applicable): fixes #6962

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

…hon errors when host is not reachable or any url errors to camera
@mention-bot
Copy link

@viswa-swami, thanks for your PR! By analyzing the history of the files in this pull request, we identified @heathbar, @fabaff and @balloob to be potential reviewers.

@homeassistant
Copy link
Contributor

Hi @viswa-swami,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@pvizeli
Copy link
Member

pvizeli commented Apr 6, 2017

I think you should add a logging.waring to info the user that we "lost" a picture.

@viswa-swami
Copy link
Contributor Author

viswa-swami commented Apr 6, 2017 via email

@viswa-swami
Copy link
Contributor Author

Moreover, one use case is that, the camera could potentially be off when the user is at home for privacy reasons, and will only be armed when user is away. So, during the entire period when camera is off, communication will fail, during which time, log will again be filled with this 'lost a picture' message.

@balloob balloob merged commit 9254e7e into home-assistant:dev Apr 7, 2017
@balloob balloob added this to the 0.42 milestone Apr 7, 2017
balloob pushed a commit that referenced this pull request Apr 8, 2017
…ge to avoid python exception errors when host is not reachable or rather any url error to camera (#6964)

* Adding exception handling when fetching the camera image to avoid python errors when host is not reachable or any url errors to camera

* Added exception as ConnectionError instead of plain except

* Added exception as ConnectionError instead of plain except. Removed the unused error handle
@balloob
Copy link
Member

balloob commented Apr 8, 2017

Cherry-picked into the 0.42 branch

@fabaff fabaff mentioned this pull request Apr 8, 2017
@viswa-swami
Copy link
Contributor Author

viswa-swami commented Apr 8, 2017 via email

@balloob balloob mentioned this pull request Apr 21, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Foscam IP Camera is continuously returning python errors when IP Camera is not available
6 participants