HistoryManager.get_session_info() #679

Merged
merged 3 commits into from Aug 17, 2011

Projects

None yet

3 participants

@minrk
IPython member

add simple get_session_info method to HistoryManager for fetching session timestamps, etc.

Also sets detect_types flags on the db connection, so timestamps are retrieved as datetime objects.

The test history file has been moved to a tempdir, so that we don't get test_hist.sqlite files all over the filesystem when running the test suite.

minrk added some commits Aug 4, 2011
@minrk minrk put test_hist.sqlite in tempdir, to prevent polluting filesystem 0279eb0
@minrk minrk add get_session_info to HistoryManager for querying session table
Also set detect_types flags on the connection, so timestamps are
retrieved as datetime objects.

Associated type checking test included.
30c9fcb
@takluyver
IPython member

This seems sensible. I'm planning, when I have time, to pull out the methods for reading history into a HistoryAccessor class which can be instantiated without an InteractiveShell, so it can be used by tools for browsing or dumping history. HistoryManager will then subclass that, and add the methods for storing history from the shell.

@fperez fperez commented on an outdated diff Aug 16, 2011
IPython/testing/tools.py
@@ -170,7 +171,7 @@ def default_config():
config.TerminalInteractiveShell.colors = 'NoColor'
config.TerminalTerminalInteractiveShell.term_title = False,
config.TerminalInteractiveShell.autocall = 0
- config.HistoryManager.hist_file = u'test_hist.sqlite'
+ config.HistoryManager.hist_file = os.path.join(tempfile.mkdtemp(), u'test_hist.sqlite')
@fperez
fperez Aug 16, 2011

This file should be added to the list of files we delete on exit, so that we clean up after ourselves. But instead of making a temp directory, let's simply make a temp file with the suffix 'test_hist.sqlite'. Then the cleanup is simply a matter of removing the file on exit, which can be done by registering it with the ipython instance's .tempfiles attribute, that all get deleted at interpeter shutdown time.

@minrk minrk add test history db to shell.tempfiles for cleanup
* end_history_session moved before tempfile cleanup in shell.atexit_operations,
  to prevent access to file after deletion
503aeea
@fperez fperez merged commit 9dfe802 into ipython:master Aug 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment