redirecting output of yade.timing.stats()

Asked by ipemath

Can I redirect the output of yade.timing.stats() to a file inorder to store the run time details. I am running the simulation remotely hence such a provision if available will be very useful.

Question information

Language:
English Edit question
Status:
Answered
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Anton Gladky (gladky-anton) said :
#1

You can save all output of Yade into the file. Does it not solve you problem?

yade script.py > out.txt

Anton

Revision history for this message
ipemath (ipemathew1984) said :
#2

I use O.exitNoBacktrace() at the end of the script to return the control to terminal. If I use "yade script.py > out.txt" I wont get the control bacck to terminal

Revision history for this message
Jan Stránský (honzik) said :
#3

You can redirect python output using sys.stdout (btw. the very first google
link "python redirect output"):

###############################
from yade import timing
import sys
sys.stdout = open('/tmp/timing.txt','w')
timing.stats()
###############################

or also returning original stdout back:

###############################
from yade import timing
import sys

print 'whatever'
f = open('/tmp/timing.txt','w')
sys.stdout = f
print 'whatever2'
timing.stats()
sys.stdout = sys.__stdout__
f.close()
print 'whatever3'
###############################

cheers
Jan

2015-08-26 19:16 GMT+02:00 ipemath <email address hidden>:

> Question #270774 on Yade changed:
> https://answers.launchpad.net/yade/+question/270774
>
> Status: Answered => Open
>
> ipemath is still having a problem:
> I use O.exitNoBacktrace() at the end of the script to return the control
> to terminal. If I use "yade script.py > out.txt" I wont get the control
> bacck to terminal
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>

Can you help with this problem?

Provide an answer of your own, or ask ipemath for more information if necessary.

To post a message you must log in.