Beispiel #1
0
Datei: vfs.py Projekt: bup/bup
def write_resolution(port, resolution):
    write_vuint(port, len(resolution))
    for name, item in resolution:
        write_bvec(port, name)
        if item:
            port.write(b'\1')
            write_item(port, item)
        else:
            port.write(b'\0')
Beispiel #2
0
def write_resolution(port, resolution):
    write_vuint(port, len(resolution))
    for name, item in resolution:
        write_bvec(port, name)
        if item:
            port.write(b'\x01')
            write_item(port, item)
        else:
            port.write(b'\x00')
Beispiel #3
0
def write_ioerror(port, ex):
    assert isinstance(ex, IOError)
    write_vuint(port, (1 if ex.errno is not None else 0)
                | (2 if ex.strerror is not None else 0)
                | (4 if ex.terminus is not None else 0))
    if ex.errno is not None:
        write_vint(port, ex.errno)
    if ex.strerror is not None:
        write_bvec(port, ex.strerror.encode('utf-8'))
    if ex.terminus is not None:
        write_resolution(port, ex.terminus)
Beispiel #4
0
 def write(self, port, include_path=True):
     records = include_path and [(_rec_tag_path, self._encode_path())] or []
     records.extend([(_rec_tag_common, self._encode_common()),
                     (_rec_tag_symlink_target, self._encode_symlink_target()),
                     (_rec_tag_posix1e_acl, self._encode_posix1e_acl()),
                     (_rec_tag_linux_attr, self._encode_linux_attr()),
                     (_rec_tag_linux_xattr, self._encode_linux_xattr())])
     for tag, data in records:
         if data:
             vint.write_vuint(port, tag)
             vint.write_bvec(port, data)
     vint.write_vuint(port, _rec_tag_end)
Beispiel #5
0
Datei: vfs.py Projekt: bup/bup
def write_ioerror(port, ex):
    assert isinstance(ex, IOError)
    write_vuint(port,
                (1 if ex.errno is not None else 0)
                | (2 if ex.message is not None else 0)
                | (4 if ex.terminus is not None else 0))
    if ex.errno is not None:
        write_vint(port, ex.errno)
    if ex.message is not None:
        write_bvec(port, ex.message.encode('utf-8'))
    if ex.terminus is not None:
        write_resolution(port, ex.terminus)
Beispiel #6
0
 def write(self, port, include_path=True):
     records = include_path and [(_rec_tag_path, self._encode_path())] or []
     records.extend([(_rec_tag_common, self._encode_common()),
                     (_rec_tag_symlink_target, self._encode_symlink_target()),
                     (_rec_tag_posix1e_acl, self._encode_posix1e_acl()),
                     (_rec_tag_linux_attr, self._encode_linux_attr()),
                     (_rec_tag_linux_xattr, self._encode_linux_xattr())])
     for tag, data in records:
         if data:
             vint.write_vuint(port, tag)
             vint.write_bvec(port, data)
     vint.write_vuint(port, _rec_tag_end)
Beispiel #7
0
 def path_info(self, paths):
     self.check_busy()
     self.conn.write('path-info\n')
     if not isinstance(paths, list):  # FIXME: check for "not oneshot".
         paths = list(paths)
     vint.write_vuint(self.conn, len(paths))
     for path in paths:
         vint.write_bvec(self.conn, path)
     result = []
     for path in paths:
         data = vint.read_bvec(self.conn)
         if data:
             result.append(vint.unpack('sss', data))
         else:
             result.append(None)
     self.check_ok()
     return result
Beispiel #8
0
def encode_and_decode_vuint(x):
    f = BytesIO()
    vint.write_vuint(f, x)
    return vint.read_vuint(BytesIO(f.getvalue()))
Beispiel #9
0
Datei: tvint.py Projekt: 3v/bup
def encode_and_decode_vuint(x):
    f = StringIO()
    vint.write_vuint(f, x)
    return vint.read_vuint(StringIO(f.getvalue()))
Beispiel #10
0
def encode_and_decode_vuint(x):
    f = BytesIO()
    vint.write_vuint(f, x)
    return vint.read_vuint(BytesIO(f.getvalue()))
Beispiel #11
0
def encode_and_decode_vuint(x):
    f = StringIO()
    vint.write_vuint(f, x)
    return vint.read_vuint(StringIO(f.getvalue()))