Skip to content
Snippets Groups Projects
Select Git revision
  • ee863d5e9b0a9b161301080b20bc4b1982218a89
  • master default protected
2 results

file_class.py

Blame
  • file_class.py 788 B
    import packet_class
    
    class File:
        def __init__(self, filename):
            self.filename = filename
            self.packet = None
            self.data = ""
        
        def RRQ(self):
            self.packet = packet_class.Packet(1,fileName=self.filename)
    
        def WRQ(self):
            self.data = open(self.filename)
            self.packet = packet_class.Packet(2,fileName=self.filename)
    
        def Data(self,block,data):
            self.packet = packet_class.Packet(3,block=block,data=data)
            
        def ACK(self,block):
            self.packet = packet_class.Packet(4,block=block)
            
        def Error(self,code,msg):
            self.packet = packet_class.Packet(5,errorCode=code,errorMsg=msg)
    
        def getPacket(self):
            return self.packet
            
        def receivePacket(self, d):
            self.data += d