本文整理汇总了Python中waldo.lib.Waldo类的典型用法代码示例。如果您正苦于以下问题:Python Waldo类的具体用法?Python Waldo怎么用?Python Waldo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Waldo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback
def callback():
myGame = int(client.getGame())
msg_to_send = e.get()
ready = client.send_cmd(-3, False)
#if ready:
#print full[myGame] + " is ready to play!"
if(msg_to_send != ''):
e.delete(0,END)
listbox.yview(END)
if(msg_to_send[0] != '/'):
client.send_msg(name + ": " + msg_to_send)
else:
#print msg_to_send[1:]
result = switch(msg_to_send[1:])
#print "My game is " + str(myGame)
if(result != myGame):
if(result == -3):
Waldo.stop(); #does this even work? i don't think so!
else:
client.send_cmd(myGame, False)
if(myGame >= 0):
client.send_msg(name + " no longer wishes to play " + full[myGame] + ". Sissy.")
if(result >= 0):
client.send_cmd(result, True)
client.send_msg(name + " would like to play " + full[result] + "!")
#client.setGame(result)
client.setGame(result)
myGame = result;
示例2: spawn_acceptor
def spawn_acceptor():
'''
Starts the TCP accept thread and spins as connections are brought up.
'''
Waldo.tcp_accept(InnerPong, HOST, PORT_INNER, throw_func)
while True:
pass
示例3: run_test
def run_test():
accept_stoppable = Waldo.tcp_accept(
SideA, SIDEA_HOST, SIDEA_PORT,
connected_callback=sidea_connected)
sideb = Waldo.tcp_connect(
SideB,SIDEA_HOST,SIDEA_PORT)
sidea = sidea_wait_queue.get()
sidea.do_nothing()
sideb.do_nothing()
sidea.stop()
time.sleep(1)
# ensure that stop fires on single host.
try:
sidea.do_nothing()
return False
except Waldo.StoppedException as inst:
pass
# ensure that the other side also sees the stop.
try:
sideb.do_nothing()
return False
except Waldo.StoppedException as inst:
pass
return True
示例4: run_test
def run_test():
accept_stoppable = Waldo.tcp_accept(
SideA, SIDEA_HOST, SIDEA_PORT,
connected_callback=sidea_connected)
sideb = Waldo.tcp_connect(
SideB,SIDEA_HOST,SIDEA_PORT)
sidea = sidea_wait_queue.get()
sidea.add_stop_listener(sidea_stop_listener)
sideb.add_stop_listener(sideb_stop_listener_1)
sideb.add_stop_listener(sideb_stop_listener_2)
listener_id = sideb.add_stop_listener(sideb_stop_listener_2)
sideb.remove_stop_listener(listener_id)
sideb.remove_stop_listener(listener_id)
sidea.do_nothing()
sideb.do_nothing()
sidea.stop()
time.sleep(1)
if sidea_stop_counter != 1:
return False
if sideb_stop_counter != 3:
return False
return True
示例5: run_chatter_a
def run_chatter_a():
# runs in accept mode
global quit
Waldo.tcp_accept(ChatterA, HOSTNAME, PORT, display_msg,
connected_callback=listen_for_user_input)
while True:
if quit:
break
time.sleep(SLEEP_TIME)
示例6: run_test
def run_test():
"""
Tests whether Waldo can propagate an application exception back through an
endpoint call.
Returns true if the test passes and false otherwise.
"""
thrower = Waldo.no_partner_create(SingleSide, None)
catcher = Waldo.no_partner_create(SingleSide, thrower)
return catcher.test_catch()
示例7: run_server
def run_server():
'''
Runs the multi-connection chat server.
'''
global server
server = Waldo.no_partner_create(Server, display_msg)
print server
Waldo.tcp_accept(ClientHandler, HOSTNAME, PORT, server, display_msg)
while True:
time.sleep(SLEEP_TIME)
示例8: run_test
def run_test():
'''
Tests Waldo's ability to detect an application exception on the partner
endpoint mid-sequence and propagate that exception back to the root endpoint
for handling.
Returns true if the exception is caught and handled, and false otherwise.
'''
Waldo.tcp_accept(Pong,HOST,PORT)
connector = Waldo.tcp_connect(Ping,HOST,PORT)
return connector.testPropagateException()
示例9: run_test
def run_test():
Waldo.tcp_accept(Pt2, HOST, PORT, connected_callback=pt2_connected)
pt1 = Waldo.tcp_connect(Pt1, HOST, PORT,createList);
pt2 = pt2_wait_queue.get()
returned_list = pt1.start_seq()
time.sleep(1)
list_to_return.append('wo')
if returned_list != list_to_return:
return False
return True
示例10: run_test
def run_test():
'''
Tests Waldo's ability to propagate an ApplicationException back through an
endpoint call on the remote partner in a sequence. The exception should be
passed back to the root endpoint which initiates the sequence.
Returns true if the exception is caught and handled, and false otherwise.
'''
thrower = Waldo.no_partner_create(Pong,None)
catcher_partner = Waldo.tcp_accept(Pong,HOST,PORT,thrower)
catcher = Waldo.tcp_connect(Ping,HOST,PORT)
return catcher.testExceptionPropagation()
示例11: run_test
def run_test():
'''
Tests Waldo's ability to propagate an exception back through a sequence within
an endpoint call.
Returns true if the exception is caught and handled, and false otherwise.
'''
Waldo.tcp_accept(Pong,HOST,PORT)
connector = Waldo.tcp_connect(Ping,HOST,PORT)
catcher = Waldo.no_partner_create(Catcher)
catcher.addEndpoint(connector)
return catcher.testCatchApplicationExceptionFromSequence()
示例12: run_test
def run_test():
'''
Tests the try...finally statement (without the use of catch).
Returns true if an error may be propagated through a try...finally
and handled later while having the code in the finally block
execute.
'''
catcher = Waldo.no_partner_create(Catcher)
thrower = Waldo.no_partner_create(Thrower)
catcher.addEndpoint(thrower)
thrower.addEndpoint(catcher)
return catcher.testTryFinally()
示例13: run_test
def run_test():
'''
Tests Waldo's ability to detect a network failure between two endpoints
mid-sequence, thrown a NetworkException, and catch that exception using
a try-catch.
Returns true if the exception is caught and handled, and false otherwise.
'''
Waldo.set_default_heartbeat_period(1)
Waldo.set_default_partner_timeout(3)
acceptor_process.start()
time.sleep(SLEEP_TIME)
connector = Waldo.tcp_connect(Ping,HOST,PORT,signal_func)
return connector.testNetworkException()
示例14: on_change_password
def on_change_password(event):
password_info = menu.get_password_info() #contains tuple (current password, new password, new password)
cur_password = password_info[0]
if user_login.get_encrypted_key(name, cur_password) != "":
if password_info[1] == password_info[2]:
new_password = password_info[1]
salt = user_login.get_salt(name)
new_pw_hash = Waldo.hash(new_password, salt)
user_login.change_password(name, Waldo.encrypt_keytext(key, new_pw_hash), new_pw_hash)
menu.set_message("Password has been changed.")
else:
menu.set_message("New passwords do not match.")
else:
menu.set_message("Username/password combination was not found.")
示例15: on_login
def on_login (event):
login_info = login.get_login_info()
encrypted_key = user_login.get_encrypted_key(login_info[0], login_info[1])
if encrypted_key != "":
global name
name = login_info[0]
password_hashed = Waldo.hash(login_info[1], user_login.get_salt(name))
global key
key = Waldo.decrypt_keytext(encrypted_key, password_hashed)
global certificate
certificate = Waldo.get_cert_from_text(user_login.get_certificate(name))
login.close()
else:
login.set_message("Username/password combination was not found.")