def sendFile(transferFile, filePath, timeStamp): channel = implementations.insecure_channel('localhost', 50050) stub = manager_django_pb2.beta_create_Manager_stub(channel) response = stub.SaveFile(manager_django_pb2.SaveRequest(save_file=transferFile, save_path=filePath, timestamp=timeStamp), _TIMEOUT_SECONDS) print response.transfer_status
def openFile(self, filePath, timeStamp): print "Reading file from Manager" channel = implementations.insecure_channel('localhost', 50050) stub = manager_django_pb2.beta_create_Manager_stub(channel) response = stub.OpenFile(manager_django_pb2.OpenRequest(open_path=filePath, timestamp=int(timeStamp)), _TIMEOUT_SECONDS) print response fileContent = response.open_file #the response should be a file #This is just test code for saving file #filename = os.path.basename(filePath) #with open(filename, 'wb') as f: #f.write(fileContent) #we should be returning the file return ContentFile(fileContent)
def sendFile(self, transferFile, filePath, timeStamp): print "Sending file to Manager" transferFile.open(mode='rb') hello = transferFile.read() channel = implementations.insecure_channel('localhost', 50050) stub = manager_django_pb2.beta_create_Manager_stub(channel) response = stub.SaveFile(manager_django_pb2.SaveRequest(save_file=hello, save_path=filePath, timestamp=long(timeStamp)), _TIMEOUT_SECONDS) #print response.transfer_status # print transferFile # print type(transferFile) # print "ATTEMPTING CONVERSION" # # print str(transferFile) # print hello return filePath
def openFile(self, filePath, timeStamp): print "Reading file from Manager" channel = implementations.insecure_channel('localhost', 50050) stub = manager_django_pb2.beta_create_Manager_stub(channel) response = stub.OpenFile( manager_django_pb2.OpenRequest(open_path=filePath, timestamp=int(timeStamp)), _TIMEOUT_SECONDS) print response fileContent = response.open_file #the response should be a file #This is just test code for saving file #filename = os.path.basename(filePath) #with open(filename, 'wb') as f: #f.write(fileContent) #we should be returning the file return ContentFile(fileContent)
def sendFile(self, transferFile, filePath, timeStamp): print "Sending file to Manager" transferFile.open(mode='rb') hello = transferFile.read() channel = implementations.insecure_channel('localhost', 50050) stub = manager_django_pb2.beta_create_Manager_stub(channel) response = stub.SaveFile( manager_django_pb2.SaveRequest(save_file=hello, save_path=filePath, timestamp=long(timeStamp)), _TIMEOUT_SECONDS) #print response.transfer_status # print transferFile # print type(transferFile) # print "ATTEMPTING CONVERSION" # # print str(transferFile) # print hello return filePath