当前位置: 首页>>代码示例>>Python>>正文


Python Packet.getFileArray方法代码示例

本文整理汇总了Python中Packet.getFileArray方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.getFileArray方法的具体用法?Python Packet.getFileArray怎么用?Python Packet.getFileArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet的用法示例。


在下文中一共展示了Packet.getFileArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: client

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
def client(ip, port):

	# Contacts the metadata server and ask for list of files.
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #Creating socket

	try:
		sock.connect((ip, port)) #Connecting socket
	except:
		print 'Could not connect to the server. Are you sure it is on and that you have the right port?'

	p = Packet() #Making a packet
	p.BuildListPacket() #Building packet
	
	try:
		sock.sendall(p.getEncodedPacket()) #Sending encoded packet
	except:
		print 'Could not send the encoded packet!'

	files = sock.recv(1024) #Receiving list of files

	p.DecodePacket(files) #Decoding Packet

	try:
		for files, size in p.getFileArray():
			print files, size, ' bytes'
	except:
		print 'Could not read list of files.'
开发者ID:skytremor,项目名称:Distributed-File-System,代码行数:29,代码来源:ls.py

示例2: client

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
def client(ip, port):

	# Contacts the metadata server and ask for list of files.
	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	s.connect((ip, port))

	# Creae a Packet and build it as a list packet
	# then send it to the metadata server
	packet = Packet()
	packet.BuildListPacket()
	s.sendall(packet.getEncodedPacket())

	# Now we take the response of the metadata server
	# the response is a packet with the list of files
	response = s.recv(1024)

	#print response
	
	if response == 'NAK':
		print 'there was an error with the request'
	else:
		packet.DecodePacket(response)

		# here I get the file array from the packet and
		# I will iterate to display the files and their size
		fileList = packet.getFileArray()
		#print fileList
		for f in fileList:
			print f[0], f[1], "bytes"
开发者ID:eduardogalindez,项目名称:DFS,代码行数:31,代码来源:ls.py

示例3: client

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
def client(ip, port):

	# Contacts the metadata server and ask for list of files.
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	sock.connect((ip, port))

	# Creates a packet to ask the metadata to send the file list
	p = Packet()
	p.BuildListPacket()
	sock.sendall(p.getEncodedPacket())

	# Received the list of files and display the information
	r = sock.recv(1024)
		# print r, type(r)

	p.DecodePacket(r)
	filelist = p.getFileArray()

	for item in filelist:
		print item[0], item[1], "bytes"
开发者ID:jesspagan,项目名称:dfs_project,代码行数:22,代码来源:ls.py

示例4: client

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
def client(ip, port):

	# Contacts the metadata server and ask for list of files.
	sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

	try:
		p = Packet()
		p.BuildListPacket()

		sock.connect((ip, port))
		sock.sendall(p.getEncodedPacket())

		msg = sock.recv(1024)
		
		if msg != "NAK":
			p.DecodePacket(msg)
			for f, size in p.getFileArray():
				print f, size
		else:
			print "Not Acknowledged"

	finally:
		sock.close()
开发者ID:JpGallegos,项目名称:simple_dfs,代码行数:25,代码来源:ls.py

示例5: client

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
def client(ip, port):
    #socket for connecting to the metadata server
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((ip, port))

    #packet object used to interact with the metadata server
    p = Packet()
    #list command
    p.BuildListPacket()

    #sending the size and later the command
    message = p.getEncodedPacket()
    sendall_with_size(sock, message)

    #dealing with the metadata server's response
    response = recv_with_size(sock)
    p.DecodePacket(response)

    #get file array is a cool guy and has all the files if successful
    for filename, size in p.getFileArray():
        print filename, size, "bytes"

    sock.close()
开发者ID:NamcoPro,项目名称:Distributed-File-System,代码行数:25,代码来源:ls.py

示例6: Packet

# 需要导入模块: import Packet [as 别名]
# 或者: from Packet import getFileArray [as 别名]
	except socket.error, e:
	    print "Could not connect with server.\n %s"%e
	    sys.exit(1)
	print "Connected to metadata server."

	try:
		response = "NAK"
		sp = Packet()
		while response == "NAK":
			sp.BuildListPacket()
			sock.sendall(sp.getEncodedPacket())
			response = sock.recv(1024)

			if response != "NAK":	
				sp.DecodePacket(response)
				lfiles = sp.getFileArray()

				if not lfiles:
					print "There are no files."
				else:
					for i in lfiles:
						print i[0], str(i[1]) + " Bytes"

	finally:
		sock.close()


if __name__ == "__main__":

	META_PORT = 8000
	cmd = sys.argv[1]
开发者ID:gallijs,项目名称:DFSv2,代码行数:33,代码来源:testmeta.py


注:本文中的Packet.getFileArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。