Ejemplo n.º 1
0
    def handle_list(self, db):
        """Get the file list from the database and send list to client"""
        try:
            # Fill code here
            #filling till

            pack = Packet()  # we create the packet
            file_list = []  # we create a list which will contains the files

            for file, size in db.GetFiles(
            ):  #for loop which will get the files and their size and this will be appended in the list we created earlier

                file_list.append((file, size))

            else:

                pack.BuildListResponse(
                    file_list
                )  # we use the packet we created and builds a registration packet.

                self.request.sendall(
                    pack.getEncodedPacket()
                )  #We use the getEncodedPacket to return a seriliazed packet ready to send through the network and send it.
            #code filled till here
        except:
            print("fell here")
            self.request.sendall("NAK")
Ejemplo n.º 2
0
 def handle_list(self, db):
     """Get the file list from the database and send list to client"""
     try:
         flist = db.GetFiles()
         p = Packet()
         p.BuildListResponse(flist)
         self.request.sendall(p.getEncodedPacket().encode())
     except:
         self.request.sendall("NAK".encode())
Ejemplo n.º 3
0
    def handle_list(self, db):
        """Get the file list from the database and send list to client"""
        try:
            print "inside handle list func"
            p = Packet()
            # print db.GetFiles()
            p.BuildListResponse(db.GetFiles())
            self.request.sendall(p.getEncodedPacket())

        except:
            self.request.sendall("NAK NAK")
Ejemplo n.º 4
0
    def handle_list(self, db):
        """Get the file list from the database and send list to client"""
        try:  # Fill code here
            packet = Packet()
            files = db.GetFiles()
            print files
            packet.BuildListResponse(files)
            response = packet.getEncodedPacket()
            self.request.sendall(response)

        except:
            self.request.sendall("NAK")
	def handle_list(self, db):
		"""Get the file list from the database and send list to client"""
		try:
			# Fill code here
			files = db.GetFiles()
			p = Packet()
			p.BuildListResponse(files)
			packet = p.getEncodedPacket() # convert to bytes
			
			self.request.sendall(packet) #sending packet back to client

		except:
			self.request.sendall("NAK")	
Ejemplo n.º 6
0
	def handle_list(self, db):
		"""
			Get the file list from the database and send list to client
				- List of tuples if successfully retrieved.
				- NAK if problem.
		"""

		try:
			print "\t- Retrieving file list from DFS..."
			flist = db.GetFiles()
			p = Packet()
			p.BuildListResponse(flist)
			self.request.sendall(p.getEncodedPacket())
			print "\t- Sent file list to ls.py!"
		except:
			self.request.sendall("NAK")
			print "\t- Couldn't retrieve file list from DFS!"
Ejemplo n.º 7
0
    def handle_list(self, db):
        """Get the file list from the database and send list to client"""
        try:
            # Fill code here
            # print("Looking for files in db")
            #Getting files from the inode table in the database using the GetFiles()
            #function from the mds_db.py.
            lis = db.GetFiles()
            #creating packet to send the file list back to the client.
            paq = Packet()
            # print("Buiding response")
            paq.BuildListResponse(lis)
            coso = paq.getEncodedPacket()
            self.request.sendall(coso)
            # print("response sent")

        except:
            self.request.sendall("NAK")