def __init__(self, path, controller): """ """ print 'in FileIOClientFactory class' self.path = path if ".enc" not in path: fileCrypto.encrypt_file('somekey', self.path) self.path = self.path+ ".enc" self.controller = controller
def send_file(self, filePath, address): port = self.send_port if ".enc" not in filePath: fileCrypto.encrypt_file('somekey', filePath) filePath = filePath+ ".enc" controller = type('test',(object,),{'cancel':False, 'total_sent':0,'completed':Deferred()}) f = FileIOClientFactory(filePath, controller) reactor.connectTCP(address, port, f) return controller.completed
def on_modified(self, event): source = event.src_path if source.find(".enc") != -1: return elif source.find(".goutputstream") == -1 and source[len(source)-1] != '~': print("File modified! (" + source + " at time: " + time.strftime("%Y-%m-%d %H:%M:%S")+ ")") if not event.is_directory: print 'calling modified method' if ".enc" not in source: fileCrypto.encrypt_file('somekey', source) source = source + ".enc" self.machine.modified(source)
def on_created(self, event): #Called on making new file #Should send file over to server source = event.src_path if source.find(".enc") != -1: return elif source.find(".goutputstream") == -1 and source[len(source)-1] != '~': print("File created! (" + source + " at time: " + time.strftime("%Y-%m-%d %H:%M:%S")+ ")") if not event.is_directory: if ".enc" not in source: fileCrypto.encrypt_file('somekey', source) source = source + ".enc" self.machine.created(source)
def send_file(self, filePath, address): # send to server (aka on my laptop) #transmitOne(filePath,'137.54.51.83',self.send_port) #transmitOne(filePath,port=self.send_port,address='localhost') #transmitOne(filePath, 'localhost',self.send_port) port = self.send_port if "MOV;" in filePath: moveMessage.sendFile(filePath, address, port) else: if ".enc" not in filePath: fileCrypto.encrypt_file('somekey', filePath) filePath = filePath+ ".enc" controller = type('test',(object,),{'cancel':False, 'total_sent':0,'completed':Deferred()}) f = FileIOClientFactory(filePath, controller) reactor.connectTCP(address, port, f) os.remove(filePath) return controller.completed
def __init__(self, path, controller): self.path = path if ".enc" not in path: fileCrypto.encrypt_file('somekey', self.path) self.path = self.path+ ".enc" self.controller = controller