[IPython-user] profile and logplay

Cohen-Tanugi, Johann cohen@slac.stanford....
Thu Feb 28 11:43:18 CST 2008


hello,

I have an issue with replaying a logfile :
I have a test profile which imports os and that is it.

THen I do :
[cohen@jarrett GRBSCRIPTS]$ ipython -profile test -logfile toto.log
Activating auto-logging. Current session state plus future input saved.
Filename       : toto.log
Mode           : backup
Output logging : False
Raw input log  : False
Timestamping   : False
State          : active
*****************************************************
* TEST *
*****************************************************
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.3.svn.r3001 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: os.path.exists('toto.log')
Out[1]: True

In [2]:
Do you really want to exit ([y]/n)?

Now xhecking the log :

[cohen@jarrett GRBSCRIPTS]$ more toto.log
#log# Automatic Logger file. *** THIS MUST BE THE FIRST LINE ***
#log# DO NOT CHANGE THIS LINE OR THE TWO BELOW
#log# opts = Struct({'__allownew': True, 'logfile': 'toto.log', 'profile': ''})
#log# args = []
#log# It is safe to make manual edits below here.
#log#-----------------------------------------------------------------------
os.path.exists('toto.log')

But if I now try to replay it :

[cohen@jarrett GRBSCRIPTS]$ ipython -profile test -logplay toto.log
Activating auto-logging. Current session state plus future input saved.
Filename       : toto.log
Mode           : append
Output logging : False
Raw input log  : False
Timestamping   : False
State          : active
Replaying log...
Loading log file <toto.log> one line at a time...
Finished replaying log file <toto.log>

The following lines/blocks in file <toto.log> reported errors:
os.path.exists('toto.log')
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.3.svn.r3001 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: os
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)

/home/cohen/data1/WORK/GRBSCRIPTS/<ipython console> in <module>()

NameError: name 'os' is not defined

In [2]:
Do you really want to exit ([y]/n)?

So the replay announced that replayed failed with an error, and indeed os has not been imported.

On the other hand if I do :

[cohen@jarrett GRBSCRIPTS]$ ipython -profile test toto.log
*****************************************************
* TEST *
*****************************************************
Loading log file <toto.log> one line at a time...
Finished replaying log file <toto.log>
Python 2.5.1 (r251:54863, Oct 30 2007, 13:54:11)
Type "copyright", "credits" or "license" for more information.

IPython 0.8.3.svn.r3001 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: os
Out[1]: <module 'os' from '/usr/lib/python2.5/os.pyc'>

In [2]:
Do you really want to exit ([y]/n)?
[cohen@jarrett GRBSCRIPTS]$

which means that there was no replay, but at least the import from the profile was honored....

I am lost; What is going on?

thanks,
Johann


More information about the IPython-user mailing list