本文整理汇总了Python中Client.Client类的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.done = False
self.cFactory = pb.PBClientFactory()
self.realm = WBRealm()
self.realm.server = WbServer()
self.wbServer = self.realm.server
self.p = portal.Portal(self.realm)
self.c = WBChecker()
self.p.registerChecker(self.c)
self.sFactory = pb.PBServerFactory(self.p)
self.sFactory.protocol = WBBroker
self.server = reactor.listenTCP(28789, self.sFactory)
self.myClient = Client()
self.myClient2 = Client()
self.client = reactor.connectTCP("localhost", 28789, self.cFactory)
self.client2 = reactor.connectTCP("localhost", 28789, self.cFactory)
def1 = self.cFactory.login(credentials.UsernamePassword("Waldo","waldo"), client=self.myClient.cc)
def1.addCallback(self.getRoot, 1)
def1.addErrback(self.failure, "Error al conectarse el cliente1")
deferredResult(def1)
def2 = self.cFactory.login(credentials.UsernamePassword("Matias","matias"), client=self.myClient2.cc)
def2.addCallback(self.getRoot, 2)
def2.addErrback(self.failure, "Error al conectarse el cliente2")
deferredResult(def2)
示例2: Client
def test_connect_from_server_if_encrypted_message_cannot_be_decrypted_to_two_elements_will_return_error_signal(
self):
client = Client(client_id=None, client_key=3197, server=None, server_id=None)
random_value_from_server = 11
encrypted_message = encrypt('{0}:{1}'.format('nonce', 'session-key'), self.client_key)
response = client.process_message_from_server((random_value_from_server, encrypted_message))
self.assertEqual(response, client.error_signal)
示例3: run_client
def run_client(host, port):
selfClient = Client(host, int(port))
selfClient._connect()
input.append(selfClient.clientSocket)
input.append(sys.stdin)
running = True
print "Connection established. Please set your name with /name to start chatting."
while running is True:
inready,outready,exready = select.select(input,[],[])
for s in inready:
# Receiving information from the other user (the server).
if s == selfClient.clientSocket:
data = s.recv(SIZE)
if data:
print data
else:
s.close()
print ERROR_MSG['conClosed']
running = False
break
# Sending information to the other users via the server.
if s == sys.stdin:
userText = sys.stdin.readline()
line = userText.rstrip("\r\n")
selfClient.clientSocket.send(line)
selfClient._close()
示例4: App
class App(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.ui.connect_button.clicked.connect(self.start)
self.ui.send_button.clicked.connect(self.send_msg)
self.client = None
def start(self):
server = self.ui.server_text.text()
username = self.ui.user_text.text()
self.client = Client(username, server)
self.client.new_message.connect(self.print_msg)
self.ui.chat_text.setEnabled(True)
self.ui.message_text.setEnabled(True)
self.ui.send_button.setEnabled(True)
def send_msg(self):
message = self.ui.message_text.text()
self.ui.message_text.clear()
self.client.send(message)
def print_msg(self, message):
self.ui.chat_text.append(message)
示例5: __init__
def __init__(self, connectID,server):
try:
Client.__init__(self, connectID,server)
self.__initData()
except BaseException,e:
print "Player Init Error"
print e
示例6: submitParsingRequest
def submitParsingRequest(self,
parsingRequest):
gearmanClient = Client(ClientManager.JOB_SERVER_ADDRESS_LIST,
parsingRequest)
gearmanClient.run()
gearmanClient = None
示例7: main
def main():
# Establish the server cluster
s1 = Server()
s2 = Server()
s3 = Server()
s4 = Server()
s5 = Server()
s1.setNeighbors([s2, s3, s4, s5])
s2.setNeighbors([s1, s3, s4, s5])
s3.setNeighbors([s2, s1, s4, s5])
s4.setNeighbors([s2, s3, s1, s5])
s5.setNeighbors([s2, s3, s4, s1])
t1 = Thread(target=s1.electionTimeout)
t1.start()
time.sleep(5)
t2 = Thread(target=s2.electionTimeout)
t2.start()
t3 = Thread(target=s3.electionTimeout)
t3.start()
t4 = Thread(target=s4.electionTimeout)
t4.start()
t5 = Thread(target=s5.electionTimeout)
t5.start()
# Connect the client to the cluster leader
c1 = Client()
c1.connectClientToLeader(s2.neighbors)
# Use the command line
c1.waitForCommands()
示例8: SharedirsSet
class SharedirsSet(object):
def do_set(self, sharedirs, callback):
sharedirs_element = Element('sharedirs')
#TODO : gérer l'utf-8 (é) ...
for sharedir in sharedirs:
sharedir_element = SubElement(sharedirs_element, 'sharedir', {'name':sharedir.name, 'path':sharedir.path})
self.client = Client(sharedirs_element, AnalyseSharedirs(callback))
self.client.start()
示例9: run_http_post
def run_http_post():
#initialize a progressbar
p = Progressbar(flow)
client = Client(p)
#run the wanted client method
if args.endurance == None:
client.send_http_post(ip, httpport, flow, delay, size)
else:
client.send_http_post_time(ip, httpport, endurance, delay, size)
示例10: __init__
def __init__(self):
self.Alice = Client()
self.Alice.open_connection()
self.Bob = Client()
self.Bob.open_connection()
self.Eve = Client()
self.Eve.open_connection()
self.alice_stolen_password = ""
示例11: run_zmq_sub
def run_zmq_sub():
#initialize a progressbar
p = Progressbar(flow)
time.sleep(6)
client = Client(p)
#run the wanted client method
if args.endurance == None:
client.subscriber(flow, ip, port)
else:
client.subscriber_time(endurance, ip, port)
print "Transmission complete!"
示例12: Search
class Search(object):
def __init__(self, query):
self.query = query
def do_search(self, callback):
search_element = Element('search',
{'ttl': '3', 'id': str(randint(1, 10000000))})
query_element = SubElement(search_element, 'query')
query_element.text = self.query
self.client = Client(search_element, AnalyseResults(callback))
self.client.start()
示例13: run_req
def run_req():
#initialize a progressbar
p = Progressbar(flow)
time.sleep(6)
#new Client instanz
client = Client(p)
#run the wanted client method
if args.endurance == None:
client.sendAsync(flow, size, delay, ip, port)
else:
client.sendAsync_time(endurance, size, delay, ip, port)
print "Transmission complete!"
示例14: StatisticsGet
class StatisticsGet(object):
def __init__(self, callback, hostname=Configuration.ip_daemon):
self.hostname = hostname
self.callback = callback
def do_get(self):
search_element = Element('statistics', {'type': 'get'})
self.client = Client(search_element, AnalyseStatistics(self.callback), self.hostname)
self.client.start()
def cancel(self):
self.client.cancel()
示例15: mkDevice
def mkDevice(screen, x, y, id):
if id.isdigit():
subnet = Subnet(screen, x, y)
subnet.IP = IP(int(id))
return subnet
elif id == "N":
dns = DNS(screen, x, y)
dns.IP = str(ord(list(id)[0]))
return dns
elif id.isupper():
router = Router(screen, x, y)
router.IP = str(ord(list(id)[0]))
router.selected = router.IP == "66"
return router
elif id.islower():
if id == "h":
host = Client(screen, x, y)
host.name = "Alice"
host.corespondent = "Bob"
elif id == "x":
host = Client(screen, x, y)
host.name = "Bob"
host.corespondent = "Alice"
else:
host = Host(screen, x ,y)
host.IP = str(ord(list(id)[0]))
return host
else:
print "Unrecognized unique identifier in sprite map"
return None