Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Suppress PSSE output entirely

Hello forum,

I have managed to find quite a few roundabout solutions to my problems with PSSE, but this one continues to annoy me.

I want to make it so that when using psspy, I do not get tons of text printed to the terminal. There was a time when I was able to circumvent this by using psspy.report_output to send the output to a text file, but that no longer appears to work.

According to the API manual, there is an option "6" for report_output that states "no output." That would be great if that option actually delivered what it promised, but I still get tons of text output to the command terminal. Is there an easy way to get rid of this?

Suppress PSSE output entirely

Hello forum,

I have managed to find quite a few roundabout solutions to my problems with PSSE, but this one continues to annoy me.

I want to make it so that when using psspy, I do not get tons of text printed to the terminal. There was a time when I was able to circumvent this by using psspy.report_output to send the output to a text file, but that no longer appears to work.

According to the API manual, there is an option "6" for report_output that states "no output." That would be great if that option actually delivered what it promised, but I still get tons of text output to the command terminal. Is there an easy way to get rid of this?

EDIT:

I have tried chip's approach using contextmanager and setting sys.stdout to os.devnull, but to no avail. I even tried breaking up the use of the "with" statement into two methods like so:

def silence(file_object = None):
    """
    Discard stdout (i.e. write to null device) or
    optionally write to given file-like object.
    """
    if file_object is None:
        file_object = open(os.devnull, 'w')

    try:
        sys.stdout = file_object
    except:
        sys.stdout = OLD_STDOUT
    return

def unsilence():
    """
    Reset stdout to the terminal like normal
    """
    sys.stdout = OLD_STDOUT
    return

And then I even tried something like:

print "Checkpoint 0"
silence()
psspy.psseinit(50000)
print "Checkpoint 1"
unsilence()

However, the text created from psseinit still gets to the terminal somehow. Oddly enough, checkpoint 1 does not get printed. I'm stumped.

Suppress PSSE output entirely

Hello forum,

I have managed to find quite a few roundabout solutions to my problems with PSSE, but this one continues to annoy me.

I want to make it so that when using psspy, I do not get tons of text printed to the terminal. There was a time when I was able to circumvent this by using psspy.report_output to send the output to a text file, but that no longer appears to work.

According to the API manual, there is an option "6" for report_output that states "no output." That would be great if that option actually delivered what it promised, but I still get tons of text output to the command terminal. Is there an easy way to get rid of this?

EDIT:

I have tried chip's approach using contextmanager and setting sys.stdout to os.devnull, but to no avail. I even tried breaking up the use of the "with" statement into two methods like so:

OLD_STDOUT = sys.stdout    #Keep track of what the original output to terminal was
def silence(file_object = None):
    """
    Discard stdout (i.e. write to null device) or
    optionally write to given file-like object.
    """
    if file_object is None:
        file_object = open(os.devnull, 'w')

    try:
        sys.stdout = file_object
    except:
        sys.stdout = OLD_STDOUT
    return

def unsilence():
    """
    Reset stdout to the terminal like normal
    """
    sys.stdout = OLD_STDOUT
    return

And then I even tried something like:

print "Checkpoint 0"
silence()
psspy.psseinit(50000)
print "Checkpoint 1"
unsilence()

However, the text created from psseinit still gets to the terminal somehow. Oddly enough, checkpoint 1 does not get printed. I'm stumped.