def read(self, addr, rpath, size, offset): req_data = self._read_struct.pack(size, offset) + rpath sock = ellnet.init_request(self._dev, addr, TCP_PORT, PKT_READ_FILE, req_data) return ellnet.recv_block(sock)
def get_listing(self, addr, path): path = path.encode('utf8') sock = ellnet.init_request( self._dev, addr, TCP_PORT, PKT_LISTING_REQ, path) data = ellnet.recv_block(sock).decode('utf8') strs = data.split('\0') dirs, files = [], [] for i in range(0, len(strs), 2): name = strs[i] size = int(strs[i + 1]) if size == -1: dirs.append(name) else: files.append((name, size)) return dirs, files
def get_listing(self, addr, path): path = path.encode('utf8') sock = ellnet.init_request(self._dev, addr, TCP_PORT, PKT_LISTING_REQ, path) data = ellnet.recv_block(sock).decode('utf8') strs = data.split('\0') dirs, files = [], [] for i in range(0, len(strs), 2): name = strs[i] size = int(strs[i + 1]) if size == -1: dirs.append(name) else: files.append((name, size)) return dirs, files