richard-better / pushbullet.py

A python client for http://pushbullet.com
MIT License
575 stars 110 forks source link

Add on_error callback support #85

Closed kiike closed 8 years ago

kiike commented 8 years ago

This PR adds basic support for handling errors for websockets-client listener. Without it no exception was raised on, say, KeyboardInterrupt and I wanted to handle them in order to clean up.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.7%) to 54.756% when pulling 1c88aeee2fbc8d4df6b529812ff347426b252d1c on kiike:pr-add_on_error_handler into b6cd31db657dbebdcd6955d354fda1e709cb8740 on randomchars:master.

kiike commented 8 years ago

As for the integration issues: i see that there's a call to str.decode() even though it's not needed. I think it's safe to drop it: i get a UTF-8 string on both Python 2.7 and Python 3.5.

kiike commented 8 years ago

These travis errors would make it look like there's an unnecessary .decode(). Removing it from test_filetype.py make the tests pass again:

(.pyvenv2) pushbullet.py/ py.test tests/test_filetypes.py 
======================================================================================== test session starts =========================================================================================
platform linux2 -- Python 2.7.12, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /mnt/vault/projects/pushbullet.py, inifile: 
collected 2 items 

tests/test_filetypes.py ..

====================================================================================== 2 passed in 0.10 seconds ======================================================================================
(.pyvenv2) pushbullet.py/ deactivate 
pushbullet.py/ source ~/.pyvenv/bin/activate
(.pyvenv) pushbullet.py/ py.test tests/test_filetypes.py       
========= test session starts ==========
platform linux -- Python 3.5.2, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /mnt/vault/projects/pushbullet.py, inifile: 
plugins: mock-1.1, cov-2.3.0
collected 2 items 

tests/test_filetypes.py ..

======= 2 passed in 0.10 seconds =======