예제 #1
0
	def __init__(self, filename, target_address = "\x00!!"):
		self.target_address = target_address
		self.filename = filename
		file = open(filename, "rb")
		data = file.read()
		file.close()
		chunks = util.fileChunks(data,c.MESSAGE_LENGTH)
		if len(chunks) > 33038209969: #max file size send allowed 100 GB
			raise Exception("File too big")
			
		length = util.get_length_bytes(len(chunks))       
		info_chunk = bytearray(length) + bytearray(bytes(filename,encoding = "utf-8"))
		chunks.insert(0,info_chunk)
		self.chunks = chunks
예제 #2
0
    def load_file(self,
                  filename,
                  address="\x00!!"):  #this stuff is annoying aaaaahhhhh
        self.pending_file_addresses_queue.append(address)
        file = open(filename, "rb")
        data = file.read()
        chunks = util.fileChunks(data, c.MESSAGE_LENGTH)
        if len(chunks) > 33038209969:  #max file size send allowed 100 GB
            print("File too big")

        filename = bytearray(bytes(filename, encoding="utf-8"))
        length = util.get_length_bytes(len(chunks))
        info_chunk = bytearray(length) + filename
        chunks.insert(0, info_chunk)
        self.file_transmit_queue.append(chunks)