def frecv(self): data, serviceName = self.mrecv(1024) if not data: return None, None file = FileMessage() file.decodeFileMessage(data) if serviceName != 'file': print('Bad file service name', file.serviceName) return None, None return file.headers, file.data
def frecv(self): data, serviceName=self.mrecv(1024) if not data: return None, None file=FileMessage() file.decodeFileMessage(data) if serviceName!='file': print('Bad file service name', file.serviceName) return None, None return file.headers, file.data
def getMeta(self, msock, headers, data, addr): print('getMeta') file=headers['file'] result={'command': 'putMeta', 'file': file} result['length']=os.path.getsize(self.config['root']+'/'+file) fmsg=FileMessage() fmsg.createFileMessage(result, None) msock.msendto(fmsg.message, addr, service='file')
def getMeta(self, msock, headers, data, addr): print('getMeta') file = headers['file'] result = {'command': 'putMeta', 'file': file} result['length'] = os.path.getsize(self.config['root'] + '/' + file) fmsg = FileMessage() fmsg.createFileMessage(result, None) msock.msendto(fmsg.message, addr, service='file')
def handle(self, msock, msg, addr): print('-----------------') print(msg.decode('ascii')) fmsg=FileMessage() fmsg.decodeFileMessage(msg) cmd=fmsg.headers['command'] if cmd in self.commands: f=self.commands[cmd] f(msock, fmsg.headers, fmsg.data, addr) else: print('Unknown file command', cmd) return
def handle(self, msock, msg, addr): print('-----------------') print(msg.decode('ascii')) fmsg = FileMessage() fmsg.decodeFileMessage(msg) cmd = fmsg.headers['command'] if cmd in self.commands: f = self.commands[cmd] f(msock, fmsg.headers, fmsg.data, addr) else: print('Unknown file command', cmd) return
def get(self, msock, headers, data, addr): file=headers['file'] offset=headers['offset'] f=open(self.config['root']+'/'+file, 'rb') f.seek(offset) bs=f.read(self.blockSize) f.close() result={'command': 'put', 'file': file, 'offset': offset} fmsg=FileMessage() fmsg.createFileMessage(result, bs) msock.msendto(fmsg.message, addr, service='file')
def get(self, msock, headers, data, addr): file = headers['file'] offset = headers['offset'] f = open(self.config['root'] + '/' + file, 'rb') f.seek(offset) bs = f.read(self.blockSize) f.close() result = {'command': 'put', 'file': file, 'offset': offset} fmsg = FileMessage() fmsg.createFileMessage(result, bs) msock.msendto(fmsg.message, addr, service='file')
def fsend(self, headers, data): fmsg=FileMessage() fmsg.createFileMessage(headers, data) self.msend(fmsg.message, service='file')
def fsendto(self, headers, data, addr): file=FileMessage() file.createFileMessage(headers, data) self.msendto(file.message, addr)
def fsend(self, headers, data): fmsg = FileMessage() fmsg.createFileMessage(headers, data) self.msend(fmsg.message, service='file')
def fsendto(self, headers, data, addr): file = FileMessage() file.createFileMessage(headers, data) self.msendto(file.message, addr)