Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/twisted_8_1/twisted/persisted/journal/picklelog.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 #
5 # -*- test-case-name: twisted.test.test_journal -*-
6
7 """Logging that uses pickles.
8
9 TODO: add log that logs to a file.
10 """
11
12 # twisted imports
13 from twisted.persisted import dirdbm
14 from twisted.internet import defer
15 from zope.interface import implements
16
17 # sibling imports
18 import base
19
20
21 class DirDBMLog:
22 """Log pickles to DirDBM directory."""
23
24 implements(base.ICommandLog)
25
26 def __init__(self, logPath):
27 self.db = dirdbm.Shelf(logPath)
28 indexs = map(int, self.db.keys())
29 if indexs:
30 self.currentIndex = max(indexs)
31 else:
32 self.currentIndex = 0
33
34 def logCommand(self, command, time):
35 """Log a command."""
36 self.currentIndex += 1
37 self.db[str(self.currentIndex)] = (time, command)
38 return defer.succeed(1)
39
40 def getCurrentIndex(self):
41 """Return index of last command logged."""
42 return self.currentIndex
43
44 def getCommandsSince(self, index):
45 result = []
46 for i in range(index, self.currentIndex + 1):
47 result.append(self.db[str(i)])
48 return result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698