Mercurial > public > mercurial-scm > hg-stable
annotate hgext/inotify/common.py @ 8386:4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Instead of having a single possible request format, introduce a dictionary
of possible messages in inotify.common
author | Nicolas Dumazet <nicdumz.commits@gmail.com> |
---|---|
date | Thu, 14 May 2009 15:48:47 +0200 |
parents | 46293a0c7e9f |
children | e387ecd7a6ed |
rev | line source |
---|---|
6239 | 1 # server.py - inotify common protocol code |
2 # | |
3 # Copyright 2006, 2007, 2008 Bryan O'Sullivan <bos@serpentine.com> | |
4 # Copyright 2007, 2008 Brendan Cully <brendan@kublai.com> | |
5 # | |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
6239
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
6239
diff
changeset
|
7 # GNU General Public License version 2, incorporated herein by reference. |
6239 | 8 |
9 import cStringIO, socket, struct | |
10 | |
11 version = 1 | |
12 | |
8386
4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8225
diff
changeset
|
13 resphdrfmts = { |
4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8225
diff
changeset
|
14 'STAT': '>llllllll' # status requests |
4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8225
diff
changeset
|
15 } |
4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8225
diff
changeset
|
16 resphdrsizes = dict((k, struct.calcsize(v)) |
4aad982111b6
inotify: Abstract the layer format and sizes to a inotify.common dictionary
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents:
8225
diff
changeset
|
17 for k, v in resphdrfmts.iteritems()) |
6239 | 18 |
19 def recvcs(sock): | |
20 cs = cStringIO.StringIO() | |
21 s = True | |
22 try: | |
23 while s: | |
24 s = sock.recv(65536) | |
25 cs.write(s) | |
26 finally: | |
27 sock.shutdown(socket.SHUT_RD) | |
28 cs.seek(0) | |
29 return cs |