Exemplo n.º 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)))
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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', ))
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 7
0
 def do(self, relpath):
     relpath = self.translate_client_path(relpath)
     self._backing_transport.delete(relpath)
     return request.SuccessfulSmartServerResponse(('ok', ))
Exemplo n.º 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))
Exemplo n.º 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, ))
Exemplo n.º 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', ))
Exemplo n.º 11
0
 def do_body(self, body_bytes):
     self._backing_transport.put_bytes(self._relpath, body_bytes,
                                       self._mode)
     return request.SuccessfulSmartServerResponse(('ok', ))
Exemplo n.º 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', ))
Exemplo n.º 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)