[issue36331] check_output is returning non-zero exit status 1

2019-03-17 Thread Ned Deily


Ned Deily  added the comment:

Did you try running the same command "screen -ls" with subprocess.run() so you 
can see the output from it?  Or just from a terminal shell?  If I do, I see:

>>> subprocess.run(["screen", "-ls"])
No Sockets found in /var/folders/sn/0m4rnbyj2z1byjs68sz83830gn/T/.screen.

CompletedProcess(args=['screen', '-ls'], returncode=1)

$ screen -ls
No Sockets found in /var/folders/sn/0m4rnbyj2z1byjs68sz83830gn/T/.screen.

So subprocees.check_output() is likely working just fine: it is telling you 
that the command you tried to execute failed for some reason.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: compile error -> 

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36331] check_output is returning non-zero exit status 1

2019-03-17 Thread Jagadeesh Marella


New submission from Jagadeesh Marella :

>>>> check_output(["screen", "-ls"])
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/Cellar/pypy3/6.0.0/libexec/lib-python/3/subprocess.py", line 
316, in check_output
**kwargs).stdout
  File "/usr/local/Cellar/pypy3/6.0.0/libexec/lib-python/3/subprocess.py", line 
398, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['screen', '-ls']' returned non-zero 
exit status 1

--
components: macOS
messages: 338140
nosy: jagadeesh, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: check_output is returning non-zero exit status 1
type: compile error
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue36331>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29473] subprocces check_output

2017-02-07 Thread Steve Dower

Steve Dower added the comment:

What's your actual command? And what output is it producing? Without those, 
we've got no hope of guessing what is going on here.

Nothing in subprocess should have changed because of my PEPs, other than 
decoding bytes passed as arguments (which IIRC wasn't possible before anyway, 
and we may have left it that way).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue29473] subprocces check_output

2017-02-07 Thread Вадим Кара

New submission from Вадим Кара:

check_output(['command'])
Can't be decoded as it was in 3.5
check_output(['command']).decode('utf-8') returns UnicodeDecodeError: 'utf-8' 
codec can't decode byte 0x8d in position 2: invalid start byte error.

--
components: Windows
messages: 287239
nosy: paul.moore, steve.dower, tim.golden, zach.ware, Вадим Кара
priority: normal
severity: normal
status: open
title: subprocces check_output
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29473>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2016-04-04 Thread Martin Panter

Martin Panter added the comment:

As I understand it, this change only made it to 3.3+

--
nosy: +martin.panter
versions:  -Python 2.7, Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: subprocess check_output

2016-01-07 Thread Chris Angelico
On Thu, Jan 7, 2016 at 9:14 PM, Marko Rauhamaa  wrote:
> Marko Rauhamaa :
>
>> Chris Angelico :
>>
>>> you ask the correct question of "why isn't my CSS file being read?"
>>
>> TL;DR
>
> Sorry, getting confused with homonyms:
>
>
>>> CSS gurus suggest, along similar lines, changing the background color
>>> of something to red.
>
>

Oh. I think that wordplay was _exactly_ why the choice was red, rather
than an equally-obvious yellow or green or blue or something. "If the
body is red, the file was read".

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-07 Thread Chris Angelico
On Thu, Jan 7, 2016 at 8:33 PM, me  wrote:
> On 2016-01-05, Chris Angelico  wrote:
>> Oh, and then you keep editing and save again? Nah, I've *never* done
>> that... Never!
>
> I'm quite surprised, buddy. You should definitely try.

I know, right! It's so exciting to suddenly discover that you have two
separate copies of a piece of code, and that one of them isn't where
you think it is... makes life so interesting!

Serious suggestion for people who run into weirdness: Sometimes it
helps to make a deliberate and obvious syntax error (misuse a keyword,
break the indentation, put a mass of symbols in someplace), just to
see that your code is getting parsed. If it doesn't trigger an error,
well, your deployment is failing somewhere. CSS gurus suggest, along
similar lines, changing the background color of something to red.
Saves ever so much fiddling around - instead of asking "why doesn't my
padding work in IE?", you ask the correct question of "why isn't my
CSS file being read?", upon which you discover that you were
referencing it from the wrong directory. True story.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-07 Thread Marko Rauhamaa
Marko Rauhamaa :

> Chris Angelico :
>
>> you ask the correct question of "why isn't my CSS file being read?"
>
> TL;DR

Sorry, getting confused with homonyms:

>> CSS gurus suggest, along similar lines, changing the background color
>> of something to red.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-05 Thread me
On 2016-01-02, Chris Angelico  wrote:
> down to "whoops, I forgot to save the file" or "whoops, I was in the
> wrong directory"...

Amen, bro.

Exceptionally true if you ever need for some reason to put your code in
another directory, but you forget to close the files in your editor. :D
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-05 Thread Chris Angelico
On Tue, Jan 5, 2016 at 10:15 PM, me  wrote:
> On 2016-01-02, Chris Angelico  wrote:
>> down to "whoops, I forgot to save the file" or "whoops, I was in the
>> wrong directory"...
>
> Amen, bro.
>
> Exceptionally true if you ever need for some reason to put your code in
> another directory, but you forget to close the files in your editor. :D

Oh, and then you keep editing and save again? Nah, I've *never* done
that... Never!

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-02 Thread Chris Angelico
On Sun, Jan 3, 2016 at 7:39 AM, Carlos Barera  wrote:
> Turns out it wasn't running against the server I thought it was.
> Apologies for the spam.

Heh. No problem. That's part of why I suggested running it from the
shell. There are two possibilities: either it also fails from the
shell (in which case you've eliminated Python as the problem, and can
concentrate on "why is my command not working"), or it succeeds when
run manually and still fails from Python (in which case you can start
investigating the differences). And every now and then, it's worth
doing a stupid smoke test just to see if your changes are even having
effect. You have no idea how many times a bug investigation has come
down to "whoops, I forgot to save the file" or "whoops, I was in the
wrong directory"...

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2016-01-02 Thread Carlos Barera
Turns out it wasn't running against the server I thought it was.
Apologies for the spam.

-carlos

On Wed, Dec 30, 2015 at 11:02 PM Cameron Simpson  wrote:

> On 30Dec2015 21:14, Carlos Barera  wrote:
> >Trying to run a specific command (ibstat)  installed in /usr/sbin on an
> >Ubuntu 15.04 machine, using subprocess.check_output and getting "/bin/sh:
> >/usr/sbin/ibstat: No such file or directory"
> >
> >I tried the following:
> >- running the command providing full path
> >- running with executable=bash
> >- running with (['/bin/bash', '-c' , "/usr/sbin/ibstat"])
> >
> >Nothing worked ...
>
> The first check is to run the command from a shell. Does it work? Does
> "which
> ibstat" confirm that the command exist at that path? Is it even installed?
>
> If it does, you should be able to run it directly without using a shell:
>
>   subprocess.call(['/usr/sbin/ibstat'], ...)
>
> or just plain ['ibstat']. Also remember that using "sh -c blah" or "bash -c
> blah" is subject to all the same security issues that subprocess'
> "shell=True"
> parameter is, and that it should be avoided without special reason.
>
> Finally, remember to drop the common Linux fetish with "bash". Just use
> "sh";
> on many systems it _is_ bash, but it will provide portable use. The bash is
> just a partiular Bourne style shell, not installed everywhere, and rarely
> of
> any special benefit for scripts over the system /bin/sh (which _every_ UNIX
> system has).
>
> If none of this solves your problem, please reply including the failing
> code
> and a transcript of the failure output.
>
> Thanks,
> Cameron Simpson 
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2015-12-30 Thread Cameron Simpson

On 30Dec2015 21:14, Carlos Barera  wrote:

Trying to run a specific command (ibstat)  installed in /usr/sbin on an
Ubuntu 15.04 machine, using subprocess.check_output and getting "/bin/sh:
/usr/sbin/ibstat: No such file or directory"

I tried the following:
- running the command providing full path
- running with executable=bash
- running with (['/bin/bash', '-c' , "/usr/sbin/ibstat"])

Nothing worked ...


The first check is to run the command from a shell. Does it work? Does "which 
ibstat" confirm that the command exist at that path? Is it even installed?


If it does, you should be able to run it directly without using a shell:

 subprocess.call(['/usr/sbin/ibstat'], ...)

or just plain ['ibstat']. Also remember that using "sh -c blah" or "bash -c 
blah" is subject to all the same security issues that subprocess' "shell=True" 
parameter is, and that it should be avoided without special reason.


Finally, remember to drop the common Linux fetish with "bash". Just use "sh"; 
on many systems it _is_ bash, but it will provide portable use. The bash is 
just a partiular Bourne style shell, not installed everywhere, and rarely of 
any special benefit for scripts over the system /bin/sh (which _every_ UNIX 
system has).


If none of this solves your problem, please reply including the failing code 
and a transcript of the failure output.


Thanks,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


subprocess check_output

2015-12-30 Thread Carlos Barera
Hi,

Trying to run a specific command (ibstat)  installed in /usr/sbin on an
Ubuntu 15.04 machine, using subprocess.check_output and getting "/bin/sh:
/usr/sbin/ibstat: No such file or directory"

I tried the following:
- running the command providing full path
- running with executable=bash
- running with (['/bin/bash', '-c' , "/usr/sbin/ibstat"])

Nothing worked ...

Any idea?

-carlos
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: subprocess check_output

2015-12-30 Thread Chris Angelico
On Thu, Dec 31, 2015 at 8:02 AM, Cameron Simpson  wrote:
> On 30Dec2015 21:14, Carlos Barera  wrote:
>>
>> Trying to run a specific command (ibstat)  installed in /usr/sbin on an
>> Ubuntu 15.04 machine, using subprocess.check_output and getting "/bin/sh:
>> /usr/sbin/ibstat: No such file or directory"
>>
>> I tried the following:
>> - running the command providing full path
>> - running with executable=bash
>> - running with (['/bin/bash', '-c' , "/usr/sbin/ibstat"])
>>
>> Nothing worked ...
>
>
> The first check is to run the command from a shell. Does it work? Does
> "which ibstat" confirm that the command exist at that path? Is it even
> installed?

And do those checks as the same user as your script runs as, with the
same environment and all. You might find that a file is executable for
one user but not for another, or something.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


check_output

2014-11-04 Thread Kiuhnm
When I call subprocess.check_output() I see the console window appear and 
disappear very quickly. Is there a way to stop the console from showing up at 
all?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: check_output

2014-11-04 Thread Kiuhnm
On Wednesday, November 5, 2014 3:05:32 AM UTC+1, Kiuhnm wrote:
 When I call subprocess.check_output() I see the console window appear and 
 disappear very quickly. Is there a way to stop the console from showing up at 
 all?

shell=True
does the trick!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue12494] subprocess: check_output() doesn't close pipes on error

2011-09-01 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 The second patch looks good. Tests?

Ok, I will try to write a new patch with tests.

 But, it *probably* shouldn't be applied to 2.7  3.2 given that it is a 
 behaviour change.

I consider that this issue is a bug, so it should be fixed in 2.7 and 
3.2. I agree that *killing* the process is a behaviour change, but we 
can just close pipes on error for 2.7 and 3.2.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-09-01 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

 I consider that this issue is a bug, so it should be fixed in 2.7 and 
 3.2. I agree that *killing* the process is a behaviour change, but we 
 can just close pipes on error for 2.7 and 3.2.

Yeah, that seems right.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-09-01 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 86b7f14485c9 by Victor Stinner in branch 'default':
Issue #12494: Close pipes and kill process on error in subprocess functions
http://hg.python.org/cpython/rev/86b7f14485c9

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-09-01 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 The second patch looks good. Tests?

I don't see how to test that the pipes are closed, because the Popen object 
(and its stdout and stderr attributes) are not visible outside the patched 
functions.

 I consider that this issue is a bug, so it should be fixed in 2.7
 and 3.2.

I tried to write a patch, but I chose to keep the code unchanged. I prefer to 
keep this little tricky bug, instead of introducing another more important 
regression.

Reopen the issue if you have a script to test the fix, or if you really want a 
backport.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-08-31 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

The second patch looks good. Tests?

I think it would be better to kill the process than to let it carry on.

But, it *probably* shouldn't be applied to 2.7  3.2 given that it is a 
behaviour change.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-07-11 Thread Ross Lagerwall

Changes by Ross Lagerwall rosslagerw...@gmail.com:


--
nosy: +rosslagerwall

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-07-05 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

subprocess_check_output-2.patch is a more complete patch: fix (?) call(), 
check_output() and getstatusoutput(). These functions kill the process if an 
exception occurs to not hang on wait() in Popen.__exit__().

Because of the kill, I don't know if the fix should be applied to 2.7 and 3.2. 
In case of an exception, is it better to keep the subprocess alive, or to kill 
it? If we keep it alive, the caller of the function cannot interact with the 
process, and we don't know exactly when it will finish.

By exception, I mean unexpected exceptions: check_output() handles explicitly 
the TimeoutExpired exception.

--
Added file: http://bugs.python.org/file22580/subprocess_check_output-2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-07-05 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

See also issue #12044 which changed the context manager to call the wait() 
method.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12494] subprocess: check_output() doesn't close pipes on error

2011-07-04 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

subprocess.check_output() doesn't close explicitly pipes if an error occurs. 
See for example issue #12493 for an example of an error on .communicate().

Attached patch uses a context manager to ensure that all pipes are always 
closed and that the status is read to avoid zombies.

Other subprocess functions should be fixed:
 - call() (will fix check_call)
 - getstatusoutput() (will fix getoutput): see patch attached to the issue 
#10197 to replace os.popen() by subprocess.Popen

--
components: Library (Lib)
files: subprocess_check_output.patch
keywords: patch
messages: 139812
nosy: haypo
priority: normal
severity: normal
status: open
title: subprocess: check_output() doesn't close pipes on error
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file22572/subprocess_check_output.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12494
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com