Command-line tool that instantly fetches Stack Overflow results when an exception is thrown

Overview

rebound

Rebound is a command-line tool that instantly fetches Stack Overflow results when an exception is thrown. Just use the rebound command to execute your file.

Placeholder Demo

Featured in: 50 Most Popular Python Projects in 2018, the top of r/Python, awesome-cli-apps, awesome-shell, terminals-are-sexy, and awesome-mac.

Installation

Requires Python 3.0 or higher.

Rebound works on MacOS, Linux, and Windows (if you use Cygwin). You can install it with pip:

$ pip install rebound-cli

or apt-get if you're using Linux:

$ sudo apt-get install rebound-cli

Usage

Running a file with rebound is just as easy as running it normally:

$ rebound [file_path]

This will execute the file, pull the error message, and let you browse related Stack Overflow questions and answers without leaving the terminal.

Supported file types: Python, Node.js, Ruby, Golang, and Java.

Contributing

To make a contribution, fork the repo, make your changes and then submit a pull request. Please try to adhere to the existing style. If you've discovered a bug or have a feature request, create an issue.

Pending Features:

  • Improved text formatting (i.e. for duplicate questions, markdown, blockquotes, clickable links, etc.)
  • Improved search result accuracy by extracting potential search terms from the stack trace
  • Support for more languages

How it Works

Rebound is written in Python and built on Urwid. Beautiful Soup is used to scrape Stack Overflow content and subprocess for catching compiler errors.

Acknowledgements

Special thanks to @rndusr for helping with the scrollbar.

Comments
  • Add random UA

    Add random UA

    Two ways to generate random UA, use 'fake-useragent' module, which is reound_FAKE_UA.py or use a list of UA, which is user_agent and random choice in rebound.py

    opened by leon332157 6
  • get_search_results(soup) Index Error

    get_search_results(soup) Index Error

    I have altered your code a bit for my own use, but this function is still from your source code and I don't think I caused the error. It worked two weeks ago, and I tried running it yesterday without any changes in the past two weeks and it's broken now. Did stack overflow change something breaking the search?

    Using search_stackoverflow(query) with a query of "python nltk tokenize" I get an error inside the function, get_search_results(soup),

    Here's an excerpt of the traceback,

     in get_search_results
    title_container = result.find_all("div", class_="result-link")[0].find_all("span")[0].find_all("a")[0]                                                                                                                                   
    IndexError: list index out of range         
    

    There are values in results, and result.find_all("div", class_="result-link")[0], but result.find_all("div", class_="result-link")[0].find_all("span") returns none so index zero doesn't exist hence the error.

    Did something change, if so what needs to be changed to get it working again?

    opened by KeithTheEE 5
  • Won't run on Windows

    Won't run on Windows

    Hi there, I am very interested in your work and tried it on my Windows 10 box. Unfortunatly there seems to be some issues related to the close_fds working on Windows?

    [email protected] MINGW64 /d/dev_workspace/Learning OpenCV/OpenCV Python Bindings/features
    $ rebound lab_optical_flow.py
    Traceback (most recent call last):
      File "d:\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "d:\python\python36-32\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "D:\Python\Python36-32\Scripts\rebound.exe\__main__.py", line 9, in <module>
      File "d:\python\python36-32\lib\site-packages\rebound\rebound.py", line 766, in main
        output, error = execute([language] + sys.argv[1:]) # Compiles the file and pipes stdout
      File "d:\python\python36-32\lib\site-packages\rebound\rebound.py", line 124, in execute
        bufsize=1
      File "d:\python\python36-32\lib\subprocess.py", line 624, in __init__
        "close_fds is not supported on Windows platforms"
    ValueError: close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr
    

    Also tried with powershell and cmd, both without any luck :-(

    Trying to change the argument from True to False :

    def execute(command):
        """Executes a given command and clones stdout/err to both variables and the
        terminal (in real-time)."""
        process = Popen(
            command,
            cwd=None,
            shell=False,
            close_fds=False,  # does not work
            stdout=PIPE,
            stderr=PIPE,
            bufsize=1
        )
    

    won't solve the problem. Something else will crash it:

     rebound lab_optical_flow.py
    (1, 44, 3)
    i is  4
    (1, 48, 3)
    Traceback (most recent call last):
      File "lab_optical_flow.py", line 64, in <module>
        raise UserWarning("You stop here and check what\'s wrong!")
    UserWarning: You stop here and check what's wrong!
    
    Display Stack Overflow results? [Y/n] y
    Traceback (most recent call last):
      File "d:\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "d:\python\python36-32\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "D:\Python\Python36-32\Scripts\rebound.exe\__main__.py", line 9, in <module>
      File "d:\python\python36-32\lib\site-packages\rebound\rebound.py", line 780, in main
        App(search_results) # Opens interface
      File "d:\python\python36-32\lib\site-packages\rebound\rebound.py", line 654, in __init__
        self.main_loop = urwid.MainLoop(layout, self.palette, unhandled_input=self._handle_input)
      File "d:\python\python36-32\lib\site-packages\urwid\main_loop.py", line 114, in __init__
        screen = raw_display.Screen()
      File "d:\python\python36-32\lib\site-packages\urwid\raw_display.py", line 92, in __init__
        fcntl.fcntl(self._resize_pipe_rd, fcntl.F_SETFL, os.O_NONBLOCK)
    NameError: name 'fcntl' is not defined
    
    

    I am not familar with close_fds as of writing. And to make it worse I happen to find that urwid is not supported on windows (see here, here and here)

    Maybe you may declare in the README.md that the fancy program currently not supported on Windows?

    opened by y0umu 5
  • IndexError: list index out of range

    IndexError: list index out of range

    File "/home/adam/.local/bin/rebound", line 11, in sys.exit(main()) File "/home/adam/.local/lib/python3.6/site-packages/rebound/rebound.py", line 843, in main search_results, captcha = search_stackoverflow(query) File "/home/adam/.local/lib/python3.6/site-packages/rebound/rebound.py", line 298, in search_stackoverflow return (get_search_results(soup), False) File "/home/adam/.local/lib/python3.6/site-packages/rebound/rebound.py", line 256, in get_search_results title_container = result.find_all("div", class_="result-link")[0].find_all("span")[0].find_all("a")[0]

    opened by jarzab3 4
  • Change how the `rebound` command is used

    Change how the `rebound` command is used

    Instead of executing files with the rebound command, I think it would be more user-friendly to execute the file normally, get a compiler error, and then type rebound to fetch that error and display the CLI. For example, the Python workflow would be:

    1. Run $ python test.py
    2. Program fails and returns an error message
    3. User runs $ rebound to prompt the CLI
    high-priority feature-request 
    opened by shobrook 4
  • rebound command not available from the command line

    rebound command not available from the command line

    I tried installing rebound by following the instructions in the readme as well as variations I compiled from looking online. After all of these I was unable to call "rebound" from the command line on a linux machine.

    I tried the following installation commands: pip install rebound-cli pip3 install rebound-cli (with and without --user) sudo apt-get install rebound-cli git clone repo followed by python3 setup.py install (with and without --user) I verified that pip and urwid are up to date.

    After all of this I get the 'rebound: Command not found.' error no matter where in the directory i try to run it from

    opened by mjfuuu 3
  • getting  following errors after pressing enter

    getting following errors after pressing enter

    ``Display Stack Overflow results? [Y/n]

    Traceback (most recent call last): File "/home/sagar/.local/bin/rebound", line 11, in sys.exit(main()) File "/home/sagar/.local/lib/python3.7/site-packages/rebound/rebound.py", line 871, in main App(search_results) # Opens interface File "/home/sagar/.local/lib/python3.7/site-packages/rebound/rebound.py", line 733, in init self.main_loop.run() File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 286, in run self._run() File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 384, in _run self.event_loop.run() File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 788, in run self._loop() File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 825, in _loop self._watch_filesfd File "/home/sagar/.local/lib/python3.7/site-packages/urwid/raw_display.py", line 404, in event_loop, callback, self.get_available_raw_input()) File "/home/sagar/.local/lib/python3.7/site-packages/urwid/raw_display.py", line 502, in parse_input callback(processed, processed_codes) File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 411, in _update self.process_input(keys) File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 517, in process_input something_handled |= bool(self.unhandled_input(k)) File "/home/sagar/.local/lib/python3.7/site-packages/urwid/main_loop.py", line 563, in unhandled_input return self._unhandled_input(input) File "/home/sagar/.local/lib/python3.7/site-packages/rebound/rebound.py", line 742, in handle_input question_title, question_desc, question_stats, answers = get_question_and_answers(url) File "/home/sagar/.local/lib/python3.7/site-packages/rebound/rebound.py", line 307, in get_question_and_answers question_stats = soup.find_all("span", class="vote-count-post")[0].get_text() # Vote count IndexError: list index out of range

    opened by Sagar19RaoRane 3
  • Semi-fix issue #84

    Semi-fix issue #84

    Changed the user agent to be the same when searching for results, instead of a different UA for every result. This fixes captcha triggering right at the start, but running the program 2-3 times in a row will trigger it again. That's why it is a semi-fix, further analysis is required, but for now, this is a step to the right direction.

    Also, I cleaned up the code and fixed some Anti-Pattern issues.

    I am also trying to use Googlebot's UA, because sometimes it fixes the issue. For now, this should do it.

    Thank you :)

    opened by cristicretu 2
  • when I was testing rebound, IndexError: list index out of range Error occurs

    when I was testing rebound, IndexError: list index out of range Error occurs

    I am using ubuntu 20.04 LTS and python 3.8.2. when I was testing rebound on a simple python script I got two error.

    1. the first issue occurs just after the command runs, Its seems like some problem with python but I am not sure.
    2. when I choose y I got the questions from StackOverflow but when I enter to see the answer it breaks and second error occurs. the output is attached below.
    [email protected]:~$ rebound test1.py
    /usr/lib/python3.8/subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
    self.stdout = io.open(c2pread, 'rb', bufsize)
    /usr/lib/python3.8/subprocess.py:849: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
    self.stderr = io.open(errread, 'rb', bufsize)
    
    Traceback (most recent call last):
    
    File "test1.py", line 3, in <module>
    
    print(x+y+z)
    
    NameError: name 'z' is not defined
    
    
    Display Stack Overflow results? [Y/n]
    y
    
    File "/home/raj-priyanshu/.local/bin/rebound", line 8, in <module>
    sys.exit(main())
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/rebound/rebound.py", line 871, in main
    App(search_results) # Opens interface
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/rebound/rebound.py", line 733, in __init__
    self.main_loop.run()
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 287, in run
    self._run()
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 790, in run
    self._loop()
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 827, in _loop
    self._watch_files[fd]()
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/raw_display.py", line 416, in <lambda>
    wrapper = lambda: self.parse_input(
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/raw_display.py", line 515, in parse_input
    callback(processed, processed_codes)
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 412, in _update
    self.process_input(keys)
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 519, in process_input
    something_handled |= bool(self.unhandled_input(k))
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/urwid/main_loop.py", line 565, in unhandled_input
    return self._unhandled_input(input)
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/rebound/rebound.py", line 742, in _handle_input
    question_title, question_desc, question_stats, answers = get_question_and_answers(url)
    File "/home/raj-priyanshu/.local/lib/python3.8/site-packages/rebound/rebound.py", line 307, in get_question_and_answers
    question_stats = soup.find_all("span", class_="vote-count-post")[0].get_text() # Vote count
    IndexError: list index out of range
    
    opened by raj-priyanshu 2
  • can't use it in my CentOS machine

    can't use it in my CentOS machine

    opened by WillireamAngel 2
  • Add error handling for Stack Overflow get request

    Add error handling for Stack Overflow get request

    Currently there is no error handling for the Stack Overflow get request in the souper function. If the requests.get function throws an exception rebound just crashes.

    Changed this by putting the requests.get call in a try except block and adding a friendly error message if the requests.get call throws an exception.

    opened by maxthecabbie 2
  • stack overflow result fixes

    stack overflow result fixes

    Fetches results from Google with stackoverflow.com tag and a little bit of code refactoring. 2 new dependencies have been introduced into the package.

    opened by derhnyel 0
  • LICENSE file missing from root directory

    LICENSE file missing from root directory

    I see this is MIT licensed. Adding a LICENSE file to the root directory would make this very obvious for people new to the project and show up in the About header on the first page view of the project.

    Would you like me to make a PR to move the file?

    mv docs/LICENSE LICENSE

    opened by TechnologyClassroom 0
  • Windows 10 -Cygwin Error

    Windows 10 -Cygwin Error "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position "

    Hi,

    First of all, this is a really cool project!

    I just started using rebound-cli, I'm on Windows and I've installed cygwin, however when I run a script i get the following error:

    
    c:\users\fredb\appdata\local\programs\python\python38\lib\subprocess.py:844: RuntimeWarning: line buffering (buffering=1) isn't suppor
    ted in binary mode, the default buffer size will be used
      self.stdout = io.open(c2pread, 'rb', bufsize)
    c:\users\fredb\appdata\local\programs\python\python38\lib\subprocess.py:849: RuntimeWarning: line buffering (buffering=1) isn't suppor
    ted in binary mode, the default buffer size will be used
      self.stderr = io.open(errread, 'rb', bufsize)
    Exception in thread Thread-2:
    Traceback (most recent call last):
      File "c:\users\fredb\appdata\local\programs\python\python38\lib\threading.py", line 932, in _bootstrap_inner
        self.run()
      File "c:\users\fredb\appdata\local\programs\python\python38\lib\threading.py", line 870, in run
        self._target(*self._args, **self._kwargs)
      File "c:\users\fredb\appdata\local\programs\python\python38\lib\site-packages\rebound\rebound.py", line 147, in read
        func(line.decode("utf-8"))
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 13: invalid continuation byte
    
    

    The script is just a simple example:

    x = 5
    y = 10
    x += y
    print(x)
    

    I really don't understand what I'm doing wrong

    windows 
    opened by Koubae 0
  • Sorry, Stack Overflow blocked our request. Try again in a minute.

    Sorry, Stack Overflow blocked our request. Try again in a minute.

    I am a new user of rebound, I have just installed it today ( via pip ).

    I am getting this every time:

    Sorry, Stack Overflow blocked our request. Try again in a minute.
    

    I am running on Ubuntu 20.04, and I have made sure that I have proper internet connectivity.

    bug high-priority 
    opened by aahnik 11
  • New Features for Rebound

    New Features for Rebound

    Hi!

    After I look through the code, I have a few ideas which can be put into the rebound project. This include:

    • Replacing in view answer function by using lynx ( Text-based browser GUI)
    • Putting create barcode function which able the user to share the solution link to other user
    • Save the solution link in the history or record, so the user can check again the previous selected link

    Please let me know what you guys think.

    Thanks!

    opened by gilbertch09 1
Releases(v2.0.0)
Owner
Jonathan Shobrook
Jonathan Shobrook
Ransomware leak site monitoring

RansomWatch RansomWatch is a ransomware leak site monitoring tool. It will scrape all of the entries on various ransomware leak sites, store the data

Zander Work 278 Dec 31, 2022
Robust and effective logging for Python 2 and 3.

Robust and effective logging for Python 2 and 3.

Chris Hager 1k Jan 04, 2023
Fuzzy-logger - Fuzzy project is here Log all your pc's actions Simple and free to use Security of datas !

Fuzzy-logger - ➡️⭐ Fuzzy ⭐ project is here ! ➡️ Log all your pc's actions ! ➡️ Simple and free to use ➡️ Security of datas !

natrix_dev 2 Oct 02, 2022
Small toolkit for python multiprocessing logging to file

Small Toolkit for Python Multiprocessing Logging This is a small toolkit for solving unsafe python mutliprocess logging (file logging and rotation) In

Qishuai 1 Nov 10, 2021
A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics.

A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics, originally intended for keyboard layout optimization.

Ga68 56 Jan 03, 2023
The easy way to send notifications

See changelog for recent changes Got an app or service and you want to enable your users to use notifications with their provider of choice? Working o

Or Carmi 2.4k Dec 25, 2022
A Prometheus exporter for monitoring & analyzing Grafana Labs' technical documentation

grafana-docs-exporter A Prometheus exporter for monitoring & analyzing Grafana Labs' technical documentation Here is the public endpoint.

Matt Abrams 5 May 02, 2022
HTTP(s) "monitoring" webpage via FastAPI+Jinja2. Inspired by https://github.com/RaymiiOrg/bash-http-monitoring

python-http-monitoring HTTP(s) "monitoring" powered by FastAPI+Jinja2+aiohttp. Inspired by bash-http-monitoring. Installation can be done with pipenv

itzk 39 Aug 26, 2022
Track Nano accounts and notify via log file or email

nano-address-notifier Track accounts and notify via log file or email Required python libs

Joohansson (Json) 4 Nov 08, 2021
Debugging-friendly exceptions for Python

Better tracebacks This is a more helpful version of Python's built-in exception message: It shows more code context and the current values of nearby v

Clemens Korndörfer 1.2k Dec 28, 2022
Vibrating-perimeter - Simple helper mod that logs how fast you are mining together with a simple buttplug.io script to control a vibrator

Vibrating Perimeter This project consists of a small minecraft helper mod that writes too a log file and a script that reads said log. Currently it on

Heart[BOT] 0 Nov 20, 2022
giving — the reactive logger

giving is a simple, magical library that lets you log or "give" arbitrary data throughout a program and then process it as an event stream.

Olivier Breuleux 0 May 24, 2022
Command-line tool that instantly fetches Stack Overflow results when an exception is thrown

rebound Rebound is a command-line tool that instantly fetches Stack Overflow results when an exception is thrown. Just use the rebound command to exec

Jonathan Shobrook 3.9k Jan 03, 2023
A watchdog and logger to Discord for hosting ScPrime servers.

ScpDog A watchdog and logger to Discord for hosting ScPrime servers. Designed to work on Linux servers. This is only capable of sending the logs from

Keagan Landfried 3 Jan 10, 2022
Fancy console logger and wise assistant within your python projects

Fancy console logger and wise assistant within your python projects. Made to save tons of hours for common routines.

BoB 5 Apr 01, 2022
Soda SQL Data testing, monitoring and profiling for SQL accessible data.

Soda SQL Data testing, monitoring and profiling for SQL accessible data. What does Soda SQL do? Soda SQL allows you to Stop your pipeline when bad dat

Soda Data Monitoring 51 Jan 01, 2023
A small utility to pretty-print Python tracebacks. ⛺

TBVaccine TBVaccine is a utility that pretty-prints Python tracebacks. It automatically highlights lines you care about and deemphasizes lines you don

Stavros Korokithakis 365 Nov 11, 2022
dash-manufacture-spc-dashboard is a dashboard for monitoring read-time process quality along manufacture production line

In our solution based on plotly, dash and influxdb, the user will firstly generate the specifications for different robots, and then a wide range of interactive visualizations for different machines

Dequn Teng 1 Feb 13, 2022
Prettify Python exception output to make it legible.

pretty-errors Prettifies Python exception output to make it legible. Install it with python -m pip install pretty_errors If you want pretty_errors to

Iain King 2.6k Jan 04, 2023
Splunk Add-On to collect audit log events from Github Enterprise Cloud

GitHub Enterprise Audit Log Monitoring Splunk modular input plugin to fetch the enterprise audit log from GitHub Enterprise Support for modular inputs

Splunk GitHub 12 Aug 18, 2022