项目作者: rahulnair23

项目描述 :
Get stackoverflow answers automatically based on uncaught exceptions
高级语言: Python
项目地址: git://github.com/rahulnair23/pyRecommender.git
创建时间: 2017-05-16T11:06:00Z
项目社区:https://github.com/rahulnair23/pyRecommender

开源协议:MIT License

下载


pyRecommender

Get stackoverflow answers automatically based on uncaught exceptions.

Installation

  1. $ git clone git@github.com:rahulnair23/pyRecommender.git
  2. $ cd pyRecommender
  3. $ export PYTHONPATH=$PYTHONPATH:$(pwd)

The pyRecommender sessions are active for all interactive and command line python sessions.

Example use:

  1. $python test.py
  2. pyRecommender session enabled (remove sitecustomize.py from PYTHONPATH to disable).
  3. Traceback (most recent call last):
  4. File "test.py", line 4, in <module>
  5. print(float('k'))
  6. ValueError: could not convert string to float: 'k'
  7. Have you looked at:
  8. 1.If you want to handle exceptions different depending on their origin, it is best to separate the different code parts that can throw the exceptions. Then you can just put a try/except block around the respective statement that throws the exception, e.g.:
  9. while True:
  10. try:
  11. ...
  12. Source: http://stackoverflow.com/questions/13297748/python-except-valueerror-only-for-strings
  13. 2.replace this code
  14. GAIA_HOST = 'www.google.com'
  15. LOGIN_URI = '/accounts/ServiceLoginAuth'
  16. by this
  17. GAIA_HOST = 'accounts.google.com'
  18. LOGIN_URI = '/ServiceLoginAuth'...
  19. Source: http://stackoverflow.com/questions/19915335/python-cloud-print-authorization

How does it work?

Python automatically imports the site package during initialization which in turn looks for sitecustomize which registers the custom hooks to get unhandled exceptions.