def load(file_iterator):
    mem_cnt = 0
    data = []
    for line in file_iterator:
        line = line.strip().split("\t")
        data.append(line)
        mem_cnt = sys.getsize(data)
        if mem_cnt >= max_mem: 
            return data
    return data
Example #2
0
 def sendData(self, data, binary= False, size= None):
     if size is None:
         size = str(sys.getsize(data)).zfill(1024)
     try:
         self.socket.send(str(size).encode('utf-8'))
         if not binary:
             self.socket.send((str(0).zfill(1024)).encode('utf-8'))
             self.socket.send(data.encode('utf-8'))
         else:
             self.socket.send((str(1).zfill(1024)).encode('utf-8'))
             self.socket.send(data)
         return True
     
     except:
         self.socket.send("$ERROR$".zfill(int(size)))
         return False
Example #3
0
 def sendData(self, data, size= None): #The backbone of our socket connections ability to send data, all functions concerning sending data go through here
     if size is None:
         size = str(sys.getsize(data)).zfill(1024) #padds the gile size until it is a 1024 bit chunk, as that is what the recieving end expects
     try:
         self.socket.send(str(size).encode('utf-8'))
         if not binary: #b is sent to confirm the message is not intended to be in binary, a p confirms the message is intended to be bianary data
             self.socket.send((str('b').zfill(1024)).encode('utf-8'))
             #data = encryptData(data)
             self.socket.send(data.encode('utf-8')) #now the data can be sent as one full size as the other end knows what size to expect
         else:
             self.socket.send((str(1).zfill(1024)))
             #data = self.encryptData(data) #encrypts the data
             self.socket.send(data)
         return True
     except: #this message is sent to notify of an error on the other side
         self.socket.send("$ERROR$".zfill(int(size)))
         return False