本文整理汇总了Python中DataBase.is_exist方法的典型用法代码示例。如果您正苦于以下问题:Python DataBase.is_exist方法的具体用法?Python DataBase.is_exist怎么用?Python DataBase.is_exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataBase
的用法示例。
在下文中一共展示了DataBase.is_exist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listen_to_client
# 需要导入模块: import DataBase [as 别名]
# 或者: from DataBase import is_exist [as 别名]
def listen_to_client(self, client, address):
client_name = client.recv(BUFF_SIZE)
data_base = DataBase(self.key)
if not data_base.is_exist("Clients", client_name):
data_base.add_row_to_table("Clients", [client_name, address[0], address[1]])
print "Client " + client_name + " is connected"
else:
print "client " + client_name + " is connected again"
while True:
try:
data = client.recv(BUFF_SIZE)
print data
if data:
if "#" in data:
data_list = self.unpack_command(data)
print data_list
answer = self.handle_command(data_list)
print answer
if type(answer) is list:
print "list"
packets = answer[1]
client.send(str(answer[0]))
for x in range(answer[0]):
client.send(packets[x])
else:
client.send(answer)
else:
pass
else:
print 'Client disconnected'
except:
print "Client " + client_name + " has been disconnected"
client.close()
return False