Il mio obiettivo è quello di chiamare ipython
, mentre anche la registrazione tutti gli input/output a IPython, e vedere qualcosa di simile:Come posso registrare l'output di IPython senza le brutte 7 righe di informazioni di registrazione su ogni carico?
[email protected] ~ $ ipython
In [1]: exit
[email protected] ~ $
Il banner può essere rimosso facilmente se ho impostato
c.TerminalIPythonApp.display_banner = False
in il mio file ~/.ipython/profile-default/ipython_config.py
.
Ma come faccio a pulire questo avvio mentre registro anche le cose?
Su una nuova installazione, se mi metto IPython senza parametri vedo:
[email protected] ~ $ ipython
Python 2.7.3 (default, Jun 20 2013, 12:50:58)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit
[email protected] ~ $
Se mi passa un argomento logfile=logfile.txt
quando si richiama IPython vedo:
[email protected] ~ $ ipython --logfile=logfile.txt
Activating auto-logging. Current session state plus future input saved.
Filename : logfile.txt
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
Python 2.7.3 (default, Jun 20 2013, 12:50:58)
Type "copyright", "credits" or "license" for more information.
IPython 0.13.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: exit
[email protected] ~ $
Come posso usare registrazione senza aggiungere la confusione extra al mio terminale:
Activating auto-logging. Current session state plus future input saved.
Filename : logfile.txt
Mode : backup
Output logging : False
Raw input log : False
Timestamping : False
State : active
su altre macchine che ho IPython configurato per registrare automaticamente le cose da avere un .ipython/profile_default/startup/01-log-everything.py
che contiene le linee:
from time import strftime
import os.path
ip = get_ipython()
ldir = ip.profile_dir.log_dir
fname = strftime('%Y-%m-%d-%H-%M-%S') + ".py"
filename = os.path.join(ldir, fname)
ip.run_line_magic('logstart', '-o %s append' % filename)
che si traduce nello stesso disordine come quando aggiungo --logfile=logfile.txt
Qualsiasi aiuto su come farlo correttamente questo sarebbe apprezzato. Potrei, se non altro, reindirizzare sys.stdout, configurare il logging e quindi resettare sys.stdout ma spero che ci sia una soluzione meno hackerata.
Una domanda simile è stato chiesto qui: http: // StackOverflow.it/questions/947810 – BugoK
@BugoK, grazie - la domanda in quel post è un po 'simile, suppongo, ma quello che sto cercando di fare è molto specifico e non è indirizzato in quel post o altrove, come meglio posso dire. –