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

Side by Side Diff: third_party/twisted_8_1/twisted/conch/interfaces.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) 2007 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 from zope.interface import Interface
5
6 class IConchUser(Interface):
7 """A user who has been authenticated to Cred through Conch. This is
8 the interface between the SSH connection and the user.
9
10 @ivar conn: The SSHConnection object for this user.
11 """
12
13 def lookupChannel(channelType, windowSize, maxPacket, data):
14 """
15 The other side requested a channel of some sort.
16 channelType is the type of channel being requested,
17 windowSize is the initial size of the remote window,
18 maxPacket is the largest packet we should send,
19 data is any other packet data (often nothing).
20
21 We return a subclass of L{SSHChannel<ssh.channel.SSHChannel>}. If
22 an appropriate channel can not be found, an exception will be
23 raised. If a L{ConchError<error.ConchError>} is raised, the .value
24 will be the message, and the .data will be the error code.
25
26 @type channelType: C{str}
27 @type windowSize: C{int}
28 @type maxPacket: C{int}
29 @type data: C{str}
30 @rtype: subclass of L{SSHChannel}/C{tuple}
31 """
32
33 def lookupSubsystem(subsystem, data):
34 """
35 The other side requested a subsystem.
36 subsystem is the name of the subsystem being requested.
37 data is any other packet data (often nothing).
38
39 We return a L{Protocol}.
40 """
41
42 def gotGlobalRequest(requestType, data):
43 """
44 A global request was sent from the other side.
45
46 By default, this dispatches to a method 'channel_channelType' with any
47 non-alphanumerics in the channelType replace with _'s. If it cannot
48 find a suitable method, it returns an OPEN_UNKNOWN_CHANNEL_TYPE error.
49 The method is called with arguments of windowSize, maxPacket, data.
50 """
51
52 class ISession(Interface):
53
54 def getPty(term, windowSize, modes):
55 """
56 Get a psuedo-terminal for use by a shell or command.
57
58 If a psuedo-terminal is not available, or the request otherwise
59 fails, raise an exception.
60 """
61
62 def openShell(proto):
63 """
64 Open a shell and connect it to proto.
65
66 @param proto: a L{ProcessProtocol} instance.
67 """
68
69 def execCommand(proto, command):
70 """
71 Execute a command.
72
73 @param proto: a L{ProcessProtocol} instance.
74 """
75
76 def windowChanged(newWindowSize):
77 """
78 Called when the size of the remote screen has changed.
79 """
80
81 def eofReceived():
82 """
83 Called when the other side has indicated no more data will be sent.
84 """
85
86 def closed():
87 """
88 Called when the session is closed.
89 """
90
91
92 class ISFTPServer(Interface):
93 """
94 The only attribute of this class is "avatar". It is the avatar
95 returned by the Realm that we are authenticated with, and
96 represents the logged-in user. Each method should check to verify
97 that the user has permission for their actions.
98 """
99
100 def gotVersion(otherVersion, extData):
101 """
102 Called when the client sends their version info.
103
104 otherVersion is an integer representing the version of the SFTP
105 protocol they are claiming.
106 extData is a dictionary of extended_name : extended_data items.
107 These items are sent by the client to indicate additional features.
108
109 This method should return a dictionary of extended_name : extended_data
110 items. These items are the additional features (if any) supported
111 by the server.
112 """
113 return {}
114
115 def openFile(filename, flags, attrs):
116 """
117 Called when the clients asks to open a file.
118
119 @param filename: a string representing the file to open.
120
121 @param flags: an integer of the flags to open the file with, ORed togeth er.
122 The flags and their values are listed at the bottom of this file.
123
124 @param attrs: a list of attributes to open the file with. It is a
125 dictionary, consisting of 0 or more keys. The possible keys are::
126
127 size: the size of the file in bytes
128 uid: the user ID of the file as an integer
129 gid: the group ID of the file as an integer
130 permissions: the permissions of the file with as an integer.
131 the bit representation of this field is defined by POSIX.
132 atime: the access time of the file as seconds since the epoch.
133 mtime: the modification time of the file as seconds since the epoch.
134 ext_*: extended attributes. The server is not required to
135 understand this, but it may.
136
137 NOTE: there is no way to indicate text or binary files. it is up
138 to the SFTP client to deal with this.
139
140 This method returns an object that meets the ISFTPFile interface.
141 Alternatively, it can return a L{Deferred} that will be called back
142 with the object.
143 """
144
145 def removeFile(filename):
146 """
147 Remove the given file.
148
149 This method returns when the remove succeeds, or a Deferred that is
150 called back when it succeeds.
151
152 @param filename: the name of the file as a string.
153 """
154
155 def renameFile(oldpath, newpath):
156 """
157 Rename the given file.
158
159 This method returns when the rename succeeds, or a L{Deferred} that is
160 called back when it succeeds. If the rename fails, C{renameFile} will
161 raise an implementation-dependent exception.
162
163 @param oldpath: the current location of the file.
164 @param newpath: the new file name.
165 """
166
167 def makeDirectory(path, attrs):
168 """
169 Make a directory.
170
171 This method returns when the directory is created, or a Deferred that
172 is called back when it is created.
173
174 @param path: the name of the directory to create as a string.
175 @param attrs: a dictionary of attributes to create the directory with.
176 Its meaning is the same as the attrs in the L{openFile} method.
177 """
178
179 def removeDirectory(path):
180 """
181 Remove a directory (non-recursively)
182
183 It is an error to remove a directory that has files or directories in
184 it.
185
186 This method returns when the directory is removed, or a Deferred that
187 is called back when it is removed.
188
189 @param path: the directory to remove.
190 """
191
192 def openDirectory(path):
193 """
194 Open a directory for scanning.
195
196 This method returns an iterable object that has a close() method,
197 or a Deferred that is called back with same.
198
199 The close() method is called when the client is finished reading
200 from the directory. At this point, the iterable will no longer
201 be used.
202
203 The iterable should return triples of the form (filename,
204 longname, attrs) or Deferreds that return the same. The
205 sequence must support __getitem__, but otherwise may be any
206 'sequence-like' object.
207
208 filename is the name of the file relative to the directory.
209 logname is an expanded format of the filename. The recommended format
210 is:
211 -rwxr-xr-x 1 mjos staff 348911 Mar 25 14:29 t-filexfer
212 1234567890 123 12345678 12345678 12345678 123456789012
213
214 The first line is sample output, the second is the length of the field.
215 The fields are: permissions, link count, user owner, group owner,
216 size in bytes, modification time.
217
218 attrs is a dictionary in the format of the attrs argument to openFile.
219
220 @param path: the directory to open.
221 """
222
223 def getAttrs(path, followLinks):
224 """
225 Return the attributes for the given path.
226
227 This method returns a dictionary in the same format as the attrs
228 argument to openFile or a Deferred that is called back with same.
229
230 @param path: the path to return attributes for as a string.
231 @param followLinks: a boolean. If it is True, follow symbolic links
232 and return attributes for the real path at the base. If it is False,
233 return attributes for the specified path.
234 """
235
236 def setAttrs(path, attrs):
237 """
238 Set the attributes for the path.
239
240 This method returns when the attributes are set or a Deferred that is
241 called back when they are.
242
243 @param path: the path to set attributes for as a string.
244 @param attrs: a dictionary in the same format as the attrs argument to
245 L{openFile}.
246 """
247
248 def readLink(path):
249 """
250 Find the root of a set of symbolic links.
251
252 This method returns the target of the link, or a Deferred that
253 returns the same.
254
255 @param path: the path of the symlink to read.
256 """
257
258 def makeLink(linkPath, targetPath):
259 """
260 Create a symbolic link.
261
262 This method returns when the link is made, or a Deferred that
263 returns the same.
264
265 @param linkPath: the pathname of the symlink as a string.
266 @param targetPath: the path of the target of the link as a string.
267 """
268
269 def realPath(path):
270 """
271 Convert any path to an absolute path.
272
273 This method returns the absolute path as a string, or a Deferred
274 that returns the same.
275
276 @param path: the path to convert as a string.
277 """
278
279 def extendedRequest(extendedName, extendedData):
280 """
281 This is the extension mechanism for SFTP. The other side can send us
282 arbitrary requests.
283
284 If we don't implement the request given by extendedName, raise
285 NotImplementedError.
286
287 The return value is a string, or a Deferred that will be called
288 back with a string.
289
290 @param extendedName: the name of the request as a string.
291 @param extendedData: the data the other side sent with the request,
292 as a string.
293 """
294
295 class ISFTPFile(Interface):
296 """
297 This represents an open file on the server. An object adhering to this
298 interface should be returned from L{openFile}().
299 """
300
301 def close():
302 """
303 Close the file.
304
305 This method returns nothing if the close succeeds immediately, or a
306 Deferred that is called back when the close succeeds.
307 """
308
309 def readChunk(offset, length):
310 """
311 Read from the file.
312
313 If EOF is reached before any data is read, raise EOFError.
314
315 This method returns the data as a string, or a Deferred that is
316 called back with same.
317
318 @param offset: an integer that is the index to start from in the file.
319 @param length: the maximum length of data to return. The actual amount
320 returned may less than this. For normal disk files, however,
321 this should read the requested number (up to the end of the file).
322 """
323
324 def writeChunk(offset, data):
325 """
326 Write to the file.
327
328 This method returns when the write completes, or a Deferred that is
329 called when it completes.
330
331 @param offset: an integer that is the index to start from in the file.
332 @param data: a string that is the data to write.
333 """
334
335 def getAttrs():
336 """
337 Return the attributes for the file.
338
339 This method returns a dictionary in the same format as the attrs
340 argument to L{openFile} or a L{Deferred} that is called back with same.
341 """
342
343 def setAttrs(attrs):
344 """
345 Set the attributes for the file.
346
347 This method returns when the attributes are set or a Deferred that is
348 called back when they are.
349
350 @param attrs: a dictionary in the same format as the attrs argument to
351 L{openFile}.
352 """
353
354
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/conch/insults/window.py ('k') | third_party/twisted_8_1/twisted/conch/ls.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698