本文整理汇总了Python中Client.Client.close方法的典型用法代码示例。如果您正苦于以下问题:Python Client.close方法的具体用法?Python Client.close怎么用?Python Client.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client.Client
的用法示例。
在下文中一共展示了Client.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getindex
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import close [as 别名]
def getindex(self):
try:
num = int(self._input('Peer Num : '))
peer = self.vpn.get_peer_by_num(num)
clt = Client(self.vpn)
print "[+] Connecting to %s at %s:%d ... [Ctrl+c]" % (peer[1], peer[2], peer[3])
clt.connect(peer[2], peer[3], (peer[4],peer[5]))
print "[+] Connected"
print "[+] Get Index ..."
clt.get_index(peer[0])
clt.close()
except Exception as e:
print "[Error]", e
except KeyboardInterrupt:
print "[!] Connection close"
else:
print "[+] Index downloaded"
示例2: downloadfile
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import close [as 别名]
def downloadfile(self):
try:
num = int(self._input('Peer Num : '))
peer = self.vpn.get_peer_by_num(num)
idfile = int(self._input('File ID : '))
name = Index(peer[0]).get_file_by_id(idfile)[1]
clt = Client(self.vpn)
print "[+] Connecting to %s at %s:%d ... [Ctrl+c]" % (peer[1], peer[2], peer[3])
clt.connect(peer[2], peer[3], (peer[4],peer[5]))
print "[+] Connected"
print '[+] Get File "%s" ...' % name
clt.get_file(idfile, name)
clt.close()
except Exception as e:
print "[Error]", e
except KeyboardInterrupt:
print "[!] Connection close"
else:
print "[+] File downloaded"
示例3: Client
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import close [as 别名]
from Client import Client
import os
if __name__ == '__main__':
c = Client()
while c.work:
pass
# user clicked exit button
c.close()
# 1 --> SIGHUP
os.kill(os.getppid(),1)
示例4: execute_command
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import close [as 别名]
def execute_command(command, host):
client = Client(host['ip'], host['user'], host['password'] )
status, stdOut = client.command(command)
client.close()
return {"status_code" : status, "standard_out" : stdOut }
示例5: run_on_all
# 需要导入模块: from Client import Client [as 别名]
# 或者: from Client.Client import close [as 别名]
def run_on_all(args, operation):
for ip_address in args.ip_address:
client = Client(ip_address, args.user, args.password)
operation(args, client)
client.close()