##// END OF EJS Templates
Separate get_session_info between HistoryAccessor and HistoryManager...
Thomas Kluyver -
Show More
@@ -261,27 +261,36 b' class HistoryAccessor(Configurable):'
261 261 ----------
262 262
263 263 session : int
264 Session number to retrieve. The current session is 0, and negative
265 numbers count back from current session, so -1 is previous session.
264 Session number to retrieve.
266 265
267 266 Returns
268 267 -------
269
270 (session_id [int], start [datetime], end [datetime], num_cmds [int],
271 remark [unicode])
272
273 Sessions that are running or did not exit cleanly will have `end=None`
274 and `num_cmds=None`.
275
268
269 session_id : int
270 Session ID number
271 start : datetime
272 Timestamp for the start of the session.
273 end : datetime
274 Timestamp for the end of the session, or None if IPython crashed.
275 num_cmds : int
276 Number of commands run, or None if IPython crashed.
277 remark : unicode
278 A manually set description.
276 279 """
277
278 if session <= 0:
279 session += self.session_number
280
281 280 query = "SELECT * from sessions where session == ?"
282 281 return self.db.execute(query, (session,)).fetchone()
283 282
284 283 @catch_corrupt_db
284 def get_last_session_id(self):
285 """Get the last session ID currently in the database.
286
287 Within IPython, this should be the same as the value stored in
288 :attr:`HistoryManager.session_number`.
289 """
290 for record in self.get_tail(n=1, include_latest=True):
291 return record[0]
292
293 @catch_corrupt_db
285 294 def get_tail(self, n=10, raw=True, output=False, include_latest=False):
286 295 """Get the last n lines from the history database.
287 296
@@ -535,6 +544,35 b' class HistoryManager(HistoryAccessor):'
535 544 # ------------------------------
536 545 # Methods for retrieving history
537 546 # ------------------------------
547 def get_session_info(self, session=0):
548 """get info about a session
549
550 Parameters
551 ----------
552
553 session : int
554 Session number to retrieve. The current session is 0, and negative
555 numbers count back from current session, so -1 is previous session.
556
557 Returns
558 -------
559
560 session_id : int
561 Session ID number
562 start : datetime
563 Timestamp for the start of the session.
564 end : datetime
565 Timestamp for the end of the session, or None if IPython crashed.
566 num_cmds : int
567 Number of commands run, or None if IPython crashed.
568 remark : unicode
569 A manually set description.
570 """
571 if session <= 0:
572 session += self.session_number
573
574 return super(HistoryManager, self).get_session_info(session=session)
575
538 576 def _get_range_session(self, start=1, stop=None, raw=True, output=False):
539 577 """Get input and output history from the current session. Called by
540 578 get_range, and takes similar parameters."""
General Comments 0
You need to be logged in to leave comments. Login now