[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH 1/3] Use Popen instead of check_output (#706099)



On Thu, Aug 18, 2011 at 09:53:24AM +0200, Martin Gracik wrote:
> subprocess.check_output was introduced in python 2.7, in rhel
> we have python 2.6, so we need to use subprocess.Popen.
> ---
>  command-stubs/list-harddrives-test |    7 +++----
>  1 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/command-stubs/list-harddrives-test b/command-stubs/list-harddrives-test
> index 6c70a0f..92964e7 100644
> --- a/command-stubs/list-harddrives-test
> +++ b/command-stubs/list-harddrives-test
> @@ -25,13 +25,12 @@ import parted
>  
>  
>  def list_harddrives_test():
> -    try:
> -        output = check_output(['list-harddrives'])
> -    except CalledProcessError:
> +    proc = subprocess.Popen(['list-harddrives'], stdout=subprocess.PIPE)
> +    if proc.wait() != 0:
>          print('list-harddrives: list harddrives test failed')
>          sys.exit(1)
>  
> -    output = output.splitlines()
> +    output = proc.stdout.read().splitlines()
>  
>      devices = set()
>      for dev in parted.getAllDevices():
> -- 
> 1.7.3.2

Ack to all 3 of these.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)

Attachment: pgprzFGbqF3k8.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]