lukasschwab / stackit

StackOverflow queries from the command line
MIT License
314 stars 28 forks source link

fix `-e` issue addressed in #6 #10

Closed WnP closed 9 years ago

WnP commented 9 years ago

Maybe we should redirect stdout to /dev/null, we could do that by setting Popen's stdout option to os.devnull

WnP commented 9 years ago

done

lukasschwab commented 9 years ago

@WnP do you have some test cases that caused failure in the previous implementation?

I'd love to have a better way to test this.

WnP commented 9 years ago

@lukasschwab

% stackit -e "python -c 'print(foo)'"
Searching for: python: can't open file '/home/steeve/stackit/-c': [Errno 2] No such file or directory ...

. . .

should search for NameError: name 'foo' is not defined not python: can't open file '/home/steeve/stackit/-c': [Errno 2] No such file or directory

for example, and all other command line with arguments that returns errors

lukasschwab commented 9 years ago

Great, I'll test with those examples and my old test set and hopefully merge by EOD.

WnP commented 9 years ago

@lukasschwab corrected ;-)

lukasschwab commented 9 years ago

@WnP Looks great! I tested with your example, and also with my old set of tests for stackit -e (Python scripts that generate errors), and tested the new "no error" message with bash commands (e.g. ls) and Python scripts that don't generate errors.

Merging. Thanks!

lukasschwab commented 9 years ago

@schwartzmx Check this out––let me know if it solves the issue you brought up on PR #6. I think it should...

schwartzmx commented 9 years ago

@lukasschwab @WnP I know Windows isn't currently "supported". But this is the type of anomalies I am talking about, they may not be solvable the way different shells and programs output stack traces and errors. For example in Powershell (With output questions abbreviated ... :

C:\stackit\stackit [master]> python .\stackit_core.py -e "ls -adfa"
Searching for: operable program or batch file....
Tags:

...

Enter m for more, a question number to select, or q to quit: q
C:\stackit\stackit [master]> ls -afda
Get-ChildItem : A parameter cannot be found that matches parameter name 'afda'.
At line:1 char:4
+ ls -afda
+    ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

The search that was done has nothing to do with the actual error. I don't know if this is solvable for everything. But I think this is regardless of just Windows. Just figured I'd bring this up, to clarify what I meant in the earlier thread.

It does work for things (that I've tested) on Unix.

Phil

WnP commented 9 years ago

@schwartzmx I don't have Windows to be make some test, I gess the problem come from the fact that errors are not redirected to stderr

could you show me this test script output to better understand the problem?