shobrook / rebound Goto Github PK
View Code? Open in Web Editor NEWCommand-line tool that instantly fetches Stack Overflow results when an exception is thrown
Command-line tool that instantly fetches Stack Overflow results when an exception is thrown
https://github.com/asciinema/asciinema
Check fortify README for an example
$ rebound main.py
Traceback (most recent call last):
File "c:\users\zeeshan rafique\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\zeeshan rafique\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\Zeeshan Rafique\anaconda3\Scripts\rebound.exe_main.py", line 7, in
File "c:\users\zeeshan rafique\anaconda3\lib\site-packages\rebound\rebound.py", line 856, in main
output, error = execute([language] + file_path) # Compiles the file and pipes stdout
File "c:\users\zeeshan rafique\anaconda3\lib\site-packages\rebound\rebound.py", line 170, in execute
bufsize=1
File "c:\users\zeeshan rafique\anaconda3\lib\subprocess.py", line 800, in init
restore_signals, start_new_session)
File "c:\users\zeeshan rafique\anaconda3\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
Code modularity is needed. Proper classes and functions should be distributed across multiple files and the project should achieve 'Separation of Concern' design principle.
Instead of running rebound "python main.py"
, it should be rebound python main.py
or even rebound main.py
(if we pull the language from the file extension).
When 'R' is pressed, the query/title should be highlighted and become editable.
Hey! I tried installing Cygwin and running a code with error but I get the same message that I was getting while running it on PowerShell. The error looks like this:
$ rebound error.py
Traceback (most recent call last):
File "c:\anaconda_3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\anaconda_3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Anaconda_3\Scripts\rebound.exe\__main__.py", line 9, in <module>
File "c:\anaconda_3\lib\site-packages\rebound\rebound.py", line 856, in main
output, error = execute([language] + file_path) # Compiles the file and pipes stdout
File "c:\anaconda_3\lib\site-packages\rebound\rebound.py", line 170, in execute
bufsize=1
File "c:\anaconda_3\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
Any solution to this?
Got an error attempting to install via pip. Error text is at the bottom including command line text using bash
$ pip install rebound-cli
Collecting rebound-cli
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/usr/lib/python3.4/site-packages/pip/_internal/commands/install.py", line 291, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3.4/site-packages/pip/_internal/resolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "/usr/lib/python3.4/site-packages/pip/_internal/resolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3.4/site-packages/pip/_internal/resolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python3.4/site-packages/pip/_internal/operations/prepare.py", line 243, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "/usr/lib/python3.4/site-packages/pip/_internal/req/req_install.py", line 307, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 484, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 442, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 587, in _get_pages
page = self._get_page(location)
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 705, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 833, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "/usr/lib/python3.4/site-packages/pip/_internal/index.py", line 753, in init
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
flip1 ~/cs464 502$
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?
xzc@HP-xzc 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?
It would be nice to be able to install via dnf on Fedora systems, instead of only with apt.
When an item in the ListBox is selected and ENTER is pressed, the question should open in the user's default browser.
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]
Hi!
After I look through the code, I have a few ideas which can be put into the rebound project. This include:
Please let me know what you guys think.
Thanks!
Scrolling works for the up/down keys but not the cursor. The scrollbar is also too close to the text.
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?
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
``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
We only want the error message, not the traceback.
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.
xxxxxxxx@IronMansion:~$ 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
Move from Click to urwid, curses, or npyscreen.
I'm getting the same error as in #41 . Maybe stackoverflow changed again?. Browser redirect works fine.
Traceback (most recent call last):
File "/home/xxxx/.local/bin/rebound", line 11, in
sys.exit(main())
File "/home/xxxx/.local/lib/python3.6/site-packages/rebound/rebound.py", line 844, in main
App(search_results) # Opens interface
File "/home/xxxx/.local/lib/python3.6/site-packages/rebound/rebound.py", line 733, in init
self.main_loop.run()
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 286, in run
self._run()
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 384, in _run
self.event_loop.run()
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 788, in run
self._loop()
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 825, in _loop
self._watch_filesfd
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/raw_display.py", line 404, in
event_loop, callback, self.get_available_raw_input())
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/raw_display.py", line 502, in parse_input
callback(processed, processed_codes)
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 411, in _update
self.process_input(keys)
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 517, in process_input
something_handled |= bool(self.unhandled_input(k))
File "/home/xxxx/.local/lib/python3.6/site-packages/urwid/main_loop.py", line 563, in unhandled_input
return self._unhandled_input(input)
File "/home/xxxx/.local/lib/python3.6/site-packages/rebound/rebound.py", line 742, in handle_input
question_title, question_desc, question_stats, answers = get_question_and_answers(url)
File "/home/xxxx/.local/lib/python3.6/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
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.
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:
$ python test.py
$ rebound
to prompt the CLIHi
would like to implements some new functions for the rebound which includes:
let me know what you guys think.
thank you
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
When "S" is pressed, the next page of results should be scraped and appended to the ListBox. If there is no next page, display a "No more results" popup.
[root@localhost whp]# rebound
bash: rebound: command not found...
[root@localhost whp]# rebound-cli
bash: rebound-cli: command not found..
[root@localhost whp]# rebound ./puppet.py
bash: rebound: command not found...
Sometimes errors happen when you try to run it. Is it possible to support runtime error caught and search on the stackoverflow
Installed rebound
with pip v20.0.2
. When running a simple Python file with a syntax error, produces the following -
Traceback (most recent call last):
File "/home/user86/.local/bin/rebound", line 5, in <module>
from rebound.rebound import main
File "/home/user86/.local/lib/python3.6/site-packages/rebound/rebound.py", line 6, in <module>
import urwid
File "/home/user86/.local/lib/python3.6/site-packages/urwid/__init__.py", line 26, in <module>
from urwid.widget import (FLOW, BOX, FIXED, LEFT, RIGHT, CENTER, TOP, MIDDLE,
File "/home/user86/.local/lib/python3.6/site-packages/urwid/widget.py", line 27, in <module>
from urwid.util import (MetaSuper, decompose_tagmarkup, calc_width,
File "/home/user86/.local/lib/python3.6/site-packages/urwid/util.py", line 61, in <module>
detected_encoding = detect_encoding()
File "/home/user86/.local/lib/python3.6/site-packages/urwid/util.py", line 58, in detect_encoding
locale.setlocale(locale.LC_ALL, initial)
File "/usr/lib/python3.6/locale.py", line 598, in setlocale
return _setlocale(category, locale)
What could be causing this?
This question actually has 3 Answers but currently the program displays 0.
This is the URL of search Page : https://stackoverflow.com/search?pagesize=50&q=python3+SyntaxError:+Missing+parentheses+in+call+to+%27print%27.+Did+you+mean+print(a)
Hello,
if there is anything possible like this then i'd like to contribute to this wonder full project
just kidding, this is not a real issue :)
On pressing "B" to browse the results while google chrome is the default browser, it just launch chrome with empty tab.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.