Changeset 3439 for pykoticon/trunk/tests/test.py
- Timestamp:
- 10/06/08 00:29:29 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykoticon/trunk/tests/test.py
r176 r3439 1 1 #! /usr/bin/env python 2 # -*- coding: ISO-8859-15 -*-2 # -*- coding: iso-8859-15 -*- 3 3 4 4 # PyKotIcon - Client side helper for PyKota and other applications … … 14 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 # GNU General Public License for more details. 16 # 16 # 17 17 # You should have received a copy of the GNU General Public License 18 18 # along with this program; if not, write to the Free Software … … 43 43 # Opens the connection to the PyKotIcon server : 44 44 server = xmlrpclib.ServerProxy("http://%s:%s" % (arguments[0], arguments[1])) 45 45 46 46 # Now display something on the PyKotIcon host : 47 47 message1 = "You are about to test PyKotIcon\n\nPyKotIcon is really great software !" 48 48 server.showDialog(xmlrpclib.Binary(message1.encode("UTF-8")), False) 49 50 # Now ask the end user if he really wants to do this : 49 50 # Now ask the end user if he really wants to do this : 51 51 message2 = "Are you sure you want to do this ?" 52 52 result = server.showDialog(xmlrpclib.Binary(message2.encode("UTF-8")), True) 53 53 print "The remote user said : %s" % result 54 54 55 55 # Displays the answer back : 56 56 answer = "You have clicked on the %s button" % result 57 57 server.showDialog(xmlrpclib.Binary(answer.encode("UTF-8")), False) 58 59 # Now we will ask some datas : 58 59 # Now we will ask some datas : 60 60 result = server.askDatas([xmlrpclib.Binary(v) for v in ["Username", "Password", "Country"]], \ 61 61 ["username", "password", "country"], \ … … 68 68 answer = "You answered :\n%s" % "\n".join(["%s => '%s'" % (k, v.data) for (k, v) in result.items() if k != "isValid"]) 69 69 server.showDialog(xmlrpclib.Binary(answer.encode("UTF-8")), False) 70 else : 70 else : 71 71 print "The answers are not valid." 72 73 # Now do nothing : 72 73 # Now do nothing : 74 74 server.nop() 75 75 76 76 # Finally we will cause PyKotIcon to die 77 77 message3 = "As soon as you'll click on the button below, PyKotIcon will die." 78 78 server.showDialog(xmlrpclib.Binary(message3.encode("UTF-8")), False) 79 79 server.quitApplication() 80 80 81 81 # That's all folks ! 82 82 print 83 83 print "This demo is finished. Did you like it ?" 84 84 85 85 if __name__ == "__main__" : 86 86 if len(sys.argv) < 3 : 87 87 sys.stderr.write("usage : %s pykoticon_hostname_or_ip_address pykoticon_TCPPort\n" % sys.argv[0]) 88 else : 88 else : 89 89 try : 90 90 main(sys.argv[1:]) 91 except socket.error, msg : 91 except socket.error, msg : 92 92 sys.stderr.write("ERROR : Network error : %s\n" % msg) 93 93 sys.stderr.write("Are you sure that PyKotIcon is running and accepts incoming connections ?\n") 94 94