Пример #1
0
 def do(self, relpath):
     if not relpath.endswith('/'):
         relpath += '/'
     relpath = self.translate_client_path(relpath)
     stat = self._backing_transport.stat(relpath)
     return request.SuccessfulSmartServerResponse(
         ('stat', str(stat.st_size), oct(stat.st_mode)))
Пример #2
0
 def do(self, relpath):
     if not relpath.endswith('/'):
         relpath += '/'
     relpath = self.translate_client_path(relpath)
     filenames = self._backing_transport.list_dir(relpath)
     return request.SuccessfulSmartServerResponse(('names', ) +
                                                  tuple(filenames))
Пример #3
0
 def do_body(self, body_bytes):
     """accept offsets for a readv request."""
     offsets = self._deserialise_offsets(body_bytes)
     backing_bytes = ''.join(
         bytes for offset, bytes in self._backing_transport.readv(
             self._relpath, offsets))
     return request.SuccessfulSmartServerResponse(('readv', ),
                                                  backing_bytes)
Пример #4
0
 def do_body(self, body_bytes):
     self._backing_transport.put_bytes_non_atomic(
         self._relpath,
         body_bytes,
         mode=self._mode,
         create_parent_dir=self._create_parent,
         dir_mode=self._dir_mode)
     return request.SuccessfulSmartServerResponse(('ok', ))
Пример #5
0
 def do(self, relpath):
     if not relpath.endswith('/'):
         relpath += '/'
     relpath = self.translate_client_path(relpath)
     transport = self._backing_transport.clone(relpath)
     filenames = transport.iter_files_recursive()
     return request.SuccessfulSmartServerResponse(('names', ) +
                                                  tuple(filenames))
Пример #6
0
 def do(self, relpath):
     relpath = self.translate_client_path(relpath)
     try:
         backing_bytes = self._backing_transport.get_bytes(relpath)
     except errors.ReadError:
         # cannot read the file
         return request.FailedSmartServerResponse(('ReadError', ))
     except errors.PermissionDenied:
         return request.FailedSmartServerResponse(('PermissionDenied', ))
     return request.SuccessfulSmartServerResponse(('ok', ), backing_bytes)
Пример #7
0
 def do(self, relpath):
     relpath = self.translate_client_path(relpath)
     self._backing_transport.delete(relpath)
     return request.SuccessfulSmartServerResponse(('ok', ))
Пример #8
0
 def do_body(self, body_bytes):
     old_length = self._backing_transport.append_bytes(
         self._relpath, body_bytes, self._mode)
     return request.SuccessfulSmartServerResponse(
         ('appended', '%d' % old_length))
Пример #9
0
 def do(self, relpath):
     relpath = self.translate_client_path(relpath)
     r = self._backing_transport.has(relpath) and 'yes' or 'no'
     return request.SuccessfulSmartServerResponse((r, ))
Пример #10
0
 def do(self, rel_from, rel_to):
     rel_from = self.translate_client_path(rel_from)
     rel_to = self.translate_client_path(rel_to)
     self._backing_transport.rename(rel_from, rel_to)
     return request.SuccessfulSmartServerResponse(('ok', ))
Пример #11
0
 def do_body(self, body_bytes):
     self._backing_transport.put_bytes(self._relpath, body_bytes,
                                       self._mode)
     return request.SuccessfulSmartServerResponse(('ok', ))
Пример #12
0
 def do(self, relpath, mode):
     relpath = self.translate_client_path(relpath)
     self._backing_transport.mkdir(relpath,
                                   _deserialise_optional_mode(mode))
     return request.SuccessfulSmartServerResponse(('ok', ))
 def do(self):
     return request.SuccessfulSmartServerResponse(('ok', ))
Пример #14
0
 def do(self, relpath):
     relpath = self.translate_client_path(relpath)
     backing_bytes = self._backing_transport.get_bytes(relpath)
     return request.SuccessfulSmartServerResponse(('ok', ), backing_bytes)