Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90877 > unrolled thread

subprocess.getstatusoutput does not exist in 2.7

Started byCecil Westerhof <Cecil@decebal.nl>
First post2015-05-19 19:11 +0200
Last post2015-05-19 21:07 +0200
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  subprocess.getstatusoutput does not exist in 2.7 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-19 19:11 +0200
    Re: subprocess.getstatusoutput does not exist in 2.7 Jon Ribbens <jon+usenet@unequivocal.co.uk> - 2015-05-19 17:37 +0000
      Re: subprocess.getstatusoutput does not exist in 2.7 Cecil Westerhof <Cecil@decebal.nl> - 2015-05-19 21:07 +0200

#90877 — subprocess.getstatusoutput does not exist in 2.7

FromCecil Westerhof <Cecil@decebal.nl>
Date2015-05-19 19:11 +0200
Subjectsubprocess.getstatusoutput does not exist in 2.7
Message-ID<87oalgtru5.fsf@Equus.decebal.nl>
At the moment I want my code to run with 2.7 and 3.4+.

But the command:
    subprocess.getstatusoutput
does not exist in 2.7. Is this an oversight or is there a reason for
it?

I can rewrite the code (back) to work with Popen again, but I found
the getstatusoutput elegant.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [next] | [standalone]


#90879

FromJon Ribbens <jon+usenet@unequivocal.co.uk>
Date2015-05-19 17:37 +0000
Message-ID<slrnmlmt9q.864.jon+usenet@frosty.unequivocal.co.uk>
In reply to#90877
On 2015-05-19, Cecil Westerhof <Cecil@decebal.nl> wrote:
> At the moment I want my code to run with 2.7 and 3.4+.
>
> But the command:
>     subprocess.getstatusoutput
> does not exist in 2.7. Is this an oversight or is there a reason for
> it?
>
> I can rewrite the code (back) to work with Popen again, but I found
> the getstatusoutput elegant.

It's in the 'commands' module in Python 2. You could use the
following:

  try:
      from subprocess import getstatusoutput
  except ImportError:
      from commands import getstatusoutput

[toc] | [prev] | [next] | [standalone]


#90891

FromCecil Westerhof <Cecil@decebal.nl>
Date2015-05-19 21:07 +0200
Message-ID<878ucktmhq.fsf@Equus.decebal.nl>
In reply to#90879
Op Tuesday 19 May 2015 19:37 CEST schreef Jon Ribbens:

> On 2015-05-19, Cecil Westerhof <Cecil@decebal.nl> wrote:
>> At the moment I want my code to run with 2.7 and 3.4+.
>>
>> But the command: subprocess.getstatusoutput does not exist in 2.7.
>> Is this an oversight or is there a reason for it?
>>
>> I can rewrite the code (back) to work with Popen again, but I found
>> the getstatusoutput elegant.
>
> It's in the 'commands' module in Python 2. You could use the
> following:
>
> try:
> from subprocess import getstatusoutput
> except ImportError:
> from commands import getstatusoutput

Works like a charm. Thanks.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web