Ticket #3633 (closed defect: fixed)

Opened 2 months ago

Last modified 3 weeks ago

[witch patch, positive review] use commands.getoutput in hostinfo

Reported by: yi Assigned to: yi
Priority: major Milestone: sage-3.1
Component: dsage Keywords:
Cc:

Description

For some reason twisted trial is not too happy with using os.popen. Switching to commands.getouput to fetch system information on the mac seems to work better.

Attachments

hostinfo.patch (0.9 kB) - added by yi on 07/10/2008 09:56:01 AM.

Change History

07/10/2008 09:56:01 AM changed by yi

  • attachment hostinfo.patch added.

07/10/2008 10:06:09 AM changed by yi

Robert: commands.getoutput gets the output of a command. This is a little bit better than doing os.popen (what I was doing before) since it actually correctly opens/closes the pipes.

Definition:	commands.getstatusoutput(cmd)
Source:
def getstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
    text = pipe.read()
    sts = pipe.close()
    if sts is None: sts = 0
    if text[-1:] == '\n': text = text[:-1]
    return sts, text

07/10/2008 10:07:19 AM changed by rlm

  • summary changed from [witch patch, needs review] use commands.getoutput in hostinfo to [witch patch, positive review pending tests] use commands.getoutput in hostinfo.

+1

08/09/2008 08:44:27 PM changed by rlm

  • owner changed from rlm to yi.

08/09/2008 09:57:17 PM changed by mabshoff

  • summary changed from [witch patch, positive review pending tests] use commands.getoutput in hostinfo to [witch patch, positive review] use commands.getoutput in hostinfo.
  • milestone changed from sage-3.1.1 to sage-3.1.

This is doctested indirectly, so I am not concerned here about the doctest. Positive review.

Cheers,

Michael

08/09/2008 10:13:20 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged in Sage 3.1.alpha1