diff options
author | Mark Spruiell <mes@zeroc.com> | 2012-04-24 14:16:15 -0700 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2012-04-24 14:16:15 -0700 |
commit | 943a48fc5c0a59b892eb746073c71b8dd88815e7 (patch) | |
tree | 421cfedbc60603d02e0b314d9204e9f85dd781c5 | |
parent | minor fix to IcePHP getLogger (diff) | |
download | ice-943a48fc5c0a59b892eb746073c71b8dd88815e7.tar.bz2 ice-943a48fc5c0a59b892eb746073c71b8dd88815e7.tar.xz ice-943a48fc5c0a59b892eb746073c71b8dd88815e7.zip |
python 3 support
504 files changed, 7446 insertions, 6266 deletions
@@ -129,6 +129,8 @@ Java Changes Python Changes ============== +- Added support for Python 3. + - Fixed a bug that caused IceGrid activation of a Python server to hang when tracing was enabled for the server. diff --git a/cpp/allDemos.py b/cpp/allDemos.py index b07ff86af3e..9e157cbcd55 100755 --- a/cpp/allDemos.py +++ b/cpp/allDemos.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "demoscript")): break else: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(os.path.join(toplevel)) from demoscript import Util diff --git a/cpp/allTests.py b/cpp/allTests.py index 79e2904ab1b..316bc188080 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -10,16 +10,16 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - print "can't find toplevel directory!" - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(toplevel)) -from scripts import * +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/cpp/config/convertssl.py b/cpp/config/convertssl.py index 21675eda874..54cebe82d32 100755 --- a/cpp/config/convertssl.py +++ b/cpp/config/convertssl.py @@ -26,10 +26,10 @@ import sys, xml.dom, xml.dom.minidom # Show usage information. # def usage(): - print "Usage: " + sys.argv[0] + " xmlfile" - print - print "Options:" - print "-h Show this message." + print("Usage: " + sys.argv[0] + " xmlfile") + print("") + print("Options:") + print("-h Show this message.") def isCygwin(): # The substring on sys.platform is required because some cygwin @@ -56,20 +56,20 @@ def printConfig(node, name, comment=""): result = result + "#\n# NOTE: You may need to define IceSSL.DefaultDir\n" general = findChild(node, "general") if general: - if general.attributes.has_key("version"): + if "version" in general.attributes: version = general.attributes["version"].nodeValue if version == "SSLv3": result = result + prefix + "Protocols=SSLv3\n" elif version == "TLSv1": result = result + prefix + "Protocols=TLSv1\n" elif version != "SSLv23": - print "unknown value `" + version + "' for version attribute" + print("unknown value `" + version + "' for version attribute") sys.exit(1) - if general.attributes.has_key("cipherlist"): + if "cipherlist" in general.attributes: result = result + prefix + "Ciphers=" + general.attributes["cipherlist"].nodeValue + "\n" - if general.attributes.has_key("verifymode"): + if "verifymode" in general.attributes: verifymode = general.attributes["verifymode"].nodeValue if verifymode == "none": result = result + prefix + "VerifyPeer=0\n" @@ -80,21 +80,21 @@ def printConfig(node, name, comment=""): elif verifymode.find("client_once") != -1: result = result + prefix + "VerifyPeer=2\n" else: - print "unknown value `" + verifymode + "' for verifymode attribute" + print("unknown value `" + verifymode + "' for verifymode attribute") sys.exit(1) - if general.attributes.has_key("verifydepth"): + if "verifydepth" in general.attributes: result = result + prefix + "VerifyDepthMax=" + general.attributes["verifydepth"].nodeValue + "\n" - if general.attributes.has_key("randombytes"): + if "randombytes" in general.attributes: result = result + "# NOTE: You may need to use IceSSL.EntropyDaemon\n" result = result + prefix + "Random=" + general.attributes["randombytes"].nodeValue + "\n" ca = findChild(node, "certauthority") if ca: - if ca.attributes.has_key("file"): + if "file" in ca.attributes: result = result + prefix + "CertAuthFile=" + ca.attributes["file"].nodeValue + "\n" - if ca.attributes.has_key("path"): + if "path" in ca.attributes: result = result + prefix + "CertAuthDir=" + ca.attributes["path"].nodeValue + "\n" basecerts = findChild(node, "basecerts") @@ -104,33 +104,33 @@ def printConfig(node, name, comment=""): rsacert = findChild(basecerts, "rsacert") if rsacert: pub = findChild(rsacert, "public") - if pub.attributes.has_key("encoding"): + if "encoding" in pub.attributes: if pub.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for certificates!\n" - if pub.attributes.has_key("filename"): + if "filename" in pub.attributes: certFile = pub.attributes["filename"].nodeValue priv = findChild(rsacert, "private") - if priv.attributes.has_key("encoding"): + if "encoding" in priv.attributes: if priv.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for private keys!\n" - if priv.attributes.has_key("filename"): + if "filename" in priv.attributes: keyFile = priv.attributes["filename"].nodeValue dsacert = findChild(basecerts, "dsacert") if dsacert: pub = findChild(dsacert, "public") - if pub.attributes.has_key("encoding"): + if "encoding" in pub.attributes: if pub.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for certificates!\n" - if pub.attributes.has_key("filename"): + if "filename" in pub.attributes: if len(certFile) > 0: certFile = certFile + sep + pub.attributes["filename"].nodeValue else: certFile = pub.attributes["filename"].nodeValue priv = findChild(rsacert, "private") - if priv.attributes.has_key("encoding"): + if "encoding" in priv.attributes: if priv.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for private keys!\n" - if priv.attributes.has_key("filename"): + if "filename" in priv.attributes: if len(keyFile) > 0: keyFile = keyFile + sep + priv.attributes["filename"].nodeValue else: @@ -143,7 +143,7 @@ def printConfig(node, name, comment=""): for child in basecerts.childNodes: if child.localName == "dhparams": keysize = child.attributes["keysize"].nodeValue - if child.attributes.has_key("encoding"): + if "encoding" in child.attributes: if child.attributes["encoding"].nodeValue != "PEM": result = result + "# NOTE: Only PEM encoding is supported for DH parameters!\n" filename = child.attributes["filename"].nodeValue @@ -160,8 +160,8 @@ for x in sys.argv[1:]: usage() sys.exit(0) elif x.startswith("-"): - print sys.argv[0] + ": unknown option `" + x + "'" - print + print(sys.argv[0] + ": unknown option `" + x + "'") + print("") usage() sys.exit(1) else: @@ -180,16 +180,16 @@ f.close() config = findChild(doc, "SSLConfig") if not config: - print sys.argv[0] + ": unable to find element SSLConfig" + print(sys.argv[0] + ": unable to find element SSLConfig") sys.exit(1) client = findChild(config, "client") server = findChild(config, "server") output = None if client and server: - print printConfig(client, "Client") - print printConfig(server, "Server", "#") + print(printConfig(client, "Client")) + print(printConfig(server, "Server", "#")) elif client: - print printConfig(client, "Client") + print(printConfig(client, "Client")) elif server: - print printConfig(server, "Server") + print(printConfig(server, "Server")) diff --git a/cpp/demo/Freeze/backup/expect.py b/cpp/demo/Freeze/backup/expect.py index 652713735ec..4ed9445da18 100755 --- a/cpp/demo/Freeze/backup/expect.py +++ b/cpp/demo/Freeze/backup/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, shutil, signal, time path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,12 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import shutil -import signal, time +from demoscript import Util def cleandb(): shutil.rmtree("db.save", True) @@ -30,23 +28,23 @@ def cleandb(): for filename in [ os.path.join("db", f) for f in os.listdir("db") if f.startswith("__db") ]: os.remove(filename) -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() cleandb() for d in os.listdir('.'): if d.startswith('hotbackup'): shutil.rmtree(d) -print "ok" +print("ok") client = Util.spawn('./client') -print "populating map...", +sys.stdout.write("populating map... ") sys.stdout.flush() client.expect('Updating map', timeout=60) time.sleep(3) # Let the client do some work for a bit. -print "ok" +print("ok") -print "performing full backup...", +sys.stdout.write("performing full backup... ") sys.stdout.flush() if Util.isWin32(): backup = Util.spawn('./backup.bat full') @@ -54,14 +52,14 @@ else: backup = Util.spawn('./backup full') backup.expect('hot backup started', timeout=30) backup.waitTestSuccess(timeout=30) -print "ok" +print("ok") -print "sleeping 5s...", +sys.stdout.write("sleeping 5s... ") sys.stdout.flush() time.sleep(5) -print "ok" +print("ok") -print "performing incremental backup...", +sys.stdout.write("performing incremental backup... ") sys.stdout.flush() if Util.isWin32(): backup = Util.spawn('./backup.bat incremental') @@ -69,25 +67,25 @@ else: backup = Util.spawn('./backup incremental') backup.expect('hot backup started', timeout=30) backup.waitTestSuccess(timeout=30) -print "ok" +print("ok") -print "sleeping 30s...", +sys.stdout.write("sleeping 30s... ") sys.stdout.flush() time.sleep(30) -print "ok" +print("ok") assert os.path.isdir('hotbackup') -print "killing client with SIGTERM...", +sys.stdout.write("killing client with SIGTERM... ") sys.stdout.flush() client.kill(signal.SIGTERM) client.waitTestSuccess(-signal.SIGTERM) -print "ok" +print("ok") -print "Client output: ", -print "%s " % (client.before) +sys.stdout.write("Client output: ") +print("%s" % (client.before)) -print "restarting client...", +sys.stdout.write("restarting client... ") sys.stdout.flush() cleandb() # Annoying. shutil.copytree cannot be used since db already exists @@ -107,17 +105,17 @@ sys.stdout.flush() client = Util.spawn('./client') client.expect('(.*)Updating map', timeout=60) assert client.match.group(1).find('Creating new map') == -1 -print "ok" +print("ok") -print "sleeping 5s...", +sys.stdout.write("sleeping 5s... ") sys.stdout.flush() time.sleep(5) -print "ok" +print("ok") -print "killing client with SIGTERM...", +sys.stdout.write("killing client with SIGTERM... ") client.kill(signal.SIGTERM) client.waitTestSuccess(-signal.SIGTERM) -print "ok" +print("ok") -print "Restarted client output:", -print "%s " % (client.before) +sys.stdout.write("Restarted client output: ") +print("%s" % (client.before)) diff --git a/cpp/demo/Freeze/bench/expect.py b/cpp/demo/Freeze/bench/expect.py index b9747ec0818..ec03365ba29 100755 --- a/cpp/demo/Freeze/bench/expect.py +++ b/cpp/demo/Freeze/bench/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import bench -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") client = Util.spawn('./client') bench.run(client) diff --git a/cpp/demo/Freeze/casino/expect.py b/cpp/demo/Freeze/casino/expect.py index 0db8ec59bfa..2592229b213 100755 --- a/cpp/demo/Freeze/casino/expect.py +++ b/cpp/demo/Freeze/casino/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import casino casino.run('./client', './server') diff --git a/cpp/demo/Freeze/customEvictor/expect.py b/cpp/demo/Freeze/customEvictor/expect.py index 45ecac4f2e7..b0685606d0a 100755 --- a/cpp/demo/Freeze/customEvictor/expect.py +++ b/cpp/demo/Freeze/customEvictor/expect.py @@ -16,38 +16,38 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util if Util.isDarwin(): - print "This demo is not supported under MacOS." + print("This demo is not supported under MacOS.") sys.exit(0) -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") -print "testing IceUtil::Cache evictor" +print("testing IceUtil::Cache evictor") server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect(".* ready", timeout=120) client = Util.spawn('./client') client.waitTestSuccess(timeout=8 * 60) -print client.before +print(client.before) server.kill(signal.SIGINT) server.waitTestSuccess(timeout=60) -print "testing simple evictor" +print("testing simple evictor") server = Util.spawn('./server simple --Ice.PrintAdapterReady') server.expect(".* ready") client = Util.spawn('./client') client.waitTestSuccess(timeout=8*60) -print client.before +print(client.before) server.kill(signal.SIGINT) server.waitTestSuccess(timeout=60) diff --git a/cpp/demo/Freeze/library/Grammar.cpp b/cpp/demo/Freeze/library/Grammar.cpp index fcc1cb7e8ee..de514f337bd 100644 --- a/cpp/demo/Freeze/library/Grammar.cpp +++ b/cpp/demo/Freeze/library/Grammar.cpp @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,51 +54,20 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - +/* Push parsers. */ +#define YYPUSH 0 +/* Pull parsers. */ +#define YYPULL 1 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_HELP = 258, - TOK_EXIT = 259, - TOK_ADD_BOOK = 260, - TOK_FIND_ISBN = 261, - TOK_FIND_AUTHORS = 262, - TOK_NEXT_FOUND_BOOK = 263, - TOK_PRINT_CURRENT = 264, - TOK_RENT_BOOK = 265, - TOK_RETURN_BOOK = 266, - TOK_REMOVE_CURRENT = 267, - TOK_SET_EVICTOR_SIZE = 268, - TOK_SHUTDOWN = 269, - TOK_STRING = 270 - }; -#endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_ADD_BOOK 260 -#define TOK_FIND_ISBN 261 -#define TOK_FIND_AUTHORS 262 -#define TOK_NEXT_FOUND_BOOK 263 -#define TOK_PRINT_CURRENT 264 -#define TOK_RENT_BOOK 265 -#define TOK_RETURN_BOOK 266 -#define TOK_REMOVE_CURRENT 267 -#define TOK_SET_EVICTOR_SIZE 268 -#define TOK_SHUTDOWN 269 -#define TOK_STRING 270 - +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "Grammar.y" @@ -132,6 +100,9 @@ yyerror(const char* s) +/* Line 189 of yacc.c */ +#line 105 "Grammar.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -150,20 +121,44 @@ yyerror(const char* s) # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_BOOK = 260, + TOK_FIND_ISBN = 261, + TOK_FIND_AUTHORS = 262, + TOK_NEXT_FOUND_BOOK = 263, + TOK_PRINT_CURRENT = 264, + TOK_RENT_BOOK = 265, + TOK_RETURN_BOOK = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 167 "Grammar.tab.c" +/* Line 264 of yacc.c */ +#line 162 "Grammar.tab.c" #ifdef short # undef short @@ -238,14 +233,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -326,9 +321,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -362,12 +357,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -751,17 +746,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -795,11 +793,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1079,10 +1077,8 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1101,10 +1097,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1128,74 +1123,75 @@ yyparse () #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* Number of syntax errors so far. */ + int yynerrs; - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1225,7 +1221,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1233,7 +1228,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1256,9 +1250,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1269,7 +1262,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1279,6 +1271,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1287,16 +1282,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1328,20 +1323,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1381,30 +1372,40 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 54 "Grammar.y" { ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 57 "Grammar.y" { ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 65 "Grammar.y" { ;} break; case 5: + +/* Line 1455 of yacc.c */ #line 68 "Grammar.y" { ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 76 "Grammar.y" { parser->usage(); @@ -1412,6 +1413,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 80 "Grammar.y" { return 0; @@ -1419,6 +1422,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 84 "Grammar.y" { parser->addBook((yyvsp[(2) - (3)])); @@ -1426,6 +1431,8 @@ yyreduce: break; case 9: + +/* Line 1455 of yacc.c */ #line 88 "Grammar.y" { parser->findIsbn((yyvsp[(2) - (3)])); @@ -1433,6 +1440,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 92 "Grammar.y" { parser->findAuthors((yyvsp[(2) - (3)])); @@ -1440,6 +1449,8 @@ yyreduce: break; case 11: + +/* Line 1455 of yacc.c */ #line 96 "Grammar.y" { parser->nextFoundBook(); @@ -1447,6 +1458,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 100 "Grammar.y" { parser->printCurrent(); @@ -1454,6 +1467,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 104 "Grammar.y" { parser->rentCurrent((yyvsp[(2) - (3)])); @@ -1461,6 +1476,8 @@ yyreduce: break; case 14: + +/* Line 1455 of yacc.c */ #line 108 "Grammar.y" { parser->returnCurrent(); @@ -1468,6 +1485,8 @@ yyreduce: break; case 15: + +/* Line 1455 of yacc.c */ #line 112 "Grammar.y" { parser->removeCurrent(); @@ -1475,6 +1494,8 @@ yyreduce: break; case 16: + +/* Line 1455 of yacc.c */ #line 116 "Grammar.y" { parser->setEvictorSize((yyvsp[(2) - (3)])); @@ -1482,6 +1503,8 @@ yyreduce: break; case 17: + +/* Line 1455 of yacc.c */ #line 120 "Grammar.y" { parser->shutdown(); @@ -1489,6 +1512,8 @@ yyreduce: break; case 18: + +/* Line 1455 of yacc.c */ #line 124 "Grammar.y" { yyerrok; @@ -1496,12 +1521,16 @@ yyreduce: break; case 19: + +/* Line 1455 of yacc.c */ #line 128 "Grammar.y" { ;} break; case 20: + +/* Line 1455 of yacc.c */ #line 136 "Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); @@ -1510,6 +1539,8 @@ yyreduce: break; case 21: + +/* Line 1455 of yacc.c */ #line 141 "Grammar.y" { (yyval) = (yyvsp[(1) - (1)]); @@ -1517,8 +1548,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1522 "Grammar.tab.c" + +/* Line 1455 of yacc.c */ +#line 1554 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1529,7 +1561,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1594,7 +1625,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1611,7 +1642,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1668,9 +1699,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1695,7 +1723,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1706,7 +1734,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -1732,6 +1760,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 146 "Grammar.y" diff --git a/cpp/demo/Freeze/library/Grammar.h b/cpp/demo/Freeze/library/Grammar.h index f956ecdbf3a..06c71695747 100644 --- a/cpp/demo/Freeze/library/Grammar.h +++ b/cpp/demo/Freeze/library/Grammar.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -54,30 +54,16 @@ TOK_STRING = 270 }; #endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_ADD_BOOK 260 -#define TOK_FIND_ISBN 261 -#define TOK_FIND_AUTHORS 262 -#define TOK_NEXT_FOUND_BOOK 263 -#define TOK_PRINT_CURRENT 264 -#define TOK_RENT_BOOK 265 -#define TOK_RETURN_BOOK 266 -#define TOK_REMOVE_CURRENT 267 -#define TOK_SET_EVICTOR_SIZE 268 -#define TOK_SHUTDOWN 269 -#define TOK_STRING 270 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/cpp/demo/Freeze/library/Scanner.cpp b/cpp/demo/Freeze/library/Scanner.cpp index cb08ec61fba..ffb9f557140 100755..100644 --- a/cpp/demo/Freeze/library/Scanner.cpp +++ b/cpp/demo/Freeze/library/Scanner.cpp @@ -1,71 +1,113 @@ -#include "IceUtil/Config.h" -/* A lexical scanner generated by flex */ +#include <IceUtil/Config.h> -/* Scanner skeleton version: - * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ - */ +#line 3 "lex.yy.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ +/* begin standard C headers. */ #include <stdio.h> +#include <string.h> #include <errno.h> +#include <stdlib.h> -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif +/* end standard C headers. */ +/* flex integer type definitions */ -#ifdef __cplusplus +#ifndef FLEXINT_H +#define FLEXINT_H -#include <stdlib.h> -#ifndef _WIN32 -#include <unistd.h> +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 #endif -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ -#if __STDC__ +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) -#define YY_USE_PROTOS #define YY_USE_CONST -#endif /* __STDC__ */ +#endif /* defined (__STDC__) */ #endif /* ! __cplusplus */ -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - - /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -80,71 +122,70 @@ * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ -#define BEGIN yy_start = 1 + 2 * +#define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ -#define YY_START ((yy_start - 1) / 2) +#define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) +#define YY_NEW_FILE yyrestart(yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ +#ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif extern int yyleng; + extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; +#define unput(c) yyunput( c, (yytext_ptr) ) +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; @@ -181,12 +222,16 @@ struct yy_buffer_state */ int yy_at_bol; + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; + #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process @@ -200,28 +245,38 @@ struct yy_buffer_state * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ -static YY_BUFFER_STATE yy_current_buffer = 0; +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". + * + * Returns the top of the stack, or NULL. */ -#define YY_CURRENT_BUFFER yy_current_buffer +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; - static int yy_n_chars; /* number of characters read into yy_ch_buf */ - - int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; -static int yy_init = 1; /* whether we need to initialize */ +static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches @@ -229,69 +284,95 @@ static int yy_start = 0; /* start state number */ */ static int yy_did_buffer_switch_on_eof; -void yyrestart YY_PROTO(( FILE *input_file )); +void yyrestart (FILE *input_file ); +void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); +void yy_delete_buffer (YY_BUFFER_STATE b ); +void yy_flush_buffer (YY_BUFFER_STATE b ); +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state (void ); + +static void yyensure_buffer_stack (void ); +static void yy_load_buffer_state (void ); +static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); -void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); -void yy_load_buffer_state YY_PROTO(( void )); -YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); -void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); -void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); -void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); -#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) +#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) -YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); -YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); -YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); +YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); +void *yyalloc (yy_size_t ); +void *yyrealloc (void *,yy_size_t ); +void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer(yyin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) +/* Begin user sect3 */ -#define yywrap() 1 +#define yywrap(n) 1 #define YY_SKIP_YYWRAP + typedef unsigned char YY_CHAR; + FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; + typedef int yy_state_type; + +extern int yylineno; + +int yylineno = 1; + extern char *yytext; #define yytext_ptr yytext -static yy_state_type yy_get_previous_state YY_PROTO(( void )); -static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); -static int yy_get_next_buffer YY_PROTO(( void )); -static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ + (yytext_ptr) = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; + (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 20 #define YY_END_OF_BUFFER 21 -static yyconst short int yy_accept[77] = +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[77] = { 0, 15, 15, 21, 19, 15, 16, 17, 18, 19, 16, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, @@ -303,7 +384,7 @@ static yyconst short int yy_accept[77] = 0, 7, 9, 0, 14, 0 } ; -static yyconst int yy_ec[256] = +static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, @@ -335,14 +416,14 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[31] = +static yyconst flex_int32_t yy_meta[31] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static yyconst short int yy_base[77] = +static yyconst flex_int16_t yy_base[77] = { 0, 0, 0, 93, 94, 29, 94, 94, 94, 26, 94, 32, 23, 66, 62, 76, 65, 74, 61, 72, 24, @@ -354,7 +435,7 @@ static yyconst short int yy_base[77] = 22, 94, 94, 24, 94, 94 } ; -static yyconst short int yy_def[77] = +static yyconst flex_int16_t yy_def[77] = { 0, 76, 1, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, @@ -366,7 +447,7 @@ static yyconst short int yy_def[77] = 76, 76, 76, 76, 76, 0 } ; -static yyconst short int yy_nxt[125] = +static yyconst flex_int16_t yy_nxt[125] = { 0, 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, 4, 13, 4, 14, 15, 16, 4, 4, 17, 4, @@ -384,7 +465,7 @@ static yyconst short int yy_nxt[125] = 76, 76, 76, 76 } ; -static yyconst short int yy_chk[125] = +static yyconst flex_int16_t yy_chk[125] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -405,6 +486,9 @@ static yyconst short int yy_chk[125] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; +extern int yy_flex_debug; +int yy_flex_debug = 0; + /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ @@ -414,7 +498,6 @@ static char *yy_last_accepting_cpos; #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "Scanner.l" -#define INITIAL 0 #line 2 "Scanner.l" // ********************************************************************** @@ -441,8 +524,52 @@ using namespace std; #define YY_INPUT(buf, result, maxSize) parser->getInput(buf, result, maxSize) -#define YY_ALWAYS_INTERACTIVE 1 -#line 445 "lex.yy.c" +#line 527 "lex.yy.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include <unistd.h> +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy (void ); + +int yyget_debug (void ); + +void yyset_debug (int debug_flag ); + +YY_EXTRA_TYPE yyget_extra (void ); + +void yyset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in (void ); + +void yyset_in (FILE * in_str ); + +FILE *yyget_out (void ); + +void yyset_out (FILE * out_str ); + +int yyget_leng (void ); + +char *yyget_text (void ); + +int yyget_lineno (void ); + +void yyset_lineno (int line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -450,65 +577,30 @@ using namespace std; #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); +extern "C" int yywrap (void ); #else -extern int yywrap YY_PROTO(( void )); +extern int yywrap (void ); #endif #endif -#ifndef YY_NO_UNPUT -static void yyunput YY_PROTO(( int c, char *buf_ptr )); -#endif - + static void yyunput (int c,char *buf_ptr ); + #ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); +static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT -#ifdef __cplusplus -static int yyinput YY_PROTO(( void )); -#else -static int input YY_PROTO(( void )); -#endif -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif +#ifdef __cplusplus +static int yyinput (void ); #else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 +static int input (void ); #endif -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif #endif /* Amount of stuff to slurp up with each read. */ @@ -517,12 +609,11 @@ YY_MALLOC_DECL #endif /* Copy whatever the last rule matched to the standard output. */ - #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -530,9 +621,10 @@ YY_MALLOC_DECL */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( yy_current_buffer->yy_is_interactive ) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ - int c = '*', n; \ + int c = '*'; \ + unsigned n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -555,7 +647,9 @@ YY_MALLOC_DECL errno=0; \ clearerr(yyin); \ } \ - } + }\ +\ + #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -576,12 +670,18 @@ YY_MALLOC_DECL #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif +/* end tables serialization structures and prototypes */ + /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL -#define YY_DECL int yylex YY_PROTO(( void )) -#endif +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. @@ -598,27 +698,29 @@ YY_MALLOC_DECL #define YY_RULE_SETUP \ YY_USER_ACTION +/** The main scanner function which does all the work. + */ YY_DECL - { +{ register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; - + #line 35 "Scanner.l" -#line 610 "lex.yy.c" +#line 712 "lex.yy.c" - if ( yy_init ) + if ( !(yy_init) ) { - yy_init = 0; + (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif - if ( ! yy_start ) - yy_start = 1; /* first start state */ + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = stdin; @@ -626,34 +728,36 @@ YY_DECL if ( ! yyout ) yyout = stdout; - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); + } - yy_load_buffer_state(); + yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { - yy_cp = yy_c_buf_p; + yy_cp = (yy_c_buf_p); /* Support of yytext. */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; - yy_current_state = yy_start; + yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -670,24 +774,22 @@ yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; - do_action: /* This label is used only to access EOF actions. */ - switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: @@ -816,6 +918,7 @@ YY_RULE_SETUP } YY_BREAK case 15: +/* rule 15 can match eol */ YY_RULE_SETUP #line 120 "Scanner.l" { @@ -830,6 +933,7 @@ YY_RULE_SETUP } YY_BREAK case 16: +/* rule 16 can match eol */ YY_RULE_SETUP #line 131 "Scanner.l" { @@ -973,33 +1077,33 @@ YY_RULE_SETUP #line 258 "Scanner.l" ECHO; YY_BREAK -#line 976 "lex.yy.c" +#line 1080 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our + * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position @@ -1009,13 +1113,13 @@ case YY_STATE_EOF(INITIAL): * end-of-buffer state). Contrast this with the test * in input(). */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have @@ -1028,30 +1132,30 @@ case YY_STATE_EOF(INITIAL): yy_next_state = yy_try_NUL_trans( yy_current_state ); - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; + yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { - yy_cp = yy_c_buf_p; + yy_cp = (yy_c_buf_p); goto yy_find_action; } } - else switch ( yy_get_next_buffer() ) + else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { - yy_did_buffer_switch_on_eof = 0; + (yy_did_buffer_switch_on_eof) = 0; - if ( yywrap() ) + if ( yywrap(0) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up @@ -1062,7 +1166,7 @@ case YY_STATE_EOF(INITIAL): * YY_NULL, it'll still work - another * YY_NULL will get returned. */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; @@ -1070,30 +1174,30 @@ case YY_STATE_EOF(INITIAL): else { - if ( ! yy_did_buffer_switch_on_eof ) + if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - yy_current_state = yy_get_previous_state(); + yy_current_state = yy_get_previous_state( ); - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; @@ -1104,8 +1208,7 @@ case YY_STATE_EOF(INITIAL): "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ - } /* end of yylex */ - +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -1114,21 +1217,20 @@ case YY_STATE_EOF(INITIAL): * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ - -static int yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); - if ( yy_current_buffer->yy_fill_buffer == 0 ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. @@ -1148,34 +1250,30 @@ static int yy_get_next_buffer() /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); + (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { @@ -1188,8 +1286,7 @@ static int yy_get_next_buffer() b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); + yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ @@ -1199,35 +1296,35 @@ static int yy_get_next_buffer() YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - num_to_read = yy_current_buffer->yy_buf_size - + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; -#endif + } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); - yy_current_buffer->yy_n_chars = yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } - if ( yy_n_chars == 0 ) + if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); + yyrestart(yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } @@ -1235,32 +1332,39 @@ static int yy_get_next_buffer() else ret_val = EOB_ACT_CONTINUE_SCAN; - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - return ret_val; - } + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + return ret_val; +} /* yy_get_previous_state - get the state just before the EOB char was reached */ -static yy_state_type yy_get_previous_state() - { + static yy_state_type yy_get_previous_state (void) +{ register yy_state_type yy_current_state; register char *yy_cp; + + yy_current_state = (yy_start); - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1272,30 +1376,23 @@ static yy_state_type yy_get_previous_state() } return yy_current_state; - } - +} /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ - -#ifdef YY_USE_PROTOS -static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) -#else -static yy_state_type yy_try_NUL_trans( yy_current_state ) -yy_state_type yy_current_state; -#endif - { + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; + register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { @@ -1307,80 +1404,73 @@ yy_state_type yy_current_state; yy_is_jam = (yy_current_state == 76); return yy_is_jam ? 0 : yy_current_state; - } - +} -#ifndef YY_NO_UNPUT -#ifdef YY_USE_PROTOS -static void yyunput( int c, register char *yy_bp ) -#else -static void yyunput( c, yy_bp ) -int c; -register char *yy_bp; -#endif - { - register char *yy_cp = yy_c_buf_p; + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; + *yy_cp = (yy_hold_char); - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - while ( source > yy_current_buffer->yy_ch_buf ) + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } -#endif /* ifndef YY_NO_UNPUT */ - - +#ifndef YY_NO_INPUT #ifdef __cplusplus -static int yyinput() + static int yyinput (void) #else -static int input() + static int input (void) #endif - { - int c; - *yy_c_buf_p = yy_hold_char; +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ - *yy_c_buf_p = '\0'; + *(yy_c_buf_p) = '\0'; else { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); - switch ( yy_get_next_buffer() ) + switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() @@ -1394,16 +1484,16 @@ static int input() */ /* Reset buffer status. */ - yyrestart( yyin ); + yyrestart(yyin ); - /* fall through */ + /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { - if ( yywrap() ) + if ( yywrap(0) ) return EOF; - if ( ! yy_did_buffer_switch_on_eof ) + if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); @@ -1413,90 +1503,92 @@ static int input() } case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; + (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); return c; - } - - -#ifdef YY_USE_PROTOS -void yyrestart( FILE *input_file ) -#else -void yyrestart( input_file ) -FILE *input_file; -#endif - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); +} +#endif /* ifndef YY_NO_INPUT */ - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer(yyin,YY_BUF_SIZE ); } + yy_init_buffer(YY_CURRENT_BUFFER,input_file ); + yy_load_buffer_state( ); +} -#ifdef YY_USE_PROTOS -void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) -#else -void yy_switch_to_buffer( new_buffer ) -YY_BUFFER_STATE new_buffer; -#endif - { - if ( yy_current_buffer == new_buffer ) +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) return; - if ( yy_current_buffer ) + if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } - yy_current_buffer = new_buffer; - yy_load_buffer_state(); + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ - yy_did_buffer_switch_on_eof = 1; - } - - -#ifdef YY_USE_PROTOS -void yy_load_buffer_state( void ) -#else -void yy_load_buffer_state() -#endif - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } + (yy_did_buffer_switch_on_eof) = 1; +} +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) -#else -YY_BUFFER_STATE yy_create_buffer( file, size ) -FILE *file; -int size; -#endif - { +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); @@ -1505,84 +1597,71 @@ int size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - yy_init_buffer( b, file ); + yy_init_buffer(b,file ); return b; - } - +} -#ifdef YY_USE_PROTOS -void yy_delete_buffer( YY_BUFFER_STATE b ) -#else -void yy_delete_buffer( b ) -YY_BUFFER_STATE b; -#endif - { +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) return; - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); + yyfree((void *) b->yy_ch_buf ); - yy_flex_free( (void *) b ); - } - - -#ifndef _WIN32 -#include <unistd.h> -#else -#ifndef YY_ALWAYS_INTERACTIVE -#ifndef YY_NEVER_INTERACTIVE -extern int isatty YY_PROTO(( int )); -#endif -#endif -#endif - -#ifdef YY_USE_PROTOS -void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) -#else -void yy_init_buffer( b, file ) -YY_BUFFER_STATE b; -FILE *file; -#endif + yyfree((void *) b ); +} +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - { - yy_flush_buffer( b ); +{ + int oerrno = errno; + + yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; -#if YY_ALWAYS_INTERACTIVE - b->yy_is_interactive = 1; -#else -#if YY_NEVER_INTERACTIVE - b->yy_is_interactive = 0; -#else - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; -#endif -#endif - } + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + b->yy_is_interactive = 1; -#ifdef YY_USE_PROTOS -void yy_flush_buffer( YY_BUFFER_STATE b ) -#else -void yy_flush_buffer( b ) -YY_BUFFER_STATE b; -#endif + errno = oerrno; +} - { - if ( ! b ) +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) return; b->yy_n_chars = 0; @@ -1599,29 +1678,125 @@ YY_BUFFER_STATE b; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; - if ( b == yy_current_buffer ) - yy_load_buffer_state(); + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; } + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ -#ifndef YY_NO_SCAN_BUFFER -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) -#else -YY_BUFFER_STATE yy_scan_buffer( base, size ) -char *base; -yy_size_t size; -#endif - { - YY_BUFFER_STATE b; + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); @@ -1635,56 +1810,51 @@ yy_size_t size; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - yy_switch_to_buffer( b ); + yy_switch_to_buffer(b ); return b; - } -#endif - - -#ifndef YY_NO_SCAN_STRING -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) -#else -YY_BUFFER_STATE yy_scan_string( yy_str ) -yyconst char *yy_str; -#endif - { - int len; - for ( len = 0; yy_str[len]; ++len ) - ; - - return yy_scan_bytes( yy_str, len ); - } -#endif +} +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) +{ + + return yy_scan_bytes(yystr,strlen(yystr) ); +} -#ifndef YY_NO_SCAN_BYTES -#ifdef YY_USE_PROTOS -YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) -#else -YY_BUFFER_STATE yy_scan_bytes( bytes, len ) -yyconst char *bytes; -int len; -#endif - { +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) yy_flex_alloc( n ); + n = _yybytes_len + 2; + buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; - buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = yy_scan_buffer( buf, n ); + b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); @@ -1694,148 +1864,196 @@ int len; b->yy_is_our_buffer = 1; return b; - } +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 #endif +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} -#ifndef YY_NO_PUSH_STATE -#ifdef YY_USE_PROTOS -static void yy_push_state( int new_state ) -#else -static void yy_push_state( new_state ) -int new_state; -#endif - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; +/* Redefine yyless() so it works in section 3 code. */ - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); +/* Accessor methods (get/set functions) to struct members. */ - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} - yy_start_stack[yy_start_stack_ptr++] = YY_START; +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} - BEGIN(new_state); - } -#endif +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} +/** Get the current token. + * + */ -#ifndef YY_NO_POP_STATE -static void yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); +char *yyget_text (void) +{ + return yytext; +} - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif +/** Set the current line number. + * @param line_number + * + */ +void yyset_lineno (int line_number ) +{ + + yylineno = line_number; +} +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * in_str ) +{ + yyin = in_str ; +} -#ifndef YY_NO_TOP_STATE -static int yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif +void yyset_out (FILE * out_str ) +{ + yyout = out_str ; +} -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int bdebug ) +{ + yy_flex_debug = bdebug ; +} -#ifdef YY_USE_PROTOS -static void yy_fatal_error( yyconst char msg[] ) +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; #else -static void yy_fatal_error( msg ) -char msg[]; + yyin = (FILE *) 0; + yyout = (FILE *) 0; #endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); - } + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } -/* Redefine yyless() so it works in section 3 code. */ + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + return 0; +} -/* Internal utility routines. */ +/* + * Internal utility routines. + */ #ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; - } +} #endif #ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { +static int yy_flex_strlen (yyconst char * s ) +{ register int n; for ( n = 0; s[n]; ++n ) ; return n; - } +} #endif - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { +void *yyalloc (yy_size_t size ) +{ return (void *) malloc( size ); - } +} -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { +void *yyrealloc (void * ptr, yy_size_t size ) +{ /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -1844,24 +2062,16 @@ yy_size_t size; * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); - } +} -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif #line 258 "Scanner.l" + + diff --git a/cpp/demo/Freeze/library/expect.py b/cpp/demo/Freeze/library/expect.py index 3ace50b52cd..52b8dd0398e 100755 --- a/cpp/demo/Freeze/library/expect.py +++ b/cpp/demo/Freeze/library/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import library -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('.* ready') @@ -34,12 +34,12 @@ client.expect('>') library.run(client, server) -print "running with collocated server" +print("running with collocated server") -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('>>> ') diff --git a/cpp/demo/Freeze/phonebook/Grammar.cpp b/cpp/demo/Freeze/phonebook/Grammar.cpp index 9d138d03042..5309aa41c35 100644 --- a/cpp/demo/Freeze/phonebook/Grammar.cpp +++ b/cpp/demo/Freeze/phonebook/Grammar.cpp @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,51 +54,20 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - +/* Push parsers. */ +#define YYPUSH 0 +/* Pull parsers. */ +#define YYPULL 1 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_HELP = 258, - TOK_EXIT = 259, - TOK_ADD_CONTACTS = 260, - TOK_FIND_CONTACTS = 261, - TOK_NEXT_FOUND_CONTACT = 262, - TOK_PRINT_CURRENT = 263, - TOK_SET_CURRENT_NAME = 264, - TOK_SET_CURRENT_ADDRESS = 265, - TOK_SET_CURRENT_PHONE = 266, - TOK_REMOVE_CURRENT = 267, - TOK_SET_EVICTOR_SIZE = 268, - TOK_SHUTDOWN = 269, - TOK_STRING = 270 - }; -#endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_ADD_CONTACTS 260 -#define TOK_FIND_CONTACTS 261 -#define TOK_NEXT_FOUND_CONTACT 262 -#define TOK_PRINT_CURRENT 263 -#define TOK_SET_CURRENT_NAME 264 -#define TOK_SET_CURRENT_ADDRESS 265 -#define TOK_SET_CURRENT_PHONE 266 -#define TOK_REMOVE_CURRENT 267 -#define TOK_SET_EVICTOR_SIZE 268 -#define TOK_SHUTDOWN 269 -#define TOK_STRING 270 - +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "Grammar.y" @@ -133,6 +101,9 @@ yyerror(const char* s) +/* Line 189 of yacc.c */ +#line 106 "Grammar.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -151,20 +122,44 @@ yyerror(const char* s) # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_ADD_CONTACTS = 260, + TOK_FIND_CONTACTS = 261, + TOK_NEXT_FOUND_CONTACT = 262, + TOK_PRINT_CURRENT = 263, + TOK_SET_CURRENT_NAME = 264, + TOK_SET_CURRENT_ADDRESS = 265, + TOK_SET_CURRENT_PHONE = 266, + TOK_REMOVE_CURRENT = 267, + TOK_SET_EVICTOR_SIZE = 268, + TOK_SHUTDOWN = 269, + TOK_STRING = 270 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 168 "Grammar.tab.c" +/* Line 264 of yacc.c */ +#line 163 "Grammar.tab.c" #ifdef short # undef short @@ -239,14 +234,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -327,9 +322,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -363,12 +358,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -755,17 +750,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -799,11 +797,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1083,10 +1081,8 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1105,10 +1101,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1132,74 +1127,75 @@ yyparse () #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + /* Number of syntax errors so far. */ + int yynerrs; - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1229,7 +1225,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1237,7 +1232,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1260,9 +1254,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1273,7 +1266,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1283,6 +1275,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1291,16 +1286,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1332,20 +1327,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1385,30 +1376,40 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 55 "Grammar.y" { ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 58 "Grammar.y" { ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 66 "Grammar.y" { ;} break; case 5: + +/* Line 1455 of yacc.c */ #line 69 "Grammar.y" { ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 77 "Grammar.y" { parser->usage(); @@ -1416,6 +1417,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 81 "Grammar.y" { return 0; @@ -1423,6 +1426,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 85 "Grammar.y" { parser->addContacts((yyvsp[(2) - (3)])); @@ -1430,6 +1435,8 @@ yyreduce: break; case 9: + +/* Line 1455 of yacc.c */ #line 89 "Grammar.y" { parser->findContacts((yyvsp[(2) - (3)])); @@ -1437,6 +1444,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 93 "Grammar.y" { parser->nextFoundContact(); @@ -1444,6 +1453,8 @@ yyreduce: break; case 11: + +/* Line 1455 of yacc.c */ #line 97 "Grammar.y" { parser->printCurrent(); @@ -1451,6 +1462,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 101 "Grammar.y" { parser->setCurrentName((yyvsp[(2) - (3)])); @@ -1458,6 +1471,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 105 "Grammar.y" { parser->setCurrentAddress((yyvsp[(2) - (3)])); @@ -1465,6 +1480,8 @@ yyreduce: break; case 14: + +/* Line 1455 of yacc.c */ #line 109 "Grammar.y" { parser->setCurrentPhone((yyvsp[(2) - (3)])); @@ -1472,6 +1489,8 @@ yyreduce: break; case 15: + +/* Line 1455 of yacc.c */ #line 113 "Grammar.y" { parser->removeCurrent(); @@ -1479,6 +1498,8 @@ yyreduce: break; case 16: + +/* Line 1455 of yacc.c */ #line 117 "Grammar.y" { parser->setEvictorSize((yyvsp[(2) - (3)])); @@ -1486,6 +1507,8 @@ yyreduce: break; case 17: + +/* Line 1455 of yacc.c */ #line 121 "Grammar.y" { parser->shutdown(); @@ -1493,6 +1516,8 @@ yyreduce: break; case 18: + +/* Line 1455 of yacc.c */ #line 125 "Grammar.y" { yyerrok; @@ -1500,12 +1525,16 @@ yyreduce: break; case 19: + +/* Line 1455 of yacc.c */ #line 129 "Grammar.y" { ;} break; case 20: + +/* Line 1455 of yacc.c */ #line 137 "Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); @@ -1514,6 +1543,8 @@ yyreduce: break; case 21: + +/* Line 1455 of yacc.c */ #line 142 "Grammar.y" { (yyval) = (yyvsp[(1) - (1)]); @@ -1521,8 +1552,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1526 "Grammar.tab.c" + +/* Line 1455 of yacc.c */ +#line 1558 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1533,7 +1565,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1598,7 +1629,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1615,7 +1646,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1672,9 +1703,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1699,7 +1727,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1710,7 +1738,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -1736,6 +1764,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 147 "Grammar.y" diff --git a/cpp/demo/Freeze/phonebook/Grammar.h b/cpp/demo/Freeze/phonebook/Grammar.h index 759d1869ca2..fb5de6918c2 100644 --- a/cpp/demo/Freeze/phonebook/Grammar.h +++ b/cpp/demo/Freeze/phonebook/Grammar.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -54,30 +54,16 @@ TOK_STRING = 270 }; #endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_ADD_CONTACTS 260 -#define TOK_FIND_CONTACTS 261 -#define TOK_NEXT_FOUND_CONTACT 262 -#define TOK_PRINT_CURRENT 263 -#define TOK_SET_CURRENT_NAME 264 -#define TOK_SET_CURRENT_ADDRESS 265 -#define TOK_SET_CURRENT_PHONE 266 -#define TOK_REMOVE_CURRENT 267 -#define TOK_SET_EVICTOR_SIZE 268 -#define TOK_SHUTDOWN 269 -#define TOK_STRING 270 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/cpp/demo/Freeze/phonebook/expect.py b/cpp/demo/Freeze/phonebook/expect.py index fb8c23abd5b..bcd9808d949 100755 --- a/cpp/demo/Freeze/phonebook/expect.py +++ b/cpp/demo/Freeze/phonebook/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import phonebook -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('.* ready') @@ -34,12 +34,12 @@ client.expect('>>> ') phonebook.run(client, server) -print "running with collocated server" +print("running with collocated server") -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('>>> ') diff --git a/cpp/demo/Freeze/transform/expect.py b/cpp/demo/Freeze/transform/expect.py index 697b60d3578..c536511e279 100755 --- a/cpp/demo/Freeze/transform/expect.py +++ b/cpp/demo/Freeze/transform/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import transform transform.run('./create', './recreate', './read', './readnew') diff --git a/cpp/demo/Glacier2/callback/expect.py b/cpp/demo/Glacier2/callback/expect.py index b5e9633eeb9..f7430af0d59 100755 --- a/cpp/demo/Glacier2/callback/expect.py +++ b/cpp/demo/Glacier2/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Glacier2 import callback server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Glacier2/chat/expect.py b/cpp/demo/Glacier2/chat/expect.py index 890960bb98b..a59a5c888c0 100755 --- a/cpp/demo/Glacier2/chat/expect.py +++ b/cpp/demo/Glacier2/chat/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') @@ -28,16 +28,16 @@ glacier2 = Util.spawn(Util.getGlacier2Router() + ' --Ice.Config=config.glacier2 glacier2.expect('Glacier2.Client ready') glacier2.expect('Glacier2.Server ready') -print "starting client 1...", +sys.stdout.write("starting client 1... ") sys.stdout.flush() client1 = Util.spawn('./client') client1.expect('user id:') client1.sendline("foo") client1.expect('password:') client1.sendline("foo") -print "ok" +print("ok") -print "starting client 2...", +sys.stdout.write("starting client 2... ") sys.stdout.flush() client2 = Util.spawn('./client') client2.expect('user id:') @@ -46,9 +46,9 @@ client2.expect('password:') client2.sendline("bar") client1.expect("bar has entered the chat room") -print "ok" +print("ok") -print "testing chat...", +sys.stdout.write("testing chat... ") sys.stdout.flush() client1.sendline("hi") client1.expect("foo says: hi") @@ -64,7 +64,7 @@ client2.expect("foo has left the chat room") client2.sendline("/quit") client2.waitTestSuccess() -print "ok" +print("ok") server.kill(signal.SIGINT) server.waitTestSuccess() diff --git a/cpp/demo/Ice/async/expect.py b/cpp/demo/Ice/async/expect.py index 4c20aa34150..4150f135175 100755 --- a/cpp/demo/Ice/async/expect.py +++ b/cpp/demo/Ice/async/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import async server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/bidir/expect.py b/cpp/demo/Ice/bidir/expect.py index fe86f7b95cc..381688e8106 100755 --- a/cpp/demo/Ice/bidir/expect.py +++ b/cpp/demo/Ice/bidir/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import bidir server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/callback/expect.py b/cpp/demo/Ice/callback/expect.py index b9e9683ea58..8ab9968f507 100755 --- a/cpp/demo/Ice/callback/expect.py +++ b/cpp/demo/Ice/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import callback server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/converter/expect.py b/cpp/demo/Ice/converter/expect.py index 590cded83ac..21800dc2266 100755 --- a/cpp/demo/Ice/converter/expect.py +++ b/cpp/demo/Ice/converter/expect.py @@ -16,28 +16,28 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') client = Util.spawn('./client') client.expect('.*==>') -print "testing with conversion... ", +sys.stdout.write("testing with conversion... ") sys.stdout.flush() client.sendline('u') server.expect('Received \\(UTF-8\\): "Bonne journ\\\\351e"') client.expect('Received: "Bonne journ\\\\303\\\\251e"') -print "ok" +print("ok") -print "testing without conversion... ", +sys.stdout.write("testing without conversion... ") client.sendline('t') server.expect('Received \\(UTF-8\\): "Bonne journ\\\\303\\\\251e"') client.expect('Received: "Bonne journ\\\\351e"') -print "ok" +print("ok") client.sendline('s') server.waitTestSuccess() diff --git a/cpp/demo/Ice/hello/expect.py b/cpp/demo/Ice/hello/expect.py index 5796f363955..82b66514830 100755 --- a/cpp/demo/Ice/hello/expect.py +++ b/cpp/demo/Ice/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import hello server = Util.spawn('./server --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/cpp/demo/Ice/interleaved/expect.py b/cpp/demo/Ice/interleaved/expect.py index fdf40f00260..9ec158b5dd8 100755 --- a/cpp/demo/Ice/interleaved/expect.py +++ b/cpp/demo/Ice/interleaved/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import interleaved server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/invoke/expect.py b/cpp/demo/Ice/invoke/expect.py index 78c6e0013f5..1176eadfa87 100755 --- a/cpp/demo/Ice/invoke/expect.py +++ b/cpp/demo/Ice/invoke/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import invoke server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/latency/expect.py b/cpp/demo/Ice/latency/expect.py index 2a04f308d43..bbde1cb2477 100755 --- a/cpp/demo/Ice/latency/expect.py +++ b/cpp/demo/Ice/latency/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing ping... ", +sys.stdout.write("testing ping... ") sys.stdout.flush() client = Util.spawn('./client') client.waitTestSuccess(timeout=100) -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess() -print client.before +print(client.before) diff --git a/cpp/demo/Ice/minimal/expect.py b/cpp/demo/Ice/minimal/expect.py index fe15c20274d..18f5823a845 100755 --- a/cpp/demo/Ice/minimal/expect.py +++ b/cpp/demo/Ice/minimal/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,20 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('./client') client.waitTestSuccess() server.expect('Hello World!') -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) -#server.waitTestSuccess() +server.waitTestFail() diff --git a/cpp/demo/Ice/multicast/expect.py b/cpp/demo/Ice/multicast/expect.py index b3b618ca5a6..57d45167330 100755 --- a/cpp/demo/Ice/multicast/expect.py +++ b/cpp/demo/Ice/multicast/expect.py @@ -16,10 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) +sys.path.append(os.path.join(path[0], "scripts")) -from demoscript import * +from demoscript import Util from demoscript.Ice import multicast multicast.run("./client", "./server") diff --git a/cpp/demo/Ice/nested/expect.py b/cpp/demo/Ice/nested/expect.py index 58814de5a0e..908827e6d1a 100755 --- a/cpp/demo/Ice/nested/expect.py +++ b/cpp/demo/Ice/nested/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import nested server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/nrvo/expect.py b/cpp/demo/Ice/nrvo/expect.py index 81acd6aa7a7..0023b1579b5 100644 --- a/cpp/demo/Ice/nrvo/expect.py +++ b/cpp/demo/Ice/nrvo/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import nrvo server = Util.spawn('./server --Ice.PrintAdapterReady') @@ -28,3 +28,5 @@ client = Util.spawn('./client') client.expect('.*==>') nrvo.run(client, server) + +server.waitTestSuccess() diff --git a/cpp/demo/Ice/plugin/expect.py b/cpp/demo/Ice/plugin/expect.py index d6d6b3d59a1..f89da1ddbec 100755 --- a/cpp/demo/Ice/plugin/expect.py +++ b/cpp/demo/Ice/plugin/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import plugin Util.addLdPath(os.getcwd()) diff --git a/cpp/demo/Ice/session/expect.py b/cpp/demo/Ice/session/expect.py index 0fe2e9f6117..f0a60cdfea7 100755 --- a/cpp/demo/Ice/session/expect.py +++ b/cpp/demo/Ice/session/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import session server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/throughput/expect.py b/cpp/demo/Ice/throughput/expect.py index b4728f315c6..49843efbc59 100755 --- a/cpp/demo/Ice/throughput/expect.py +++ b/cpp/demo/Ice/throughput/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import throughput server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/Ice/value/expect.py b/cpp/demo/Ice/value/expect.py index 82beb9d502e..f3a3b6bea9e 100755 --- a/cpp/demo/Ice/value/expect.py +++ b/cpp/demo/Ice/value/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import value server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/IceBox/hello/expect.py b/cpp/demo/IceBox/hello/expect.py index c3d2368fc78..e80bce92ad2 100755 --- a/cpp/demo/IceBox/hello/expect.py +++ b/cpp/demo/IceBox/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceBox import hello # Override the service command line diff --git a/cpp/demo/IceGrid/allocate/expect.py b/cpp/demo/IceGrid/allocate/expect.py index faf14b93cdb..e861174bcf2 100755 --- a/cpp/demo/IceGrid/allocate/expect.py +++ b/cpp/demo/IceGrid/allocate/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import allocate allocate.run('./client') diff --git a/cpp/demo/IceGrid/icebox/expect.py b/cpp/demo/IceGrid/icebox/expect.py index 71bc07e36fe..d0977bd9980 100755 --- a/cpp/demo/IceGrid/icebox/expect.py +++ b/cpp/demo/IceGrid/icebox/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import icebox desc = 'application.xml' diff --git a/cpp/demo/IceGrid/replication/expect.py b/cpp/demo/IceGrid/replication/expect.py index 904462a88e7..ac41fcea230 100755 --- a/cpp/demo/IceGrid/replication/expect.py +++ b/cpp/demo/IceGrid/replication/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,27 +16,26 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db/master") Util.cleanDbDir("db/node1") Util.cleanDbDir("db/node2") Util.cleanDbDir("db/replica1") Util.cleanDbDir("db/replica2") -print "ok" +print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' -print "starting icegridnodes...", +sys.stdout.write("starting icegridnodes... ") sys.stdout.flush() master = Util.spawn(Util.getIceGridRegistry() + ' --Ice.Config=config.master --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut=') master.expect('IceGrid.Registry.Internal ready\nIceGrid.Registry.Server ready\nIceGrid.Registry.Client ready') @@ -48,15 +47,15 @@ node1 = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.node1 --Ice.Pri node1.expect('IceGrid.Node ready') node2 = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.node2 --Ice.PrintAdapterReady --Ice.StdErr= --Ice.StdOut= %s' % (args)) node2.expect('IceGrid.Node ready') -print "ok" +print("ok") -print "deploying application...", +sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.client') admin.expect('>>>') admin.sendline("application add \'application.xml\'") admin.expect('>>>') -print "ok" +print("ok") def runtest(): client = Util.spawn('./client') @@ -71,12 +70,12 @@ def runtest(): client.waitTestSuccess(timeout=1) -print "testing client...", +sys.stdout.write("testing client... ") sys.stdout.flush() runtest() -print "ok" +print("ok") -print "testing replication...", +sys.stdout.write("testing replication... ") sys.stdout.flush() admin.sendline('registry shutdown Replica1') admin.expect('>>>') @@ -86,9 +85,9 @@ admin.sendline('registry shutdown Replica2') admin.expect('>>>') replica2.waitTestSuccess() runtest() -print "ok" +print("ok") -print "completing shutdown...", +sys.stdout.write("completing shutdown... ") sys.stdout.flush() admin.sendline('node shutdown node1') admin.expect('>>>') @@ -104,4 +103,4 @@ master.waitTestSuccess() admin.sendline('exit') admin.waitTestSuccess(timeout=120) -print "ok" +print("ok") diff --git a/cpp/demo/IceGrid/secure/.gitignore b/cpp/demo/IceGrid/secure/.gitignore index 58441e933c7..ebb4189ea80 100644 --- a/cpp/demo/IceGrid/secure/.gitignore +++ b/cpp/demo/IceGrid/secure/.gitignore @@ -7,4 +7,6 @@ Hello.cpp Hello.h db/registry/* db/node/* +db/master/* +db/slave/* certs/* diff --git a/cpp/demo/IceGrid/secure/expect.py b/cpp/demo/IceGrid/secure/expect.py index 77feee84f70..0dcf1101caa 100755 --- a/cpp/demo/IceGrid/secure/expect.py +++ b/cpp/demo/IceGrid/secure/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,26 +16,25 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db/master") Util.cleanDbDir("db/slave") Util.cleanDbDir("db/node") Util.cleanDbDir("certs") -print "ok" +print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' -print "creating certificates...", +sys.stdout.write("creating certificates... ") sys.stdout.flush() makecerts = Util.spawn("python -u makecerts.py") makecerts.expect("Do you want to keep this as the CA subject name?") @@ -63,9 +62,9 @@ makecerts.sendline("y") makecerts.expect("1 out of 1 certificate requests certified, commit?") makecerts.sendline("y") makecerts.waitTestSuccess() -print "ok" +print("ok") -print "starting icegrid...", +sys.stdout.write("starting icegrid... ") sys.stdout.flush() masterProps = " --Ice.PrintAdapterReady" master = Util.spawn(Util.getIceGridRegistry() + ' --Ice.Config=config.master' + masterProps) @@ -81,18 +80,18 @@ slave.expect('IceGrid.Registry.Client ready') node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.node --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Node ready') -print "ok" +print("ok") -print "starting glacier2...", +sys.stdout.write("starting glacier2... ") sys.stdout.flush() glacier2Props = " --Ice.PrintAdapterReady --Glacier2.SessionTimeout=5" glacier2 = Util.spawn(Util.getGlacier2Router() + ' --Ice.Config=config.glacier2' + glacier2Props) glacier2.expect('Glacier2.Client ready') glacier2.expect('Glacier2.Server ready') -print "ok" +print("ok") -print "deploying application...", +sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.admin') admin.expect('>>>') @@ -100,7 +99,7 @@ admin.sendline("application add application.xml") admin.expect('>>>') admin.sendline('exit') admin.waitTestSuccess(timeout=120) -print "ok" +print("ok") def runtest(): client = Util.spawn('./client') @@ -115,12 +114,12 @@ def runtest(): client.waitTestSuccess(timeout=1) -print "testing client...", +sys.stdout.write("testing client... ") sys.stdout.flush() runtest() -print "ok" +print("ok") -print "completing shutdown...", +sys.stdout.write("completing shutdown... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.admin') @@ -144,4 +143,4 @@ admin.waitTestSuccess(timeout=120) glacier2.kill(signal.SIGINT) glacier2.waitTestSuccess() -print "ok" +print("ok") diff --git a/cpp/demo/IceGrid/secure/makecerts.py b/cpp/demo/IceGrid/secure/makecerts.py index 6d49467d33e..0b44a1f9ba9 100755 --- a/cpp/demo/IceGrid/secure/makecerts.py +++ b/cpp/demo/IceGrid/secure/makecerts.py @@ -18,18 +18,18 @@ def runIceca(args): def createCertificate(filename, cn): - print "======= Creating " + filename + " certificate =======" + print("======= Creating " + filename + " certificate =======") runIceca('request --no-password --overwrite "%s" "%s"' % (filename, cn)) runIceca("sign --in %s_req.pem --out %s_cert.pem" % (filename, filename)) os.remove("%s_req.pem" % filename) - print - print + print("") + print("") cwd = os.getcwd() if not os.path.exists("certs") or os.path.basename(cwd) != "secure": - print "You must run this script from the secure demo directory" + print("You must run this script from the secure demo directory") sys.exit(1) os.environ["ICE_CA_HOME"] = os.path.abspath("certs") @@ -39,10 +39,10 @@ os.chdir("certs") # # First, create the certificate authority. # -print "======= Creating Certificate Authority =======" +print("======= Creating Certificate Authority =======") runIceca("init --overwrite --no-password") -print -print +print("") +print("") createCertificate("master", "Master") createCertificate("slave", "Slave") @@ -50,7 +50,7 @@ createCertificate("node", "Node") createCertificate("glacier2", "Glacier2") createCertificate("server", "Server") -print "======= Creating Java Key Store =======" +print("======= Creating Java Key Store =======") try: os.remove("certs.jks") diff --git a/cpp/demo/IceGrid/sessionActivation/expect.py b/cpp/demo/IceGrid/sessionActivation/expect.py index 7dbd6b89405..bf787cb0c50 100755 --- a/cpp/demo/IceGrid/sessionActivation/expect.py +++ b/cpp/demo/IceGrid/sessionActivation/expect.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import sessionActivation sessionActivation.run('./client') - diff --git a/cpp/demo/IceGrid/simple/expect.py b/cpp/demo/IceGrid/simple/expect.py index 426054077f5..d2bd07efe14 100755 --- a/cpp/demo/IceGrid/simple/expect.py +++ b/cpp/demo/IceGrid/simple/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import simple simple.run('./client') diff --git a/cpp/demo/IceStorm/clock/expect.py b/cpp/demo/IceStorm/clock/expect.py index bd3c080afba..fdf71c1c8bd 100755 --- a/cpp/demo/IceStorm/clock/expect.py +++ b/cpp/demo/IceStorm/clock/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceStorm import clock clock.run('./subscriber', './publisher') diff --git a/cpp/demo/IceStorm/counter/expect.py b/cpp/demo/IceStorm/counter/expect.py index b47e550b8f7..e441c84025f 100755 --- a/cpp/demo/IceStorm/counter/expect.py +++ b/cpp/demo/IceStorm/counter/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") if Util.defaultHost: args = ' --IceBox.Service.IceStorm="IceStormService,34:createIceStorm --Ice.Config=config.service %s"' \ @@ -36,7 +35,7 @@ else: icestorm = Util.spawn('%s --Ice.Config=config.icebox --Ice.PrintAdapterReady %s' % (Util.getIceBox(), args)) icestorm.expect('.* ready') -print "testing single client...", +sys.stdout.write("testing single client... ") sys.stdout.flush() server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') @@ -44,27 +43,27 @@ client1 = Util.spawn('./client') client1.expect('init: 0') client1.sendline('i') client1.expect('int: 1 total: 1') -print "ok" +print("ok") -print "testing second client...", +sys.stdout.write("testing second client... ") sys.stdout.flush() client2 = Util.spawn('./client') client2.expect('init: 1') client2.sendline('i') client1.expect('int: 1 total: 2') client2.expect('int: 1 total: 2') -print "ok" +print("ok") -print "testing third client...", +sys.stdout.write("testing third client... ") client3 = Util.spawn('./client') client3.expect('init: 2') client3.sendline('d') client1.expect('int: -1 total: 1') client2.expect('int: -1 total: 1') client3.expect('int: -1 total: 1') -print "ok" +print("ok") -print "testing removing client...", +sys.stdout.write("testing removing client... ") client3.sendline('x') client3.waitTestSuccess() @@ -75,7 +74,7 @@ client1.sendline('x') client1.waitTestSuccess() client2.sendline('x') client2.waitTestSuccess() -print "ok" +print("ok") server.kill(signal.SIGINT) server.waitTestSuccess() diff --git a/cpp/demo/IceStorm/replicated/expect.py b/cpp/demo/IceStorm/replicated/expect.py index 43ba9ad873e..6815b9a5401 100755 --- a/cpp/demo/IceStorm/replicated/expect.py +++ b/cpp/demo/IceStorm/replicated/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util import time, signal desc = 'application.xml' @@ -37,32 +37,32 @@ if Util.isNoServices() or Util.isDebugBuild(): fi.close() fo.close() -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db/node") Util.cleanDbDir("db/registry") -print "ok" +print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' -print "starting icegridnode...", +sys.stdout.write("starting icegridnode... ") sys.stdout.flush() node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Registry.Server ready\nIceGrid.Registry.Client ready\nIceGrid.Node ready') -print "ok" +print("ok") -print "deploying application...", +sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.grid') admin.expect('>>>') admin.sendline("application add \'%s\'" %(desc)) admin.expect('>>>') -print "ok" +print("ok") -print "testing pub/sub...", +sys.stdout.write("testing pub/sub... ") sys.stdout.flush() sub = Util.spawn('./subscriber --Ice.PrintAdapterReady') @@ -80,7 +80,7 @@ pub = Util.spawn('./publisher') time.sleep(3) sub.expect('[0-9][0-9]/[0-9][0-9].*\n[0-9][0-9]/[0-9][0-9]') -print "ok" +print("ok") sub.kill(signal.SIGINT) sub.waitTestSuccess() diff --git a/cpp/demo/IceStorm/replicated2/expect.py b/cpp/demo/IceStorm/replicated2/expect.py index 82ec81f2f56..3572447bf48 100755 --- a/cpp/demo/IceStorm/replicated2/expect.py +++ b/cpp/demo/IceStorm/replicated2/expect.py @@ -16,18 +16,18 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util import time, signal -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db1"); Util.cleanDbDir("db2") Util.cleanDbDir("db3") -print "ok" +print("ok") if Util.defaultHost: a1 = ' --IceBox.Service.IceStorm="IceStormService,34:createIceStorm --Ice.Config=config.s1 %s"' \ @@ -41,7 +41,7 @@ else: a2 = '' a3 = '' -print "starting replicas...", +sys.stdout.write("starting replicas... ") sys.stdout.flush() ib1 = Util.spawn('%s --Ice.Config=config.ib1 --Ice.PrintAdapterReady %s' % (Util.getIceBox(), a1)) ib1.expect('.* ready') @@ -49,13 +49,13 @@ ib2 = Util.spawn('%s --Ice.Config=config.ib2 --Ice.PrintAdapterReady %s' % (Util ib2.expect('.* ready') ib3 = Util.spawn('%s --Ice.Config=config.ib3 --Ice.PrintAdapterReady %s' % (Util.getIceBox(), a3)) ib3.expect('.* ready') -print "ok" +print("ok") ib3.expect('Election: node 2: reporting for duty in group 2:[-0-9A-Fa-f]+ as coordinator' , timeout=20) ib2.expect('Election: node 1: reporting for duty in group 2:[-0-9A-Fa-f]+ with coordinator 2', timeout=20) ib1.expect('Election: node 0: reporting for duty in group 2:[-0-9A-Fa-f]+ with coordinator 2', timeout=20) -print "testing pub/sub...", +sys.stdout.write("testing pub/sub... ") sys.stdout.flush() sub = Util.spawn('./subscriber --Ice.PrintAdapterReady') @@ -69,9 +69,9 @@ pub = Util.spawn('./publisher') time.sleep(3) sub.expect('[0-9][0-9]/[0-9][0-9].*\n[0-9][0-9]/[0-9][0-9]') -print "ok" +print("ok") -print "shutting down...", +sys.stdout.write("shutting down... ") sys.stdout.flush() sub.kill(signal.SIGINT) sub.waitTestSuccess() @@ -88,4 +88,8 @@ admin = Util.spawn(Util.getIceBoxAdmin() + ' --Ice.Config=config.ib2 shutdown') admin.waitTestSuccess() admin = Util.spawn(Util.getIceBoxAdmin() + ' --Ice.Config=config.ib3 shutdown') admin.waitTestSuccess() -print "ok" + +ib1.waitTestSuccess() +ib2.waitTestSuccess() +ib3.waitTestSuccess() +print("ok") diff --git a/cpp/demo/IceUtil/workqueue/expect.py b/cpp/demo/IceUtil/workqueue/expect.py index a5d7d080eed..558b105a8ed 100755 --- a/cpp/demo/IceUtil/workqueue/expect.py +++ b/cpp/demo/IceUtil/workqueue/expect.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./workqueue') server.expect('Pushing work items') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() server.expect('work item: item1') server.expect('work item: item2') @@ -32,4 +32,4 @@ server.expect('work item: item3') server.expect('work item: item4') server.expect('work item: item5') server.waitTestSuccess(timeout=10) -print "ok" +print("ok") diff --git a/cpp/demo/book/evictor_filesystem/Grammar.cpp b/cpp/demo/book/evictor_filesystem/Grammar.cpp index 2104fad405b..e6a9689518e 100644 --- a/cpp/demo/book/evictor_filesystem/Grammar.cpp +++ b/cpp/demo/book/evictor_filesystem/Grammar.cpp @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,49 +54,20 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - - +/* Push parsers. */ +#define YYPUSH 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_HELP = 258, - TOK_EXIT = 259, - TOK_STRING = 260, - TOK_LIST = 261, - TOK_LIST_RECURSIVE = 262, - TOK_CREATE_FILE = 263, - TOK_CREATE_DIR = 264, - TOK_PWD = 265, - TOK_CD = 266, - TOK_CAT = 267, - TOK_WRITE = 268, - TOK_RM = 269 - }; -#endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_STRING 260 -#define TOK_LIST 261 -#define TOK_LIST_RECURSIVE 262 -#define TOK_CREATE_FILE 263 -#define TOK_CREATE_DIR 264 -#define TOK_PWD 265 -#define TOK_CD 266 -#define TOK_CAT 267 -#define TOK_WRITE 268 -#define TOK_RM 269 +/* Pull parsers. */ +#define YYPULL 1 +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "Grammar.y" @@ -130,6 +100,9 @@ yyerror(const char* s) +/* Line 189 of yacc.c */ +#line 105 "Grammar.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -148,20 +121,43 @@ yyerror(const char* s) # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_STRING = 260, + TOK_LIST = 261, + TOK_LIST_RECURSIVE = 262, + TOK_CREATE_FILE = 263, + TOK_CREATE_DIR = 264, + TOK_PWD = 265, + TOK_CD = 266, + TOK_CAT = 267, + TOK_WRITE = 268, + TOK_RM = 269 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 165 "Grammar.tab.c" +/* Line 264 of yacc.c */ +#line 161 "Grammar.tab.c" #ifdef short # undef short @@ -236,14 +232,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -324,9 +320,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -360,12 +356,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -740,17 +736,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -784,11 +783,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1068,10 +1067,8 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1090,10 +1087,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1117,74 +1113,75 @@ yyparse () #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. + /* Number of syntax errors so far. */ + int yynerrs; - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1214,7 +1211,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1222,7 +1218,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1245,9 +1240,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1258,7 +1252,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1268,6 +1261,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1276,16 +1272,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1317,20 +1313,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1370,30 +1362,40 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 53 "Grammar.y" { ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 56 "Grammar.y" { ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 64 "Grammar.y" { ;} break; case 5: + +/* Line 1455 of yacc.c */ #line 67 "Grammar.y" { ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 75 "Grammar.y" { parser->usage(); @@ -1401,6 +1403,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 79 "Grammar.y" { return 0; @@ -1408,6 +1412,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 83 "Grammar.y" { parser->list(false); @@ -1415,6 +1421,8 @@ yyreduce: break; case 9: + +/* Line 1455 of yacc.c */ #line 87 "Grammar.y" { parser->list(true); @@ -1422,6 +1430,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 91 "Grammar.y" { parser->createFile((yyvsp[(2) - (2)])); @@ -1429,6 +1439,8 @@ yyreduce: break; case 11: + +/* Line 1455 of yacc.c */ #line 95 "Grammar.y" { parser->createDir((yyvsp[(2) - (2)])); @@ -1436,6 +1448,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 99 "Grammar.y" { parser->pwd(); @@ -1443,6 +1457,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 103 "Grammar.y" { parser->cd("/"); @@ -1450,6 +1466,8 @@ yyreduce: break; case 14: + +/* Line 1455 of yacc.c */ #line 107 "Grammar.y" { parser->cd((yyvsp[(2) - (2)]).front()); @@ -1457,6 +1475,8 @@ yyreduce: break; case 15: + +/* Line 1455 of yacc.c */ #line 111 "Grammar.y" { parser->cat((yyvsp[(2) - (2)]).front()); @@ -1464,6 +1484,8 @@ yyreduce: break; case 16: + +/* Line 1455 of yacc.c */ #line 115 "Grammar.y" { parser->write((yyvsp[(2) - (2)])); @@ -1471,6 +1493,8 @@ yyreduce: break; case 17: + +/* Line 1455 of yacc.c */ #line 119 "Grammar.y" { parser->destroy((yyvsp[(2) - (2)])); @@ -1478,6 +1502,8 @@ yyreduce: break; case 18: + +/* Line 1455 of yacc.c */ #line 123 "Grammar.y" { parser->usage(); @@ -1486,12 +1512,16 @@ yyreduce: break; case 19: + +/* Line 1455 of yacc.c */ #line 128 "Grammar.y" { ;} break; case 20: + +/* Line 1455 of yacc.c */ #line 136 "Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); @@ -1500,6 +1530,8 @@ yyreduce: break; case 21: + +/* Line 1455 of yacc.c */ #line 141 "Grammar.y" { (yyval) = (yyvsp[(1) - (1)]); @@ -1507,8 +1539,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1512 "Grammar.tab.c" + +/* Line 1455 of yacc.c */ +#line 1545 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1519,7 +1552,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1584,7 +1616,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1601,7 +1633,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1658,9 +1690,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1685,7 +1714,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1696,7 +1725,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -1722,6 +1751,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 146 "Grammar.y" diff --git a/cpp/demo/book/evictor_filesystem/Grammar.h b/cpp/demo/book/evictor_filesystem/Grammar.h index b5b8e41ade4..ca5a99150f6 100644 --- a/cpp/demo/book/evictor_filesystem/Grammar.h +++ b/cpp/demo/book/evictor_filesystem/Grammar.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -53,29 +53,16 @@ TOK_RM = 269 }; #endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_STRING 260 -#define TOK_LIST 261 -#define TOK_LIST_RECURSIVE 262 -#define TOK_CREATE_FILE 263 -#define TOK_CREATE_DIR 264 -#define TOK_PWD 265 -#define TOK_CD 266 -#define TOK_CAT 267 -#define TOK_WRITE 268 -#define TOK_RM 269 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/cpp/demo/book/evictor_filesystem/expect.py b/cpp/demo/book/evictor_filesystem/expect.py index 19d2ab5e4b7..1b01a6bbbe5 100755 --- a/cpp/demo/book/evictor_filesystem/expect.py +++ b/cpp/demo/book/evictor_filesystem/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import evictor_filesystem -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') diff --git a/cpp/demo/book/lifecycle/Grammar.cpp b/cpp/demo/book/lifecycle/Grammar.cpp index 2104fad405b..e6a9689518e 100644 --- a/cpp/demo/book/lifecycle/Grammar.cpp +++ b/cpp/demo/book/lifecycle/Grammar.cpp @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,7 +28,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -47,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -55,49 +54,20 @@ /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - - +/* Push parsers. */ +#define YYPUSH 0 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_HELP = 258, - TOK_EXIT = 259, - TOK_STRING = 260, - TOK_LIST = 261, - TOK_LIST_RECURSIVE = 262, - TOK_CREATE_FILE = 263, - TOK_CREATE_DIR = 264, - TOK_PWD = 265, - TOK_CD = 266, - TOK_CAT = 267, - TOK_WRITE = 268, - TOK_RM = 269 - }; -#endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_STRING 260 -#define TOK_LIST 261 -#define TOK_LIST_RECURSIVE 262 -#define TOK_CREATE_FILE 263 -#define TOK_CREATE_DIR 264 -#define TOK_PWD 265 -#define TOK_CD 266 -#define TOK_CAT 267 -#define TOK_WRITE 268 -#define TOK_RM 269 +/* Pull parsers. */ +#define YYPULL 1 +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "Grammar.y" @@ -130,6 +100,9 @@ yyerror(const char* s) +/* Line 189 of yacc.c */ +#line 105 "Grammar.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -148,20 +121,43 @@ yyerror(const char* s) # define YYTOKEN_TABLE 0 #endif + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_HELP = 258, + TOK_EXIT = 259, + TOK_STRING = 260, + TOK_LIST = 261, + TOK_LIST_RECURSIVE = 262, + TOK_CREATE_FILE = 263, + TOK_CREATE_DIR = 264, + TOK_PWD = 265, + TOK_CD = 266, + TOK_CAT = 267, + TOK_WRITE = 268, + TOK_RM = 269 + }; +#endif + + + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 216 of yacc.c. */ -#line 165 "Grammar.tab.c" +/* Line 264 of yacc.c */ +#line 161 "Grammar.tab.c" #ifdef short # undef short @@ -236,14 +232,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int i) +YYID (int yyi) #else static int -YYID (i) - int i; +YYID (yyi) + int yyi; #endif { - return i; + return yyi; } #endif @@ -324,9 +320,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -360,12 +356,12 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ @@ -740,17 +736,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - yytype_int16 *bottom; - yytype_int16 *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -784,11 +783,11 @@ yy_reduce_print (yyvsp, yyrule) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - fprintf (stderr, " $%d = ", yyi + 1); + YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); - fprintf (stderr, "\n"); + YYFPRINTF (stderr, "\n"); } } @@ -1068,10 +1067,8 @@ yydestruct (yymsg, yytype, yyvaluep) break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -1090,10 +1087,9 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1117,74 +1113,75 @@ yyparse () #endif #endif { - /* The look-ahead symbol. */ +/* The lookahead symbol. */ int yychar; -/* The semantic value of the look-ahead symbol. */ +/* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; - - int yystate; - int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Look-ahead token as an internal (translated) token number. */ - int yytoken = 0; -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. + /* Number of syntax errors so far. */ + int yynerrs; - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss = yyssa; - yytype_int16 *yyssp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - YYSTYPE *yyvsp; + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -1214,7 +1211,6 @@ int yynerrs; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -1222,7 +1218,6 @@ int yynerrs; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -1245,9 +1240,8 @@ int yynerrs; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -1258,7 +1252,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -1268,6 +1261,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -1276,16 +1272,16 @@ int yynerrs; yybackup: /* Do appropriate processing given the current state. Read a - look-ahead token if we need one and don't already have one. */ + lookahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to look-ahead token. */ + /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a look-ahead token if don't already have one. */ + /* Not known => get a lookahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -1317,20 +1313,16 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the look-ahead token. */ + /* Shift the lookahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; + /* Discard the shifted token. */ + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -1370,30 +1362,40 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 53 "Grammar.y" { ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 56 "Grammar.y" { ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 64 "Grammar.y" { ;} break; case 5: + +/* Line 1455 of yacc.c */ #line 67 "Grammar.y" { ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 75 "Grammar.y" { parser->usage(); @@ -1401,6 +1403,8 @@ yyreduce: break; case 7: + +/* Line 1455 of yacc.c */ #line 79 "Grammar.y" { return 0; @@ -1408,6 +1412,8 @@ yyreduce: break; case 8: + +/* Line 1455 of yacc.c */ #line 83 "Grammar.y" { parser->list(false); @@ -1415,6 +1421,8 @@ yyreduce: break; case 9: + +/* Line 1455 of yacc.c */ #line 87 "Grammar.y" { parser->list(true); @@ -1422,6 +1430,8 @@ yyreduce: break; case 10: + +/* Line 1455 of yacc.c */ #line 91 "Grammar.y" { parser->createFile((yyvsp[(2) - (2)])); @@ -1429,6 +1439,8 @@ yyreduce: break; case 11: + +/* Line 1455 of yacc.c */ #line 95 "Grammar.y" { parser->createDir((yyvsp[(2) - (2)])); @@ -1436,6 +1448,8 @@ yyreduce: break; case 12: + +/* Line 1455 of yacc.c */ #line 99 "Grammar.y" { parser->pwd(); @@ -1443,6 +1457,8 @@ yyreduce: break; case 13: + +/* Line 1455 of yacc.c */ #line 103 "Grammar.y" { parser->cd("/"); @@ -1450,6 +1466,8 @@ yyreduce: break; case 14: + +/* Line 1455 of yacc.c */ #line 107 "Grammar.y" { parser->cd((yyvsp[(2) - (2)]).front()); @@ -1457,6 +1475,8 @@ yyreduce: break; case 15: + +/* Line 1455 of yacc.c */ #line 111 "Grammar.y" { parser->cat((yyvsp[(2) - (2)]).front()); @@ -1464,6 +1484,8 @@ yyreduce: break; case 16: + +/* Line 1455 of yacc.c */ #line 115 "Grammar.y" { parser->write((yyvsp[(2) - (2)])); @@ -1471,6 +1493,8 @@ yyreduce: break; case 17: + +/* Line 1455 of yacc.c */ #line 119 "Grammar.y" { parser->destroy((yyvsp[(2) - (2)])); @@ -1478,6 +1502,8 @@ yyreduce: break; case 18: + +/* Line 1455 of yacc.c */ #line 123 "Grammar.y" { parser->usage(); @@ -1486,12 +1512,16 @@ yyreduce: break; case 19: + +/* Line 1455 of yacc.c */ #line 128 "Grammar.y" { ;} break; case 20: + +/* Line 1455 of yacc.c */ #line 136 "Grammar.y" { (yyval) = (yyvsp[(2) - (2)]); @@ -1500,6 +1530,8 @@ yyreduce: break; case 21: + +/* Line 1455 of yacc.c */ #line 141 "Grammar.y" { (yyval) = (yyvsp[(1) - (1)]); @@ -1507,8 +1539,9 @@ yyreduce: break; -/* Line 1267 of yacc.c. */ -#line 1512 "Grammar.tab.c" + +/* Line 1455 of yacc.c */ +#line 1545 "Grammar.tab.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -1519,7 +1552,6 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1584,7 +1616,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse look-ahead token after an + /* If just tried and failed to reuse lookahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -1601,7 +1633,7 @@ yyerrlab: } } - /* Else will try to reuse look-ahead token after shifting the error + /* Else will try to reuse lookahead token after shifting the error token. */ goto yyerrlab1; @@ -1658,9 +1690,6 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - *++yyvsp = yylval; @@ -1685,7 +1714,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow +#if !defined(yyoverflow) || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -1696,7 +1725,7 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEOF && yychar != YYEMPTY) + if (yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered @@ -1722,6 +1751,8 @@ yyreturn: } + +/* Line 1675 of yacc.c */ #line 146 "Grammar.y" diff --git a/cpp/demo/book/lifecycle/Grammar.h b/cpp/demo/book/lifecycle/Grammar.h index b5b8e41ade4..ca5a99150f6 100644 --- a/cpp/demo/book/lifecycle/Grammar.h +++ b/cpp/demo/book/lifecycle/Grammar.h @@ -1,24 +1,23 @@ -/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -29,10 +28,11 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -53,29 +53,16 @@ TOK_RM = 269 }; #endif -/* Tokens. */ -#define TOK_HELP 258 -#define TOK_EXIT 259 -#define TOK_STRING 260 -#define TOK_LIST 261 -#define TOK_LIST_RECURSIVE 262 -#define TOK_CREATE_FILE 263 -#define TOK_CREATE_DIR 264 -#define TOK_PWD 265 -#define TOK_CD 266 -#define TOK_CAT 267 -#define TOK_WRITE 268 -#define TOK_RM 269 - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif + diff --git a/cpp/demo/book/lifecycle/expect.py b/cpp/demo/book/lifecycle/expect.py index 5993eeb23b6..fc5bdb408f3 100755 --- a/cpp/demo/book/lifecycle/expect.py +++ b/cpp/demo/book/lifecycle/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import lifecycle server = Util.spawn('./server --Ice.PrintAdapterReady') diff --git a/cpp/demo/book/map_filesystem/expect.py b/cpp/demo/book/map_filesystem/expect.py index 9d1609ad4ce..59cdb7ce2d2 100755 --- a/cpp/demo/book/map_filesystem/expect.py +++ b/cpp/demo/book/map_filesystem/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import map_filesystem -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') diff --git a/cpp/demo/book/printer/expect.py b/cpp/demo/book/printer/expect.py index 54cef43522f..12670c9d14f 100755 --- a/cpp/demo/book/printer/expect.py +++ b/cpp/demo/book/printer/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('./client') client.waitTestSuccess() server.expect('Hello World!') server.kill(signal.SIGTERM) server.waitTestSuccess(-signal.SIGTERM) -print "ok" +print("ok") diff --git a/cpp/demo/book/simple_filesystem/expect.py b/cpp/demo/book/simple_filesystem/expect.py index 07f8c64905d..a2a9e91955d 100755 --- a/cpp/demo/book/simple_filesystem/expect.py +++ b/cpp/demo/book/simple_filesystem/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * - -import signal +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('./client') client.expect('Contents of root directory:\n.*Down to a sunless sea.') client.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp index 7b62ef2970a..899b859a423 100755 --- a/cpp/src/Slice/PythonUtil.cpp +++ b/cpp/src/Slice/PythonUtil.cpp @@ -240,7 +240,7 @@ getDictLookup(const ContainedPtr& cont, const string& suffix = string()) scope = package + "." + scope; } - return "_M_" + scope + "__dict__.has_key('" + suffix + Slice::Python::fixIdent(cont->name()) + "')"; + return "'" + suffix + Slice::Python::fixIdent(cont->name()) + "' not in _M_" + scope + "__dict__"; } // @@ -383,7 +383,7 @@ Slice::Python::CodeVisitor::visitClassDecl(const ClassDeclPtr& p) string scoped = p->scoped(); if(_classHistory.count(scoped) == 0) { - _out << sp << nl << "if not " << getDictLookup(p) << ':'; + _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); string type = getAbsolute(p, "_t_"); _out << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')"; @@ -415,7 +415,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) // // Define the class. // - _out << sp << nl << "if not " << getDictLookup(p) << ':'; + _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); _out << nl << "_M_" << abs << " = Ice.createTempClass()"; _out << nl << "class " << name << '('; @@ -472,7 +472,7 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p) { if(isAbstract) { - _out << nl << "if __builtin__.type(self) == _M_" << abs << ':'; + _out << nl << "if Ice.getType(self) == _M_" << abs << ':'; _out.inc(); _out << nl << "raise RuntimeError('" << abs << " is an abstract class')"; _out.dec(); @@ -1001,7 +1001,7 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p) string abs = getAbsolute(p); string name = fixIdent(p->name()); - _out << sp << nl << "if not " << getDictLookup(p) << ':'; + _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); _out << nl << "_M_" << abs << " = Ice.createTempClass()"; _out << nl << "class " << name << '('; @@ -1164,7 +1164,7 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p) } } - _out << sp << nl << "if not " << getDictLookup(p) << ':'; + _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); _out << nl << "_M_" << abs << " = Ice.createTempClass()"; _out << nl << "class " << name << "(object):"; @@ -1342,7 +1342,7 @@ Slice::Python::CodeVisitor::visitSequence(const SequencePtr& p) // Emit the type information. // string scoped = p->scoped(); - _out << sp << nl << "if not " << getDictLookup(p, "_t_") << ':'; + _out << sp << nl << "if " << getDictLookup(p, "_t_") << ':'; _out.inc(); if(isCustom) { @@ -1369,7 +1369,7 @@ Slice::Python::CodeVisitor::visitDictionary(const DictionaryPtr& p) // Emit the type information. // string scoped = p->scoped(); - _out << sp << nl << "if not " << getDictLookup(p, "_t_") << ':'; + _out << sp << nl << "if " << getDictLookup(p, "_t_") << ':'; _out.inc(); _out << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineDictionary('" << scoped << "', "; writeMetaData(p->getMetaData()); @@ -1391,7 +1391,7 @@ Slice::Python::CodeVisitor::visitEnum(const EnumPtr& p) EnumeratorList::iterator q; int i; - _out << sp << nl << "if not " << getDictLookup(p) << ':'; + _out << sp << nl << "if " << getDictLookup(p) << ':'; _out.inc(); _out << nl << "_M_" << abs << " = Ice.createTempClass()"; _out << nl << "class " << name << "(object):"; @@ -1716,7 +1716,7 @@ Slice::Python::CodeVisitor::writeHash(const string& name, const TypePtr& p, int& return; } - _out << nl << "_h = 5 * _h + __builtin__.hash(" << name << ")"; + _out << nl << "_h = 5 * _h + Ice.getHash(" << name << ")"; } void @@ -2208,7 +2208,7 @@ Slice::Python::generate(const UnitPtr& un, bool all, bool checksum, const vector Slice::Python::MetaDataVisitor visitor; un->visit(&visitor, false); - out << nl << "import Ice, IcePy, __builtin__"; + out << nl << "import Ice, IcePy"; if(!all) { diff --git a/cpp/test/Freeze/complex/Grammar.cpp b/cpp/test/Freeze/complex/Grammar.cpp index ba6b0d6bee4..b77c4a3fe56 100644 --- a/cpp/test/Freeze/complex/Grammar.cpp +++ b/cpp/test/Freeze/complex/Grammar.cpp @@ -1,30 +1,39 @@ -/* A Bison parser, made by GNU Bison 1.875c. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +/* A Bison parser, made by GNU Bison 2.4.1. */ - This program is free software; you can redistribute it and/or modify +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -36,32 +45,29 @@ /* Identify Bison output. */ #define YYBISON 1 +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 - +/* Push parsers. */ +#define YYPUSH 0 +/* Pull parsers. */ +#define YYPULL 1 -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOK_NUMBER = 258 - }; -#endif -#define TOK_NUMBER 258 - +/* Using locations. */ +#define YYLSP_NEEDED 0 /* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ #line 1 "Grammar.y" @@ -96,6 +102,9 @@ yyerror(const char* s) +/* Line 189 of yacc.c */ +#line 107 "Grammar.tab.c" + /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -109,70 +118,202 @@ yyerror(const char* s) # define YYERROR_VERBOSE 0 #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_NUMBER = 258 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - /* Copy the second part of user declarations. */ -/* Line 214 of yacc.c. */ -#line 126 "Grammar.tab.c" +/* Line 264 of yacc.c */ +#line 152 "Grammar.tab.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif -#if ! defined (yyoverflow) || YYERROR_VERBOSE +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif -# ifndef YYFREE -# define YYFREE free +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int # endif -# ifndef YYMALLOC -# define YYMALLOC malloc +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid # endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# endif -# else -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include <alloca.h> /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include <malloc.h> /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif +# else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short yyss; - YYSTYPE yyvs; - }; + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -180,24 +321,24 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ - register YYSIZE_T yyi; \ + YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -206,48 +347,42 @@ union yyalloc elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack) \ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ do \ { \ YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 6 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 11 -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 8 -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS 3 -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES 6 -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 12 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 258 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -280,28 +415,28 @@ static const unsigned char yytranslate[] = #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned char yyprhs[] = +static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 7, 11, 15 }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yysigned_char yyrhs[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = { 9, 0, -1, 10, -1, 3, -1, 10, 4, 10, -1, 5, 10, 6, -1, 10, 7, 10, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned char yyrline[] = +static const yytype_uint8 yyrline[] = { 0, 42, 42, 49, 53, 57, 61 }; #endif -#if YYDEBUG || YYERROR_VERBOSE -/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "TOK_NUMBER", "'+'", "'('", "')'", "'*'", @@ -312,20 +447,20 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 43, 40, 41, 42 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = +static const yytype_uint8 yyr1[] = { 0, 8, 9, 10, 10, 10, 10 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = +static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 3, 3, 3 }; @@ -333,14 +468,14 @@ static const unsigned char yyr2[] = /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const unsigned char yydefact[] = +static const yytype_uint8 yydefact[] = { 0, 3, 0, 0, 2, 0, 1, 0, 0, 5, 4, 6 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const yysigned_char yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = { -1, 3, 4 }; @@ -348,14 +483,14 @@ static const yysigned_char yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -4 -static const yysigned_char yypact[] = +static const yytype_int8 yypact[] = { 6, -4, 6, 2, 3, -3, -4, 6, 6, -4, 3, 3 }; /* YYPGOTO[NTERM-NUM]. */ -static const yysigned_char yypgoto[] = +static const yytype_int8 yypgoto[] = { -4, -4, -2 }; @@ -365,13 +500,13 @@ static const yysigned_char yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 -static const unsigned char yytable[] = +static const yytype_uint8 yytable[] = { 5, 7, 6, 9, 8, 10, 11, 7, 0, 1, 8, 2 }; -static const yysigned_char yycheck[] = +static const yytype_int8 yycheck[] = { 2, 4, 0, 6, 7, 7, 8, 4, -1, 3, 7, 5 @@ -379,28 +514,12 @@ static const yysigned_char yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const unsigned char yystos[] = +static const yytype_uint8 yystos[] = { 0, 3, 5, 9, 10, 10, 0, 4, 7, 6, 10, 10 }; -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) @@ -426,30 +545,63 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ - { \ - yyerror ("syntax error: cannot back up");\ + { \ + yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) + #define YYTERROR 1 #define YYERRCODE 256 -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). */ +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - ((Current).first_line = (Rhs)[1].first_line, \ - (Current).first_column = (Rhs)[1].first_column, \ - (Current).last_line = (Rhs)[N].last_line, \ - (Current).last_column = (Rhs)[N].last_column) +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) #endif + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM @@ -470,43 +622,100 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YYDSYMPRINT(Args) \ -do { \ - if (yydebug) \ - yysymprint Args; \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) -# define YYDSYMPRINTF(Title, Token, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Token, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (short *bottom, short *top) +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) #else static void -yy_stack_print (bottom, top) - short *bottom; - short *top; +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; #endif { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) - YYFPRINTF (stderr, " %d", *bottom); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } YYFPRINTF (stderr, "\n"); } @@ -514,45 +723,52 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void -yy_reduce_print (yyrule) +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; int yyrule; #endif { + int yynrhs = yyr2[yyrule]; int yyi; - unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) -# define YYDSYMPRINT(Args) -# define YYDSYMPRINTF(Title, Token, Value, Location) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ @@ -567,13 +783,9 @@ int yydebug; if the built-in stack extension method is used). Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ -#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif @@ -583,45 +795,47 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else +#else +static YYSIZE_T yystrlen (yystr) - const char *yystr; -# endif + const char *yystr; +#endif { - register const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else +#else +static char * yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif + char *yydest; + const char *yysrc; +#endif { - register char *yyd = yydest; - register const char *yys = yysrc; + char *yyd = yydest; + const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; @@ -631,84 +845,204 @@ yystpcpy (yydest, yysrc) # endif # endif -#endif /* !YYERROR_VERBOSE */ +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } - + if (! yyres) + return yystrlen (yystr); -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ + return yystpcpy (yyres, yystr) - yyres; +} +# endif -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + int yyn = yypact[yystate]; - if (yytype < YYNTOKENS) - { - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); -# ifdef YYPRINT - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - } + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - switch (yytype) { - default: - break; + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - YYFPRINTF (yyoutput, ")"); } +#endif /* YYERROR_VERBOSE */ + -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yydestruct (int yytype, YYSTYPE *yyvaluep) +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void -yydestruct (yytype, yyvaluep) +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: - break; + break; } } - /* Prevent warnings from -Wmissing-prototypes. */ - #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); -# else +#else int yyparse (); -# endif +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); @@ -719,20 +1053,23 @@ int yyparse (); - -/*----------. -| yyparse. | -`----------*/ +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else @@ -742,68 +1079,75 @@ yyparse () #endif #endif { - /* The lookahead symbol. */ +/* The lookahead symbol. */ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; -/* Number of syntax errors so far. */ -int yynerrs; + /* Number of syntax errors so far. */ + int yynerrs; - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yytoken = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; -#define YYPOPSTACK (yyvsp--, yyssp--) + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; - YYSIZE_T yystacksize = YYINITDEPTH; + YYSIZE_T yystacksize; + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ - yyssp = yyss; yyvsp = yyvs; @@ -814,8 +1158,7 @@ int yynerrs; `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -828,21 +1171,19 @@ int yynerrs; #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - + yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", + yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); yyss = yyss1; @@ -850,24 +1191,23 @@ int yynerrs; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE - goto yyoverflowlab; + goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyoverflowlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { - short *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); - + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -878,7 +1218,6 @@ int yynerrs; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; - YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -888,6 +1227,9 @@ int yynerrs; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + if (yystate == YYFINAL) + YYACCEPT; + goto yybackup; /*-----------. @@ -895,12 +1237,10 @@ int yynerrs; `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; @@ -922,7 +1262,7 @@ yybackup: else { yytoken = YYTRANSLATE (yychar); - YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -939,25 +1279,20 @@ yybackup: goto yyreduce; } - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; - - /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + yystate = yyn; + *++yyvsp = yylval; + goto yynewstate; @@ -993,55 +1328,64 @@ yyreduce: switch (yyn) { case 2: + +/* Line 1455 of yacc.c */ #line 43 "Grammar.y" { - parser->setResult(yyval); + parser->setResult((yyval)); ;} break; case 3: + +/* Line 1455 of yacc.c */ #line 50 "Grammar.y" { - yyval = yyvsp[0]; + (yyval) = (yyvsp[(1) - (1)]); ;} break; case 4: + +/* Line 1455 of yacc.c */ #line 54 "Grammar.y" { - yyval = new Complex::AddNodeI(yyvsp[-2], yyvsp[0]); + (yyval) = new Complex::AddNodeI((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} break; case 5: + +/* Line 1455 of yacc.c */ #line 58 "Grammar.y" { - yyval = yyvsp[-1]; + (yyval) = (yyvsp[(2) - (3)]); ;} break; case 6: + +/* Line 1455 of yacc.c */ #line 62 "Grammar.y" { - yyval = new Complex::MultiplyNodeI(yyvsp[-2], yyvsp[0]); + (yyval) = new Complex::MultiplyNodeI((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); ;} break; - } - -/* Line 1000 of yacc.c. */ -#line 1035 "Grammar.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; +/* Line 1455 of yacc.c */ +#line 1379 "Grammar.tab.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -1065,66 +1409,41 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - int yytype = YYTRANSLATE (yychar); - const char* yyprefix; - char *yymsg; - int yyx; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 0; - - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { - yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); - yycount += 1; - if (yycount == 5) - { - yysize = 0; - break; - } + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; } - yysize += (sizeof ("syntax error, unexpected ") - + yystrlen (yytname[yytype])); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); - yyp = yystpcpy (yyp, yytname[yytype]); - - if (yycount < 5) - { - yyprefix = ", expecting "; - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - yyp = yystpcpy (yyp, yyprefix); - yyp = yystpcpy (yyp, yytname[yyx]); - yyprefix = " or "; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("syntax error; also virtual memory exhausted"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror ("syntax error"); + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif } @@ -1135,25 +1454,16 @@ yyerrlab: error, discard it. */ if (yychar <= YYEOF) - { - /* If at end of input, pop the error token, - then the rest of the stack, then return failure. */ + { + /* Return failure if at end of input. */ if (yychar == YYEOF) - for (;;) - { - YYPOPSTACK; - if (yyssp == yyss) - YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[*yyssp], yyvsp); - } - } + YYABORT; + } else { - YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); - yydestruct (yytoken, &yylval); + yydestruct ("Error: discarding", + yytoken, &yylval); yychar = YYEMPTY; - } } @@ -1167,15 +1477,17 @@ yyerrlab: `---------------------------------------------------*/ yyerrorlab: -#ifdef __GNUC__ - /* Pacify GCC when the user code never invokes YYERROR and the label - yyerrorlab therefore never appears in user code. */ - if (0) + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) goto yyerrorlab; -#endif - yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -1204,21 +1516,20 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); - yydestruct (yystos[yystate], yyvsp); - YYPOPSTACK; + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - *++yyvsp = yylval; + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + yystate = yyn; goto yynewstate; @@ -1237,25 +1548,45 @@ yyabortlab: yyresult = 1; goto yyreturn; -#ifndef yyoverflow -/*----------------------------------------------. -| yyoverflowlab -- parser overflow comes here. | -`----------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); } + +/* Line 1675 of yacc.c */ #line 67 "Grammar.y" diff --git a/cpp/test/Freeze/complex/Grammar.h b/cpp/test/Freeze/complex/Grammar.h index ff8b73a45bb..b7f7c2131d8 100644 --- a/cpp/test/Freeze/complex/Grammar.h +++ b/cpp/test/Freeze/complex/Grammar.h @@ -1,27 +1,37 @@ -/* A Bison parser, made by GNU Bison 1.875c. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +/* A Bison parser, made by GNU Bison 2.4.1. */ - This program is free software; you can redistribute it and/or modify +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE @@ -32,19 +42,16 @@ TOK_NUMBER = 258 }; #endif -#define TOK_NUMBER 258 - -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 #endif - diff --git a/cpp/test/Freeze/complex/run.py b/cpp/test/Freeze/complex/run.py index deae63146e1..86316dce547 100755 --- a/cpp/test/Freeze/complex/run.py +++ b/cpp/test/Freeze/complex/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.path.dirname(os.path.abspath(__file__)) @@ -33,15 +33,17 @@ client = os.path.join(os.getcwd(), "client") if TestUtil.appverifier: TestUtil.setAppVerifierSettings([client]) -print "starting populate...", +sys.stdout.write("starting populate... ") +sys.stdout.flush() populateProc = TestUtil.startClient(client, ' --dbdir "%s" populate' % os.getcwd(), startReader = False) -print "ok" +print("ok") populateProc.startReader() populateProc.waitTestSuccess() -print "starting verification client...", +sys.stdout.write("starting verification client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, ' --dbdir "%s" validate' % os.getcwd(), startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/cpp/test/Freeze/dbmap/run.py b/cpp/test/Freeze/dbmap/run.py index f1809a84d4d..89ea23b3d22 100755 --- a/cpp/test/Freeze/dbmap/run.py +++ b/cpp/test/Freeze/dbmap/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) diff --git a/cpp/test/Freeze/evictor/run.py b/cpp/test/Freeze/evictor/run.py index abac1bca7f4..b4b226b2727 100755 --- a/cpp/test/Freeze/evictor/run.py +++ b/cpp/test/Freeze/evictor/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) @@ -26,4 +26,3 @@ TestUtil.cleanDbDir(dbdir) testOptions = ' --Freeze.DbEnv.db.DbHome="%s" --Ice.Config="%s"' % (dbdir, os.path.join(os.getcwd(), "config")) TestUtil.clientServerTest(additionalServerOptions= testOptions, additionalClientOptions= testOptions) - diff --git a/cpp/test/Freeze/fileLock/run.py b/cpp/test/Freeze/fileLock/run.py index 423aa1e2987..621efd35f3d 100755 --- a/cpp/test/Freeze/fileLock/run.py +++ b/cpp/test/Freeze/fileLock/run.py @@ -16,11 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "testing Freeze file lock...", +sys.stdout.write("testing Freeze file lock... ") sys.stdout.flush() client = os.path.join(os.getcwd(), "client") @@ -46,4 +46,4 @@ clientExe.sendline('go') clientExe.expect('File lock released.') clientExe.waitTestSuccess() -print "ok" +print("ok") diff --git a/cpp/test/FreezeScript/dbmap/run.py b/cpp/test/FreezeScript/dbmap/run.py index 4cee776f276..da971d3385c 100755 --- a/cpp/test/FreezeScript/dbmap/run.py +++ b/cpp/test/FreezeScript/dbmap/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * - + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil transformdb = '%s' % os.path.join(TestUtil.getCppBinDir(), "transformdb") @@ -52,10 +51,10 @@ for file in os.listdir(os.path.join(os.getcwd(), "fail")): regex2 = re.compile(r"^.*transf(ormdb|~1)(\.exe)?", re.IGNORECASE) -print "testing error detection...", +sys.stdout.write("testing error detection... ") sys.stdout.flush() if TestUtil.debug: - print + sys.stdout.write("\n") files.sort() for oldfile in files: @@ -71,7 +70,7 @@ for oldfile in files: os.path.join(os.getcwd(), "fail", newfile) + '" -o tmp.xml --key string --value ' + value if TestUtil.debug: - print command + print(command) p = TestUtil.runCommand(command) (stdin, stdout, stderr) = (p.stdin, p.stdout, p.stderr) @@ -79,36 +78,40 @@ for oldfile in files: lines1 = stderr.readlines() lines2 = open(os.path.join(os.getcwd(), "fail", oldfile.replace("_old.ice", ".err")), "r").readlines() if len(lines1) != len(lines2): - print "failed! (1)" + print("failed! (1)") sys.exit(1) i = 0 while i < len(lines1): - line1 = regex2.sub("", lines1[i]).strip() - line2 = regex2.sub("", lines2[i]).strip() + if sys.version_info[0] == 2: + line1 = regex2.sub("", lines1[i]).strip() + line2 = regex2.sub("", lines2[i]).strip() + else: + line1 = regex2.sub("", lines1[i].decode("utf-8")).strip() + line2 = regex2.sub("", lines2[i]).strip() if line1 != line2: - print "failed! (2)" - print "line1 = " + line1 - print "line2 = " + line2 + print("failed! (2)") + print("line1 = " + line1) + print("line2 = " + line2) # sys.exit(1) i = i + 1 -print "ok" +print("ok") -print "creating test database...", +sys.stdout.write("creating test database... ") sys.stdout.flush() makedb = '"%s" "%s"'% (os.path.join(os.getcwd(), "makedb"), os.getcwd()) proc = TestUtil.spawn(makedb) proc.waitTestSuccess() -print "ok" +print("ok") testold = os.path.join(os.getcwd(), "TestOld.ice") testnew = os.path.join(os.getcwd(), "TestNew.ice") initxml = os.path.join(os.getcwd(), "init.xml") checkxml = os.path.join(os.getcwd(), "check.xml") -print "initializing test database...", +sys.stdout.write("initializing test database... ") sys.stdout.flush() command = '"' + transformdb + '" --old "' + testold + '" --new "' + testold + '" -f "' + initxml + '" "' + dbdir + \ @@ -116,9 +119,9 @@ command = '"' + transformdb + '" --old "' + testold + '" --new "' + testold + '" TestUtil.spawn(command).waitTestSuccess() -print "ok" +print("ok") -print "executing default transformations...", +sys.stdout.write("executing default transformations... ") sys.stdout.flush() command = '"' + transformdb + '" --old "' + testold + '" --new "' + testnew + '" --key int --value ::Test::S "' + init_dbdir + \ @@ -126,9 +129,9 @@ command = '"' + transformdb + '" --old "' + testold + '" --new "' + testnew + '" TestUtil.spawn(command).waitTestSuccess() -print "ok" +print("ok") -print "validating database...", +sys.stdout.write("validating database... ") sys.stdout.flush() command = '"' + transformdb + '" --old "' + testnew + '" --new "' + testnew + '" -f "' + checkxml + '" "' + check_dbdir + \ @@ -136,7 +139,7 @@ command = '"' + transformdb + '" --old "' + testnew + '" --new "' + testnew + '" TestUtil.spawn(command).waitTestSuccess() -print "ok" +print("ok") if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd([transformdb]) diff --git a/cpp/test/FreezeScript/evictor/run.py b/cpp/test/FreezeScript/evictor/run.py index 5f4391559dd..a197c80fec4 100755 --- a/cpp/test/FreezeScript/evictor/run.py +++ b/cpp/test/FreezeScript/evictor/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel os.getcwd()!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel os.getcwd()!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil transformdb = os.path.join(TestUtil.getCppBinDir(), "transformdb") @@ -38,36 +38,36 @@ if os.path.exists(tmp_dbdir): shutil.rmtree(tmp_dbdir) os.mkdir(tmp_dbdir) -print "creating test database...", +sys.stdout.write("creating test database... ") sys.stdout.flush() makedb = '"%s" "%s"' % (os.path.join(os.getcwd(), "makedb"), os.getcwd()) proc = TestUtil.spawn(makedb) proc.waitTestSuccess() -print "ok" +print("ok") testold = os.path.join(os.getcwd(), "TestOld.ice") testnew = os.path.join(os.getcwd(), "TestNew.ice") transformxml = os.path.join(os.getcwd(), "transform.xml") checkxml = os.path.join(os.getcwd(), "check.xml") -print "executing evictor transformations...", +sys.stdout.write("executing evictor transformations... ") sys.stdout.flush() command = '"' + transformdb + '" -e -p --old "' + testold + '" --new "' + testnew + '" -f "' + transformxml + '" "' + dbdir + \ '" evictor.db "' + check_dbdir + '" ' proc = TestUtil.spawn(command) proc.waitTestSuccess() -print "ok" +print("ok") -print "validating database...", +sys.stdout.write("validating database... ") sys.stdout.flush() command = '"' + transformdb + '" -e --old "' + testnew + '" --new "' + testnew + '" -f "' + checkxml + '" "' + check_dbdir + \ '" evictor.db "' + tmp_dbdir + '"' proc = TestUtil.spawn(command) proc.waitTestSuccess() -print "ok" +print("ok") if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd([transformdb]) diff --git a/cpp/test/Glacier2/attack/run.py b/cpp/test/Glacier2/attack/run.py index 624dc1f7e5c..8b510507d5f 100755 --- a/cpp/test/Glacier2/attack/run.py +++ b/cpp/test/Glacier2/attack/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() router = TestUtil.getGlacier2Router() @@ -32,9 +32,10 @@ args = ' --Glacier2.RoutingTable.MaxSize=10' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(testdir, "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() starterProc = TestUtil.startServer(router, args, count=2) -print "ok" +print("ok") TestUtil.clientServerTest() diff --git a/cpp/test/Glacier2/dynamicFiltering/run.py b/cpp/test/Glacier2/dynamicFiltering/run.py index 44e72842f45..69cc0cf4aac 100755 --- a/cpp/test/Glacier2/dynamicFiltering/run.py +++ b/cpp/test/Glacier2/dynamicFiltering/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") client = os.path.join(os.getcwd(), "client") @@ -30,9 +30,10 @@ if TestUtil.appverifier: TestUtil.setAppVerifierSettings(targets) -print "starting server...", +sys.stdout.write("starting server... ") +sys.stdout.flush() serverProc = TestUtil.startServer(server, count=3) -print "ok" +print("ok") args = r' --Glacier2.Client.Endpoints="default -p 12347"' + \ r' --Ice.Admin.Endpoints="tcp -p 12348"' + \ @@ -42,15 +43,15 @@ args = r' --Glacier2.Client.Endpoints="default -p 12347"' + \ r' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' + \ r' --Ice.Default.Locator="locator:default -p 12012"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() starterProc = TestUtil.startServer(router, args, count=2) -print "ok" +print("ok") - - -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() proc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") proc.startReader() proc.waitTestSuccess() diff --git a/cpp/test/Glacier2/override/run.py b/cpp/test/Glacier2/override/run.py index c531f9dec1b..cd2173e01b4 100755 --- a/cpp/test/Glacier2/override/run.py +++ b/cpp/test/Glacier2/override/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = TestUtil.getGlacier2Router() @@ -46,9 +46,10 @@ def startRouter(): ' --Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered=1' + \ ' --Glacier2.Client.SleepTime=50 --Glacier2.Server.SleepTime=50' - print "starting router in buffered mode...", + sys.stdout.write("starting router in buffered mode... ") + sys.stdout.flush() starterProc = TestUtil.startServer(router, args, count=2) - print "ok" + print("ok") return starterProc name = os.path.join("Glacier2", "override") @@ -59,4 +60,3 @@ starterProc.waitTestSuccess() if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd([router]) - diff --git a/cpp/test/Glacier2/router/run.py b/cpp/test/Glacier2/router/run.py index b8194611f80..05234c93d7c 100755 --- a/cpp/test/Glacier2/router/run.py +++ b/cpp/test/Glacier2/router/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = TestUtil.getGlacier2Router() @@ -40,14 +40,16 @@ def startRouter(buffered): if buffered: args += ' --Glacier2.Client.Buffered=1 --Glacier2.Server.Buffered=1' - print "starting router in buffered mode...", + sys.stdout.write("starting router in buffered mode... ") + sys.stdout.flush() else: args += ' --Glacier2.Client.Buffered=0 --Glacier2.Server.Buffered=0' - print "starting router in unbuffered mode...", + sys.stdout.write("starting router in unbuffered mode... ") + sys.stdout.flush() starterProc = TestUtil.startServer(router, args, count=2) - print "ok" + print("ok") return starterProc name = os.path.join("Glacier2", "router") @@ -76,4 +78,3 @@ starterProc.waitTestSuccess() if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd([router]) - diff --git a/cpp/test/Glacier2/sessionControl/run.py b/cpp/test/Glacier2/sessionControl/run.py index 500ac7668bb..f4564493786 100755 --- a/cpp/test/Glacier2/sessionControl/run.py +++ b/cpp/test/Glacier2/sessionControl/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") router = TestUtil.getGlacier2Router() @@ -29,9 +29,10 @@ if TestUtil.appverifier: targets = [server, client, router] TestUtil.setAppVerifierSettings(targets) -print "starting server...", +sys.stdout.write("starting server... ") +sys.stdout.flush() serverProc = TestUtil.startServer(server) -print "ok" +print("ok") args = ' --Glacier2.Client.Endpoints="default -p 12347"' + \ ' --Ice.Admin.Endpoints="tcp -p 12348"' + \ @@ -40,20 +41,20 @@ args = ' --Glacier2.Client.Endpoints="default -p 12347"' + \ ' --Glacier2.SessionManager="SessionManager:tcp -p 12010"' \ ' --Glacier2.PermissionsVerifier="Glacier2/NullPermissionsVerifier"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() starterProc = TestUtil.startServer(router, args, count = 2) -print "ok" - - +print("ok") # # The test may sporadically fail without this slight pause. # time.sleep(1) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() @@ -62,4 +63,3 @@ starterProc.waitTestSuccess() if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd(targets) - diff --git a/cpp/test/Glacier2/sessionHelper/run.py b/cpp/test/Glacier2/sessionHelper/run.py index 1705881b750..7284609bbda 100755 --- a/cpp/test/Glacier2/sessionHelper/run.py +++ b/cpp/test/Glacier2/sessionHelper/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = os.path.join(TestUtil.getCppBinDir(), "glacier2router") @@ -31,15 +31,13 @@ args = ' --Ice.Warn.Dispatch=0' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() routerConfig = TestUtil.DriverConfig("server") routerConfig.lang = "cpp" starterProc = TestUtil.startServer(router, args, count=2, config=routerConfig) -print "ok" - - +print("ok") TestUtil.clientServerTest(additionalClientOptions=" --shutdown") starterProc.waitTestSuccess() - diff --git a/cpp/test/Glacier2/ssl/run.py b/cpp/test/Glacier2/ssl/run.py index 72dd1ada03a..903540c602e 100755 --- a/cpp/test/Glacier2/ssl/run.py +++ b/cpp/test/Glacier2/ssl/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") client = os.path.join(os.getcwd(), "client") @@ -29,9 +29,10 @@ if TestUtil.appverifier: targets = [server, client, router] TestUtil.setAppVerifierSettings(targets) -print "starting server...", +sys.stdout.write("starting server... ") +sys.stdout.flush() serverProc = TestUtil.startServer(server) -print "ok" +print("ok") args = ' --Ice.Warn.Dispatch=0' + \ ' --Glacier2.AddSSLContext=1' + \ @@ -47,16 +48,18 @@ args = ' --Ice.Warn.Dispatch=0' + \ routerCfg = TestUtil.DriverConfig("server") routerCfg.protocol = "ssl" -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() starterProc = TestUtil.startServer(router, args, routerCfg, count = 2) -print "ok" +print("ok") clientCfg = TestUtil.DriverConfig("client") clientCfg.protocol = "ssl" -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, "", clientCfg, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/cpp/test/Glacier2/staticFiltering/run.py b/cpp/test/Glacier2/staticFiltering/run.py index ca0c7147623..e3807da41fc 100755 --- a/cpp/test/Glacier2/staticFiltering/run.py +++ b/cpp/test/Glacier2/staticFiltering/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil hostname = socket.gethostname() fqdn = socket.getfqdn() @@ -224,13 +224,13 @@ if not limitedTests: ]) if len(testcases) == 0: - print "WARNING: You are running this test with SSL disabled and the network " - print " configuration for this host does not permit the other tests " - print " to run correctly." + print("WARNING: You are running this test with SSL disabled and the network ") + print(" configuration for this host does not permit the other tests ") + print(" to run correctly.") sys.exit(0) elif len(testcases) < 6: - print "WARNING: The network configuration for this host does not permit all " - print " tests to run correctly, some tests have been disabled." + print("WARNING: The network configuration for this host does not permit all ") + print(" tests to run correctly, some tests have been disabled.") def pingProgress(): sys.stdout.write('.') @@ -244,7 +244,7 @@ for testcase in testcases: # use command line arguments to pass the test cases in, but a # configuration file is easier. # - attackcfg = file(os.path.join(os.getcwd(), 'attack.cfg'), 'w') + attackcfg = open(os.path.join(os.getcwd(), 'attack.cfg'), 'w') accepts=0 rejects=0 sys.stdout.write(description) @@ -285,7 +285,7 @@ for testcase in testcases: ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' - routerConfig = file(os.path.join(os.getcwd(), "router.cfg"), "w") + routerConfig = open(os.path.join(os.getcwd(), "router.cfg"), "w") routerConfig.write("Ice.Default.Locator=locator:tcp -h %s -p 12010\n" % hostname) routerConfig.write("Glacier2.Client.Trace.Reject=0\n") @@ -327,7 +327,7 @@ for testcase in testcases: pingProgress() if TestUtil.protocol != "ssl": - serverConfig = file(os.path.join(os.getcwd(), "server.cfg"), "w") + serverConfig = open(os.path.join(os.getcwd(), "server.cfg"), "w") serverOptions = ' --Ice.Config="' + os.path.join(os.getcwd(), "server.cfg") + '" ' serverConfig.write("BackendAdapter.Endpoints=tcp -p 12010\n") serverConfig.close() diff --git a/cpp/test/Ice/adapterDeactivation/run.py b/cpp/test/Ice/adapterDeactivation/run.py index 099ce110107..db68ff30b9a 100755 --- a/cpp/test/Ice/adapterDeactivation/run.py +++ b/cpp/test/Ice/adapterDeactivation/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/ami/run.py b/cpp/test/Ice/ami/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/ami/run.py +++ b/cpp/test/Ice/ami/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/background/run.py b/cpp/test/Ice/background/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/background/run.py +++ b/cpp/test/Ice/background/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/binding/run.py b/cpp/test/Ice/binding/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/binding/run.py +++ b/cpp/test/Ice/binding/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/checksum/run.py b/cpp/test/Ice/checksum/run.py index f6f62b28c1f..564355252bc 100755 --- a/cpp/test/Ice/checksum/run.py +++ b/cpp/test/Ice/checksum/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server", "server") TestUtil.clientServerTest(server = server) - diff --git a/cpp/test/Ice/custom/run.py b/cpp/test/Ice/custom/run.py index 43526feb98b..f1fb492a715 100755 --- a/cpp/test/Ice/custom/run.py +++ b/cpp/test/Ice/custom/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/defaultServant/run.py b/cpp/test/Ice/defaultServant/run.py index de6f75c19e5..21a39b058b8 100755 --- a/cpp/test/Ice/defaultServant/run.py +++ b/cpp/test/Ice/defaultServant/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Ice/defaultValue/run.py b/cpp/test/Ice/defaultValue/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/Ice/defaultValue/run.py +++ b/cpp/test/Ice/defaultValue/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Ice/dispatcher/run.py b/cpp/test/Ice/dispatcher/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/dispatcher/run.py +++ b/cpp/test/Ice/dispatcher/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/exceptions/run.py b/cpp/test/Ice/exceptions/run.py index 43526feb98b..f1fb492a715 100755 --- a/cpp/test/Ice/exceptions/run.py +++ b/cpp/test/Ice/exceptions/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/facets/run.py b/cpp/test/Ice/facets/run.py index 099ce110107..db68ff30b9a 100755 --- a/cpp/test/Ice/facets/run.py +++ b/cpp/test/Ice/facets/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/faultTolerance/run.py b/cpp/test/Ice/faultTolerance/run.py index d1473a0250a..2dce603e0a8 100755 --- a/cpp/test/Ice/faultTolerance/run.py +++ b/cpp/test/Ice/faultTolerance/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") client = os.path.join(os.getcwd(), "client") @@ -28,20 +28,21 @@ base = 12340 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer(server, "%d" % (base + i))) - print "ok" + print("ok") ports = "" for i in range(0, num): ports = "%s %d" % (ports, base + i) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, ports, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/cpp/test/Ice/gc/run.py b/cpp/test/Ice/gc/run.py index 51dea83141e..dcf09c04d79 100755 --- a/cpp/test/Ice/gc/run.py +++ b/cpp/test/Ice/gc/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") @@ -27,4 +27,3 @@ seedfile = os.path.join(os.getcwd(), "seed") TestUtil.simpleTest(client, '"%s"' % seedfile) os.remove(seedfile) - diff --git a/cpp/test/Ice/hold/run.py b/cpp/test/Ice/hold/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/hold/run.py +++ b/cpp/test/Ice/hold/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/info/run.py b/cpp/test/Ice/info/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/info/run.py +++ b/cpp/test/Ice/info/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/inheritance/run.py b/cpp/test/Ice/inheritance/run.py index 099ce110107..db68ff30b9a 100755 --- a/cpp/test/Ice/inheritance/run.py +++ b/cpp/test/Ice/inheritance/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/interceptor/run.py b/cpp/test/Ice/interceptor/run.py index 1be74428998..384e0ed4805 100755 --- a/cpp/test/Ice/interceptor/run.py +++ b/cpp/test/Ice/interceptor/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client, " --Ice.Warn.Dispatch=0") - diff --git a/cpp/test/Ice/invoke/run.py b/cpp/test/Ice/invoke/run.py index 719a5ffbd39..361d84543dc 100755 --- a/cpp/test/Ice/invoke/run.py +++ b/cpp/test/Ice/invoke/run.py @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with Blobject server." +print("tests with Blobject server.") TestUtil.clientServerTest() -print "tests with BlobjectArray server." +print("tests with BlobjectArray server.") TestUtil.clientServerTest(additionalServerOptions = "--array") -print "tests with BlobjectAsync server." +print("tests with BlobjectAsync server.") TestUtil.clientServerTest(additionalServerOptions = "--async") -print "tests with BlobjectAsyncArray server." +print("tests with BlobjectAsyncArray server.") TestUtil.clientServerTest(additionalServerOptions = "--array --async") - diff --git a/cpp/test/Ice/location/run.py b/cpp/test/Ice/location/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/location/run.py +++ b/cpp/test/Ice/location/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/objects/run.py b/cpp/test/Ice/objects/run.py index 099ce110107..db68ff30b9a 100755 --- a/cpp/test/Ice/objects/run.py +++ b/cpp/test/Ice/objects/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/operations/run.py b/cpp/test/Ice/operations/run.py index 17b74635d79..698206c03ca 100755 --- a/cpp/test/Ice/operations/run.py +++ b/cpp/test/Ice/operations/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0") -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server = "serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/properties/run.py b/cpp/test/Ice/properties/run.py index 18f78f00db1..e0193967f47 100755 --- a/cpp/test/Ice/properties/run.py +++ b/cpp/test/Ice/properties/run.py @@ -17,25 +17,34 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") # # Write config # -configPath = u"./config/ä¸å›½_client.config" - -TestUtil.createConfig(configPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=./config/ä¸å›½_client.config"]) +if sys.version_info[0] == 2: + configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config".decode("utf-8") + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=./config/ä¸å›½_client.config"]) +else: + configPath = "./config/\u4e2d\u56fd_client.config" + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") TestUtil.simpleTest(client) if os.path.exists(configPath): - os.remove(configPath)
\ No newline at end of file + os.remove(configPath) diff --git a/cpp/test/Ice/proxy/run.py b/cpp/test/Ice/proxy/run.py index 43526feb98b..f1fb492a715 100755 --- a/cpp/test/Ice/proxy/run.py +++ b/cpp/test/Ice/proxy/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/retry/run.py b/cpp/test/Ice/retry/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/retry/run.py +++ b/cpp/test/Ice/retry/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/servantLocator/run.py b/cpp/test/Ice/servantLocator/run.py index 43526feb98b..f1fb492a715 100755 --- a/cpp/test/Ice/servantLocator/run.py +++ b/cpp/test/Ice/servantLocator/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cpp/test/Ice/slicing/exceptions/run.py b/cpp/test/Ice/slicing/exceptions/run.py index 7056fe381ec..0dc8f723956 100755 --- a/cpp/test/Ice/slicing/exceptions/run.py +++ b/cpp/test/Ice/slicing/exceptions/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") - diff --git a/cpp/test/Ice/slicing/objects/run.py b/cpp/test/Ice/slicing/objects/run.py index a3051e1fc42..c5200040d14 100755 --- a/cpp/test/Ice/slicing/objects/run.py +++ b/cpp/test/Ice/slicing/objects/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server = "serveramd") - diff --git a/cpp/test/Ice/stream/run.py b/cpp/test/Ice/stream/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/Ice/stream/run.py +++ b/cpp/test/Ice/stream/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Ice/stringConverter/run.py b/cpp/test/Ice/stringConverter/run.py index c864d65fafb..247405f3610 100755 --- a/cpp/test/Ice/stringConverter/run.py +++ b/cpp/test/Ice/stringConverter/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Ice/threadPoolPriority/run.py b/cpp/test/Ice/threadPoolPriority/run.py index 26f66ec7fac..cdf273409f3 100755 --- a/cpp/test/Ice/threadPoolPriority/run.py +++ b/cpp/test/Ice/threadPoolPriority/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests default server thread pool." +print("tests default server thread pool.") TestUtil.clientServerTest() -print "tests custom server thread pool." +print("tests custom server thread pool.") TestUtil.clientServerTest(server = "servercustom") - diff --git a/cpp/test/Ice/timeout/run.py b/cpp/test/Ice/timeout/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cpp/test/Ice/timeout/run.py +++ b/cpp/test/Ice/timeout/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cpp/test/Ice/udp/run.py b/cpp/test/Ice/udp/run.py index edb57a0f46c..012688ce120 100755 --- a/cpp/test/Ice/udp/run.py +++ b/cpp/test/Ice/udp/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # COMPILERFIX: The server fails to start on Solaris when IPv6 is @@ -26,7 +26,7 @@ from scripts import * # linked-local configured link. # if TestUtil.isSolaris() and TestUtil.ipv6: - print "test not supported on Solaris with IPv6" + print("test not supported on Solaris with IPv6") sys.exit(0) server = os.path.join(os.getcwd(), "server") @@ -36,16 +36,17 @@ num = 5 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer(server, "%d" % i , adapter="McastTestAdapter")) - print "ok" + print("ok") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, "%d" % num, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/cpp/test/IceBox/configuration/run.py b/cpp/test/IceBox/configuration/run.py index 1c9c186b581..1b006c54318 100755 --- a/cpp/test/IceBox/configuration/run.py +++ b/cpp/test/IceBox/configuration/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil icebox = TestUtil.getIceBox() @@ -27,4 +27,3 @@ config2 = os.path.join(os.getcwd(), "config.icebox2") TestUtil.clientServerTest(additionalServerOptions= '--Ice.Config="%s"' % config, server = icebox) TestUtil.clientServerTest(additionalServerOptions= '--Ice.Config="%s"' % config2, server = icebox) - diff --git a/cpp/test/IceGrid/activation/run.py b/cpp/test/IceGrid/activation/run.py index 9baa8b2f02e..c3bcd3f1405 100755 --- a/cpp/test/IceGrid/activation/run.py +++ b/cpp/test/IceGrid/activation/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin IceGridAdmin.iceGridTest("application.xml", "", "properties-override='%s'" % IceGridAdmin.iceGridNodePropertiesOverride()) - diff --git a/cpp/test/IceGrid/admin/run.py b/cpp/test/IceGrid/admin/run.py index 67d30e16921..835aa346838 100755 --- a/cpp/test/IceGrid/admin/run.py +++ b/cpp/test/IceGrid/admin/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(path[0]) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin if not TestUtil.isWin32() and os.getuid() == 0: - print - print "*** can't run test as root ***" - print + sys.stdout.write("\n") + sys.stdout.write("*** can't run test as root ***\n") + sys.stdout.write("\n") sys.exit(0) testdir = os.getcwd(); @@ -37,7 +37,7 @@ if TestUtil.appverifier: registryProcs = IceGridAdmin.startIceGridRegistry(testdir) nodeProc = IceGridAdmin.startIceGridNode(testdir) -print "starting glacier2...", +sys.stdout.write("starting glacier2... ") sys.stdout.flush() args = ' --Glacier2.SessionTimeout=5' + \ @@ -50,9 +50,9 @@ args = ' --Glacier2.SessionTimeout=5' + \ ' --Ice.Default.Locator="IceGrid/Locator:default -p 12010"' + \ ' --IceSSL.VerifyPeer=1' routerProc = TestUtil.startServer(router, args, count=2) -print "ok" +print("ok") -print "testing login with username/password...", +sys.stdout.write("testing login with username/password... ") sys.stdout.flush() # Direct registry connection with username/password @@ -77,11 +77,11 @@ admin.sendline("server list") admin.expect('>>> ') admin.sendline('exit') admin.waitTestSuccess(timeout=120) -print "ok" +print("ok") if TestUtil.protocol == "ssl": - print "testing login with ssl...", + sys.stdout.write("testing login with ssl... ") sys.stdout.flush() # Direct registry connection with SSL @@ -103,9 +103,9 @@ if TestUtil.protocol == "ssl": admin.sendline('exit') admin.waitTestSuccess(timeout=120) - print "ok" + print("ok") -print "testing commands...", +sys.stdout.write("testing commands... ") sys.stdout.flush() icegridadmin = TestUtil.getIceGridAdmin() args = ' --Ice.Default.Locator="IceGrid/Locator:default -p 12010"' + \ @@ -195,9 +195,9 @@ admin.expect('node is up') admin.expect('>>> ') admin.sendline('exit') admin.waitTestSuccess(timeout=120) -print "ok" +print("ok") -# print "testing icegridadmin...", +# sys.stdout.write("testing icegridadmin... ") # sys.stdout.flush() # admin = Util.spawn('icegridadmin --Ice.Config=config.admin --Ice.Default.Router="DemoGlacier2/router:ssl -p 4064"') @@ -224,7 +224,7 @@ print "ok" # admin.sendline('exit') # admin.waitTestSuccess(timeout=120) -# print "ok" +# print("ok") # print "completing shutdown...", # sys.stdout.flush() @@ -243,11 +243,11 @@ print "ok" # admin.sendline('exit') # admin.waitTestSuccess(timeout=120) -print "stopping glacier2...", +sys.stdout.write("stopping glacier2... ") sys.stdout.flush() routerProc.kill(signal.SIGINT) routerProc.waitTestSuccess() -print "ok" +print("ok") IceGridAdmin.iceGridAdmin("node shutdown localnode") IceGridAdmin.shutdownIceGridRegistry(registryProcs) @@ -255,4 +255,3 @@ nodeProc.waitTestSuccess() if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd(targets) - diff --git a/cpp/test/IceGrid/allocation/run.py b/cpp/test/IceGrid/allocation/run.py index f44b04e16f5..9cddd6c3179 100755 --- a/cpp/test/IceGrid/allocation/run.py +++ b/cpp/test/IceGrid/allocation/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin IceGridAdmin.iceGridTest("application.xml") - diff --git a/cpp/test/IceGrid/deployer/run.py b/cpp/test/IceGrid/deployer/run.py index 20ca3c73a22..6f66f393364 100755 --- a/cpp/test/IceGrid/deployer/run.py +++ b/cpp/test/IceGrid/deployer/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin os.environ["MY_FOO"] = "12" @@ -27,4 +27,3 @@ IceGridAdmin.iceGridTest("application.xml", '--TestDir="%s"' % os.getcwd(), "ice # Tests with targets IceGridAdmin.iceGridTest("application.xml", '-t --TestDir="%s"' % os.getcwd(), "icebox.exe='%s' moreservers moreservices moreproperties" % TestUtil.getIceBox()) - diff --git a/cpp/test/IceGrid/distribution/run.py b/cpp/test/IceGrid/distribution/run.py index 8c9f3bcab43..bf345146953 100755 --- a/cpp/test/IceGrid/distribution/run.py +++ b/cpp/test/IceGrid/distribution/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin def icepatch2Calc(datadir, dirname): icePatch2Calc = "" @@ -43,7 +43,8 @@ files = [ ] -print "creating IcePatch2 data directory...", +sys.stdout.write("creating IcePatch2 data directory... ") +sys.stdout.flush() if not os.path.exists(datadir): os.mkdir(datadir) else: @@ -59,7 +60,7 @@ for [file, content] in files: icepatch2Calc(datadir, "original") icepatch2Calc(datadir, "updated") -print "ok" +print("ok") IceGridAdmin.iceGridTest("application.xml") diff --git a/cpp/test/IceGrid/fileLock/run.py b/cpp/test/IceGrid/fileLock/run.py index 8068eb87cff..41f6b82ee41 100755 --- a/cpp/test/IceGrid/fileLock/run.py +++ b/cpp/test/IceGrid/fileLock/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin testdir = os.getcwd(); @@ -52,11 +52,10 @@ def runIceGridRegistry(): registryProcs = IceGridAdmin.startIceGridRegistry(testdir) -print "testing IceGrid file lock...", +sys.stdout.write("testing IceGrid file lock... ") iceGrid = runIceGridRegistry() iceGrid.expect(".*IceUtil::FileLockedException.*") iceGrid.wait() -print "ok" +print("ok") IceGridAdmin.shutdownIceGridRegistry(registryProcs) - diff --git a/cpp/test/IceGrid/replicaGroup/run.py b/cpp/test/IceGrid/replicaGroup/run.py index 4bd32ee230f..a3079355940 100755 --- a/cpp/test/IceGrid/replicaGroup/run.py +++ b/cpp/test/IceGrid/replicaGroup/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin IceGridAdmin.iceGridTest("application.xml", "--Ice.RetryIntervals=\"0 50 100 250\"", "icebox.exe='%s'" % TestUtil.getIceBox()) - diff --git a/cpp/test/IceGrid/replication/run.py b/cpp/test/IceGrid/replication/run.py index c1ff43bf060..cc61946c6b2 100755 --- a/cpp/test/IceGrid/replication/run.py +++ b/cpp/test/IceGrid/replication/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin TestUtil.addLdPath(os.getcwd()) if TestUtil.sqlType != None and TestUtil.sqlType != "QSQLITE": - print "*** This test only supports Freeze or SQLite databases" + print("*** This test only supports Freeze or SQLite databases") sys.exit(0) variables = "properties-override='%s'" % IceGridAdmin.iceGridNodePropertiesOverride() diff --git a/cpp/test/IceGrid/session/run.py b/cpp/test/IceGrid/session/run.py index 2f9e95a01d4..4e20e9f655f 100755 --- a/cpp/test/IceGrid/session/run.py +++ b/cpp/test/IceGrid/session/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin if not TestUtil.isWin32() and os.getuid() == 0: - print - print "*** can't run test as root ***" - print + sys.stdout.write("\n") + sys.stdout.write("*** can't run test as root ***\n") + sys.stdout.write("\n") sys.exit(0) name = os.path.join("IceGrid", "session") @@ -34,9 +34,9 @@ if not os.path.exists(node1Dir): else: IceGridAdmin.cleanDbDir(node1Dir) -print "starting admin permissions verifier...", +sys.stdout.write("starting admin permissions verifier... ") verifierProc = TestUtil.startServer(os.path.join(os.getcwd(), "verifier"), config=TestUtil.DriverConfig("server")) -print "ok" +print("ok") IceGridAdmin.registryOptions += \ r' --IceGrid.Registry.DynamicRegistration' + \ @@ -51,4 +51,3 @@ IceGridAdmin.iceGridTest("application.xml", 'properties-override=\'%s\'' % IceGridAdmin.iceGridNodePropertiesOverride()) verifierProc.waitTestSuccess() - diff --git a/cpp/test/IceGrid/simple/run.py b/cpp/test/IceGrid/simple/run.py index 568bbe5fa53..c0e31578fda 100755 --- a/cpp/test/IceGrid/simple/run.py +++ b/cpp/test/IceGrid/simple/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin # # Test client/server without on demand activation. @@ -29,4 +29,3 @@ IceGridAdmin.iceGridClientServerTest("", "--TestAdapter.Endpoints=default --Test # Test client/server with on demand activation. # IceGridAdmin.iceGridTest("simple_server.xml", "--with-deploy") - diff --git a/cpp/test/IceGrid/update/run.py b/cpp/test/IceGrid/update/run.py index 8435dad3012..093afe59055 100755 --- a/cpp/test/IceGrid/update/run.py +++ b/cpp/test/IceGrid/update/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin name = os.path.join("IceGrid", "update") @@ -39,4 +39,3 @@ nodeOverrideOptions = '--IceBinDir="%s" --TestDir="%s" ' % (TestUtil.getCppBinDi IceGridAdmin.iceGridNodePropertiesOverride() IceGridAdmin.iceGridTest("", nodeOverrideOptions) - diff --git a/cpp/test/IceSSL/configuration/run.py b/cpp/test/IceSSL/configuration/run.py index 5235efd9276..8942615d408 100755 --- a/cpp/test/IceSSL/configuration/run.py +++ b/cpp/test/IceSSL/configuration/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest(additionalClientOptions = '"%s"' % os.getcwd()) - diff --git a/cpp/test/IceStorm/federation/run.py b/cpp/test/IceStorm/federation/run.py index 62b48b15fa6..bf0d91e32b5 100755 --- a/cpp/test/IceStorm/federation/run.py +++ b/cpp/test/IceStorm/federation/run.py @@ -17,9 +17,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil publisher = os.path.join(os.getcwd(), "publisher") subscriber = os.path.join(os.getcwd(), "subscriber") @@ -53,33 +53,34 @@ def runtest(type, **args): icestorm.start() - print "setting up topics...", + sys.stdout.write("setting up topics... ") sys.stdout.flush() icestorm.admin("create fed1 fed2 fed3; link fed1 fed2 10; link fed2 fed3 5") - print "ok" + print("ok") # # Test oneway subscribers. # - print "testing oneway subscribers...", + sys.stdout.write("testing oneway subscribers... ") sys.stdout.flush() doTest(icestorm, 0) - print "ok" + print("ok") # # Test batch oneway subscribers. # - print "testing batch subscribers...", + sys.stdout.write("testing batch subscribers... ") sys.stdout.flush() doTest(icestorm, 1) - print "ok" + print("ok") # # Destroy the topics. # - print "destroying topics...", + sys.stdout.write("destroying topics... ") + sys.stdout.flush() icestorm.admin("destroy fed1 fed2 fed3") - print "ok" + print("ok") # # Shutdown icestorm. diff --git a/cpp/test/IceStorm/federation2/run.py b/cpp/test/IceStorm/federation2/run.py index d9d89192a5a..0981cd3a81b 100755 --- a/cpp/test/IceStorm/federation2/run.py +++ b/cpp/test/IceStorm/federation2/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil, Expect iceStormAdmin = "" if TestUtil.isBCC2010(): @@ -81,26 +81,26 @@ def runtest(type, **args): adminIceStormReference = ' --IceStormAdmin.TopicManager.Proxy="%s" --IceStormAdmin.TopicManager.Proxy2="%s"' % ( icestorm1.proxy(), icestorm2.proxy()) - print "setting up the topics...", + sys.stdout.write("setting up the topics... ") sys.stdout.flush() admin(adminIceStormReference, "create TestIceStorm1/fed1 TestIceStorm2/fed1; link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "ok" + print("ok") # # Test oneway subscribers. # - print "testing federation with oneway subscribers...", + sys.stdout.write("testing federation with oneway subscribers... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 0) - print "ok" + print("ok") # # Test batch oneway subscribers. # - print "testing federation with batch subscribers...", + sys.stdout.write("testing federation with batch subscribers... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 1) - print "ok" + print("ok") # # Test #2: @@ -108,7 +108,7 @@ def runtest(type, **args): # Stop and restart the service and repeat the test. This ensures that # the database is correct. # - print "restarting services to ensure that the database content is preserved...", + sys.stdout.write("restarting services to ensure that the database content is preserved... ") sys.stdout.flush() # @@ -119,23 +119,23 @@ def runtest(type, **args): icestorm1.start(echo=False) icestorm2.start(echo=False) - print "ok" + print("ok") # # Test oneway subscribers. # - print "retesting federation with oneway subscribers... ", + sys.stdout.write("retesting federation with oneway subscribers... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 0) - print "ok" + print("ok") # # Test batch oneway subscribers. # - print "retesting federation with batch subscribers... ", + sys.stdout.write("retesting federation with batch subscribers... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 1) - print "ok" + print("ok") # # Shutdown icestorm. @@ -151,31 +151,31 @@ def runtest(type, **args): # Ensure they are received by the linked server. # if type != "replicated": - print "restarting only one IceStorm server...", + sys.stdout.write("restarting only one IceStorm server... ") sys.stdout.flush() proc = icestorm1.start(echo=False) #proc.expect("topic.fed1.*subscriber offline") #proc.expect("connection refused") - print "ok" + print("ok") # # Test oneway subscribers. # - print "testing that the federation link reports an error...", + sys.stdout.write("testing that the federation link reports an error... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 0, icestorm1.reference()) - # Give some time for the output to be sent. - time.sleep(2) + # Give some time for the output to be sent. + time.sleep(2) proc.expect("topic.fed1.*subscriber offline") - print "ok" + print("ok") - print "starting downstream icestorm server...", + sys.stdout.write("starting downstream icestorm server... ") sys.stdout.flush() icestorm2.start(echo=False) - print "ok" + print("ok") # # Need to sleep for at least the discard interval. @@ -185,10 +185,10 @@ def runtest(type, **args): # # Test oneway subscribers. # - print "testing link is reestablished...", + sys.stdout.write("testing link is reestablished... ") sys.stdout.flush() doTest(icestorm1, icestorm2, 0) - print "ok" + print("ok") try: proc.expect("topic.fed1.*subscriber offline") @@ -205,26 +205,27 @@ def runtest(type, **args): # Trash the TestIceStorm2 database. Then restart the servers and # verify that the link is removed. # - print "destroying the downstream IceStorm service database...", + sys.stdout.write("destroying the downstream IceStorm service database... ") sys.stdout.flush() icestorm2.clean() - print "ok" + print("ok") - print "restarting IceStorm servers...", + sys.stdout.write("restarting IceStorm servers... ") sys.stdout.flush() icestorm1.start(echo = False) icestorm2.start(echo = False) - print "ok" + print("ok") - print "checking link still exists...", + sys.stdout.write("checking link still exists... ") + sys.stdout.flush() line = admin(adminIceStormReference, "links TestIceStorm1") if not re.compile("fed1 with cost 0").search(line): - print line + print(line) sys.exit(1) - print "ok" + print("ok") - print "publishing some events...", + sys.stdout.write("publishing some events... ") sys.stdout.flush() # The publisher must be run twice because all the events can be # sent out in one batch to the linked subscriber which means that @@ -232,13 +233,13 @@ def runtest(type, **args): # sent. Furthermore, with a replicated IceStorm both sets of # events must be set to the same replica. runPublisher(icestorm1, opt = " --count 2") - print "ok" + print("ok") # Give the unsubscription time to propagate. time.sleep(1) # Verify that the link has disappeared. - print "verifying that the link has been destroyed...", + sys.stdout.write("verifying that the link has been destroyed... ") sys.stdout.flush() line = admin(adminIceStormReference, "links TestIceStorm1") nRetry = 5 @@ -247,25 +248,26 @@ def runtest(type, **args): time.sleep(1) # Give more time for unsubscription to propagate. nRetry -= 1 if len(line) > 0: - print line + print(line) sys.exit(1) - print "ok" + print("ok") # # Destroy the remaining topic. # - print "destroying topics...", + sys.stdout.write("destroying topics... ") + sys.stdout.flush() admin(adminIceStormReference, "destroy TestIceStorm1/fed1") - print "ok" + print("ok") # # Shutdown icestorm. # - print "shutting down icestorm services...", + sys.stdout.write("shutting down icestorm services... ") sys.stdout.flush() icestorm1.stop() icestorm2.stop() - print "ok" + print("ok") runtest("persistent") runtest("replicated", replicatedPublisher = False) diff --git a/cpp/test/IceStorm/rep1/run.py b/cpp/test/IceStorm/rep1/run.py index b1f62dc216f..358090cdf82 100755 --- a/cpp/test/IceStorm/rep1/run.py +++ b/cpp/test/IceStorm/rep1/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil publisher = os.path.join(os.getcwd(), "publisher") subscriber = os.path.join(os.getcwd(), "subscriber") @@ -77,23 +77,23 @@ icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), "replicated", repli ' --IceStorm.Election.ResponseTimeout=2') icestorm.start() -print "testing topic creation across replicas...", +sys.stdout.write("testing topic creation across replicas... ") sys.stdout.flush() icestorm.admin("create single") for replica in range(0, 3): icestorm.adminForReplica(replica, "create single", "error: topic `single' exists") -print "ok" +print("ok") -print "testing topic destruction across replicas...", +sys.stdout.write("testing topic destruction across replicas... ") sys.stdout.flush() icestorm.admin("destroy single") for replica in range(0, 3): icestorm.adminForReplica(replica, "destroy single", "error: couldn't find topic `single'") -print "ok" +print("ok") -print "testing topic creation without replica...", +sys.stdout.write("testing topic creation without replica... ") sys.stdout.flush() icestorm.stopReplica(0) @@ -107,11 +107,11 @@ icestorm.adminForReplica(0, "create single", "ConnectionRefused") icestorm.startReplica(0, echo=False) icestorm.adminForReplica(0, "create single", "error: topic `single' exists") -print "ok" +print("ok") icestorm.admin("destroy single") -print "testing topic creation without master...", +sys.stdout.write("testing topic creation without master... ") sys.stdout.flush() icestorm.stopReplica(2) @@ -125,11 +125,11 @@ icestorm.adminForReplica(2, "create single", "ConnectionRefused") icestorm.startReplica(2, echo=False) icestorm.adminForReplica(2, "create single", "error: topic `single' exists") -print "ok" +print("ok") # All replicas are running -print "testing topic destruction without replica...", +sys.stdout.write("testing topic destruction without replica... ") sys.stdout.flush() icestorm.stopReplica(0) @@ -143,9 +143,9 @@ icestorm.adminForReplica(0, "destroy single", "ConnectionRefused") icestorm.startReplica(0, echo=False) icestorm.adminForReplica(0, "destroy single", "error: couldn't find topic `single'") -print "ok" +print("ok") -print "testing topic destruction without master...", +sys.stdout.write("testing topic destruction without master... ") sys.stdout.flush() icestorm.admin("create single") @@ -161,29 +161,29 @@ icestorm.adminForReplica(2, "destroy single", "ConnectionRefused") icestorm.startReplica(2, echo=False) icestorm.adminForReplica(2, "destroy single", "error: couldn't find topic `single'") -print "ok" +print("ok") # Now test subscription/unsubscription on all replicas. icestorm.admin("create single") -print "testing subscription across replicas...", +sys.stdout.write("testing subscription across replicas... ") sys.stdout.flush() runsub2() for replica in range(0, 3): runsub2(replica, "IceStorm::AlreadySubscribed") -print "ok" +print("ok") -print "testing unsubscription across replicas...", +sys.stdout.write("testing unsubscription across replicas... ") sys.stdout.flush() rununsub2() for replica in range(0, 3): rununsub2(replica) -print "ok" +print("ok") -print "testing subscription without master...", +sys.stdout.write("testing subscription without master... ") sys.stdout.flush() icestorm.stopReplica(2) @@ -197,9 +197,9 @@ runsub2(2, "ConnectionRefused") icestorm.startReplica(2, echo=False) runsub2(2, "IceStorm::AlreadySubscribed") -print "ok" +print("ok") -print "testing unsubscription without master...", +sys.stdout.write("testing unsubscription without master... ") sys.stdout.flush() icestorm.stopReplica(2) @@ -213,9 +213,9 @@ rununsub2(2, "ConnectionRefused") icestorm.startReplica(2, echo=False) rununsub2(2) -print "ok" +print("ok") -print "testing subscription without replica...", +sys.stdout.write("testing subscription without replica... ") sys.stdout.flush() icestorm.stopReplica(0) @@ -229,9 +229,9 @@ runsub2(0, "ConnectionRefused") icestorm.startReplica(0, echo=False) runsub2(0, "IceStorm::AlreadySubscribed") -print "ok" +print("ok") -print "testing unsubscription without replica...", +sys.stdout.write("testing unsubscription without replica... ") sys.stdout.flush() icestorm.stopReplica(0) @@ -245,48 +245,48 @@ rununsub2(0, "ConnectionRefused") icestorm.startReplica(0, echo=False) rununsub2(0) -print "ok" +print("ok") # All replicas are running -print "running twoway subscription test...", +sys.stdout.write("running twoway subscription test... ") sys.stdout.flush() runtest("twoway", icestorm.reference()) -print "ok" +print("ok") -print "running ordered subscription test...", +sys.stdout.write("running ordered subscription test... ") sys.stdout.flush() runtest("ordered", icestorm.reference()) -print "ok" +print("ok") icestorm.stopReplica(2) -print "running twoway, ordered subscription test without master...", +sys.stdout.write("running twoway, ordered subscription test without master... ") sys.stdout.flush() runtest("twoway", icestorm.reference()) runtest("ordered", icestorm.reference()) -print "ok" +print("ok") icestorm.startReplica(2, echo = False) icestorm.stopReplica(0) -print "running twoway, ordered subscription test without replica...", +sys.stdout.write("running twoway, ordered subscription test without replica... ") sys.stdout.flush() runtest("twoway", icestorm.reference()) runtest("ordered", icestorm.reference()) -print "ok" +print("ok") icestorm.startReplica(0, echo = False) -print "running cycle publishing test...", +sys.stdout.write("running cycle publishing test... ") sys.stdout.flush() runtest("twoway", icestorm.reference(), pubopt=" --cycle") -print "ok" +print("ok") -print "stopping replicas...", +sys.stdout.write("stopping replicas... ") sys.stdout.flush() icestorm.stop() -print "ok" +print("ok") if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/repgrid/run.py b/cpp/test/IceStorm/repgrid/run.py index 834e9ff9783..1fb8a64dc8c 100755 --- a/cpp/test/IceStorm/repgrid/run.py +++ b/cpp/test/IceStorm/repgrid/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil, IceGridAdmin targets = [] if TestUtil.appverifier: diff --git a/cpp/test/IceStorm/repstress/run.py b/cpp/test/IceStorm/repstress/run.py index 67096c750c6..08aa574ea6b 100755 --- a/cpp/test/IceStorm/repstress/run.py +++ b/cpp/test/IceStorm/repstress/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil publisher = os.path.join(os.getcwd(), "publisher") subscriber = os.path.join(os.getcwd(), "subscriber") @@ -40,86 +40,86 @@ icestorm = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), "replicated", repli ' --IceStorm.Election.ResponseTimeout=2') icestorm.start() -print "creating topic...", +sys.stdout.write("creating topic... ") sys.stdout.flush() icestorm.admin("create single") -print "ok" +print("ok") -print "running subscriber...", +sys.stdout.write("running subscriber... ") sys.stdout.flush() subscriberProc = TestUtil.startServer(subscriber, ' --Ice.ServerIdleTime=0 ' + icestorm.reference(), echo = False) subscriberProc.expect("([^\n]+)\n") subControl = subscriberProc.match.group(1) -print "ok" +print("ok") -print "running publisher...", +sys.stdout.write("running publisher... ") sys.stdout.flush() publisherProc = TestUtil.startServer(publisher, ' --Ice.ServerIdleTime=0 ' + icestorm.reference(), echo = False) publisherProc.expect("([^\n]+)\n") pubControl = publisherProc.match.group(1) -print "ok" +print("ok") time.sleep(2) for i in range(0, 3): # 0, 1 - print "stopping replica 2 (0, 1 running)...", + sys.stdout.write("stopping replica 2 (0, 1 running)... ") sys.stdout.flush() icestorm.stopReplica(2) - print "ok" + print("ok") time.sleep(2) # 1, 2 - print "starting 2, stopping 0 (1, 2 running)...", + sys.stdout.write("starting 2, stopping 0 (1, 2 running)... ") sys.stdout.flush() icestorm.startReplica(2, echo=False) icestorm.stopReplica(0) - print "ok" + print("ok") # This waits for the replication to startup #icestorm.admin("list") time.sleep(2) # 0, 2 - print "starting 0, stopping 1 (0, 2 running)...", + sys.stdout.write("starting 0, stopping 1 (0, 2 running)... ") sys.stdout.flush() icestorm.startReplica(0, echo=False) icestorm.stopReplica(1) - print "ok" + print("ok") # This waits for the replication to startup #icestorm.admin("list") time.sleep(2) - print "starting 1 (all running)...", + sys.stdout.write("starting 1 (all running)... ") sys.stdout.flush() icestorm.startReplica(1, echo=False) - print "ok" + print("ok") # This waits for the replication to startup #icestorm.admin("list") time.sleep(2) -print "stopping publisher...", +sys.stdout.write("stopping publisher... ") sys.stdout.flush() runcontrol(pubControl) publisherProc.expect("([^\n]+)\n") publisherCount = publisherProc.match.group(1) publisherProc.waitTestSuccess() -print "ok" +print("ok") -print "stopping replicas...", +sys.stdout.write("stopping replicas... ") sys.stdout.flush() icestorm.stop() -print "ok" +print("ok") -print "stopping subscriber...", +sys.stdout.write("stopping subscriber... ") sys.stdout.flush() runcontrol(subControl) subscriberProc.expect("([^\n]+)\n") subscriberCount = subscriberProc.match.group(1) subscriberProc.waitTestSuccess() -print "ok" +print("ok") -print "publisher published %s events, subscriber received %s events" % (publisherCount, subscriberCount) +print("publisher published %s events, subscriber received %s events" % (publisherCount, subscriberCount)) if TestUtil.appverifier: TestUtil.appVerifierAfterTestEnd(targets, cwd = os.getcwd()) diff --git a/cpp/test/IceStorm/single/run.py b/cpp/test/IceStorm/single/run.py index 27935f821e8..bfba477917e 100755 --- a/cpp/test/IceStorm/single/run.py +++ b/cpp/test/IceStorm/single/run.py @@ -17,9 +17,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil publisher = os.path.join(os.getcwd(), "publisher") subscriber = os.path.join(os.getcwd(), "subscriber") @@ -35,24 +35,24 @@ def dotest(type): icestorm.start() - print "creating topic...", + sys.stdout.write("creating topic... ") sys.stdout.flush() icestorm.admin("create single") - print "ok" + print("ok") - print "starting subscriber...", + sys.stdout.write("starting subscriber... ") sys.stdout.flush() subscriberProc = TestUtil.startServer(subscriber, icestorm.reference(), count = 5) - print "ok" + print("ok") # # Start the publisher. This should publish 10 events which eventually # causes subscriber to terminate. # - print "starting publisher...", + sys.stdout.write("starting publisher... ") sys.stdout.flush() publisherProc = TestUtil.startClient(publisher, icestorm.reference(), startReader = False) - print "ok" + print("ok") publisherProc.startReader() subscriberProc.waitTestSuccess() @@ -61,10 +61,10 @@ def dotest(type): # # Destroy the topic. # - print "destroy topic...", + sys.stdout.write("destroy topic... ") sys.stdout.flush() icestorm.admin("destroy single") - print "ok" + print("ok") # # Shutdown icestorm. diff --git a/cpp/test/IceStorm/stress/run.py b/cpp/test/IceStorm/stress/run.py index 21a799e0667..87d6ab2541e 100755 --- a/cpp/test/IceStorm/stress/run.py +++ b/cpp/test/IceStorm/stress/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceStormUtil iceStormAdmin = "" if TestUtil.isBCC2010(): @@ -57,84 +57,85 @@ def runAdmin(cmd, desc = None): global iceStormAdmin global iceStormAdminReference if desc: - print desc, + sys.stdout.write(desc + " ") sys.stdout.flush() proc = TestUtil.startClient(iceStormAdmin, adminIceStormReference + r' -e "%s"' % cmd, startReader = True) proc.waitTestSuccess() if desc: - print "ok" + print("ok") def runtest(type): # Clear the idle timeout otherwise the IceBox ThreadPool will timeout. server1 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, dbDir = "db", instanceName = "TestIceStorm1", - port = 12000) + port = 12000) server2 = IceStormUtil.init(TestUtil.toplevel, os.getcwd(), type, dbDir = "db2", instanceName = "TestIceStorm2", - port = 12500) + port = 12500) global adminIceStormReference adminIceStormReference = ' --IceStormAdmin.TopicManager.Proxy="%s" --IceStormAdmin.TopicManager.Proxy2="%s"' % ( server1.proxy(), server2.proxy()) - print "starting icestorm services...", + sys.stdout.write("starting icestorm services... ") sys.stdout.flush() server1.start(echo=False) server2.start(echo=False) - print "ok" + print("ok") runAdmin("create TestIceStorm1/fed1 TestIceStorm2/fed1", "setting up the topics...") - print "Sending 5000 ordered events... ", + sys.stdout.write("Sending 5000 ordered events... ") sys.stdout.flush() doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server1.reference(), '--events 5000') - print "ok" + print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 5000 ordered events across a link... ", + sys.stdout.write("Sending 5000 ordered events across a link... ") sys.stdout.flush() doTest(server1, server2, '--events 5000 --qos "reliability,ordered" ' + server2.reference(), '--events 5000') - print "ok" + print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events... ", + sys.stdout.write("Sending 20000 unordered events... ") sys.stdout.flush() doTest(server1, server2, '--events 20000 ' + server1.reference(), '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events across a link... ", + sys.stdout.write("Sending 20000 unordered events across a link... ") sys.stdout.flush() doTest(server1, server2, '--events 20000 ' + server2.reference(), '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered batch events... ", + sys.stdout.write("Sending 20000 unordered batch events... ") sys.stdout.flush() doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server1.reference(), '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered batch events across a link... ", + sys.stdout.write("Sending 20000 unordered batch events across a link... ") sys.stdout.flush() doTest(server1, server2, '--events 20000 --qos "reliability,batch" ' + server2.reference(), '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events with slow subscriber... ", + sys.stdout.write("Sending 20000 unordered events with slow subscriber... ") + sys.stdout.flush() doTest(server1, server2, ['--events 2 --slow ' + server1.reference(), '--events 20000 ' + server1.reference()], '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events with slow subscriber & link... ", + sys.stdout.write("Sending 20000 unordered events with slow subscriber & link... ") + sys.stdout.flush() doTest(server1, server2, ['--events 2 --slow' + server1.reference(), '--events 20000' + server1.reference(), '--events 2 --slow' + server2.reference(), '--events 20000' + server2.reference()], '--events 20000 --oneway') - print "ok" - + print("ok") - print "shutting down icestorm services...", + sys.stdout.write("shutting down icestorm services... ") sys.stdout.flush() server1.stop() server2.stop() - print "ok" + print("ok") - print "starting icestorm services...", + sys.stdout.write("starting icestorm services... ") sys.stdout.flush() # # The erratic tests emit lots of connection warnings so they are @@ -143,21 +144,21 @@ def runtest(type): # server1.start(echo=False, additionalOptions = ' --Ice.Warn.Connections=0') server2.start(echo=False, additionalOptions = ' --Ice.Warn.Connections=0') - print "ok" + print("ok") runAdmin("unlink TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events with erratic subscriber... ", + sys.stdout.write("Sending 20000 unordered events with erratic subscriber... ") sys.stdout.flush() doTest(server1, server2, [ '--erratic 5 --qos "reliability,ordered" --events 20000' + server1.reference(), '--erratic 5 --events 20000' + server1.reference(), '--events 20000' + server1.reference()], '--events 20000 --oneway') - print "ok" + print("ok") runAdmin("link TestIceStorm1/fed1 TestIceStorm2/fed1") - print "Sending 20000 unordered events with erratic subscriber across a link... ", + sys.stdout.write("Sending 20000 unordered events with erratic subscriber across a link... ") sys.stdout.flush() doTest(server1, server2, [ '--events 20000' + server1.reference(), @@ -167,16 +168,16 @@ def runtest(type): '--erratic 5 --qos "reliability,ordered" --events 20000 ' + server2.reference(), '--erratic 5 --events 20000 ' + server2.reference()], '--events 20000 --oneway ') - print "ok" + print("ok") # # Shutdown icestorm. # - print "shutting down icestorm services...", + sys.stdout.write("shutting down icestorm services... ") sys.stdout.flush() server1.stop() server2.stop() - print "ok" + print("ok") runtest("persistent") runtest("replicated") diff --git a/cpp/test/IceUtil/condvar/run.py b/cpp/test/IceUtil/condvar/run.py index e82f73fb946..b04ffcce420 100755 --- a/cpp/test/IceUtil/condvar/run.py +++ b/cpp/test/IceUtil/condvar/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil workqueue = os.path.join(os.getcwd(), "workqueue") diff --git a/cpp/test/IceUtil/fileLock/run.py b/cpp/test/IceUtil/fileLock/run.py index 48760b12db2..5ed68cb4b38 100755 --- a/cpp/test/IceUtil/fileLock/run.py +++ b/cpp/test/IceUtil/fileLock/run.py @@ -16,11 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "testing process file lock...", +sys.stdout.write("testing process file lock... ") sys.stdout.flush() client = os.path.join(os.getcwd(), "client") @@ -53,4 +53,4 @@ clientExe.expect('File lock acquired.\.*') clientExe.sendline('go') clientExe.expect('File lock released.') clientExe.waitTestSuccess() -print "ok" +print("ok") diff --git a/cpp/test/IceUtil/inputUtil/run.py b/cpp/test/IceUtil/inputUtil/run.py index 1e01f6b11bf..4d6633269cd 100755 --- a/cpp/test/IceUtil/inputUtil/run.py +++ b/cpp/test/IceUtil/inputUtil/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client, os.getcwd()) - diff --git a/cpp/test/IceUtil/priority/run.py b/cpp/test/IceUtil/priority/run.py index 3fe7d3cc948..5240b248794 100755 --- a/cpp/test/IceUtil/priority/run.py +++ b/cpp/test/IceUtil/priority/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client, os.getcwd()) - diff --git a/cpp/test/IceUtil/thread/run.py b/cpp/test/IceUtil/thread/run.py index 3fe7d3cc948..5240b248794 100755 --- a/cpp/test/IceUtil/thread/run.py +++ b/cpp/test/IceUtil/thread/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client, os.getcwd()) - diff --git a/cpp/test/IceUtil/timer/run.py b/cpp/test/IceUtil/timer/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/IceUtil/timer/run.py +++ b/cpp/test/IceUtil/timer/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/IceUtil/unicode/run.py b/cpp/test/IceUtil/unicode/run.py index 0a82dd170b3..6a8bc9790bc 100755 --- a/cpp/test/IceUtil/unicode/run.py +++ b/cpp/test/IceUtil/unicode/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client, '"%s"' % os.getcwd()) - diff --git a/cpp/test/IceUtil/uuid/run.py b/cpp/test/IceUtil/uuid/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/IceUtil/uuid/run.py +++ b/cpp/test/IceUtil/uuid/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py index 0baf3c1f4b0..7a9041ed4df 100755 --- a/cpp/test/Slice/errorDetection/run.py +++ b/cpp/test/Slice/errorDetection/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel os.getcwd()!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel os.getcwd()!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil slice2cpp = '"%s"' % os.path.join(TestUtil.getCppBinDir(), "slice2cpp") @@ -32,7 +32,8 @@ files.sort() for file in files: - print file + "...", + sys.stdout.write(file + "... ") + sys.stdout.flush() if file.find("Underscore") != -1: command = slice2cpp + ' --underscore -I. "%s"' % os.path.join(os.getcwd(), file) @@ -45,19 +46,23 @@ for file in files: lines1 = stderr.readlines() lines2 = open(os.path.join(os.getcwd(), regex1.sub(".err", file)), "r").readlines() if len(lines1) != len(lines2): - print "failed! " + print("failed!") sys.exit(1) regex2 = re.compile("^.*(?=" + file + ")") i = 0 while i < len(lines1): - line1 = regex2.sub("", lines1[i]).strip() - line2 = regex2.sub("", lines2[i]).strip() + if sys.version_info[0] == 2: + line1 = regex2.sub("", lines1[i]).strip() + line2 = regex2.sub("", lines2[i]).strip() + else: + line1 = regex2.sub("", lines1[i].decode("utf-8")).strip() + line2 = regex2.sub("", lines2[i]).strip() if line1 != line2: - print "failed! " + print("failed!") sys.exit(1) i = i + 1 else: - print "ok" + print("ok") sys.exit(0) diff --git a/cpp/test/Slice/keyword/run.py b/cpp/test/Slice/keyword/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/Slice/keyword/run.py +++ b/cpp/test/Slice/keyword/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cpp/test/Slice/structure/run.py b/cpp/test/Slice/structure/run.py index 3c4472ca289..86e9aba519e 100755 --- a/cpp/test/Slice/structure/run.py +++ b/cpp/test/Slice/structure/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") TestUtil.simpleTest(client) - diff --git a/cs/allTests.py b/cs/allTests.py index 13cb4f25073..a0eaee7c0b5 100755 --- a/cs/allTests.py +++ b/cs/allTests.py @@ -10,15 +10,16 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(toplevel)) -from scripts import * +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/cs/demo/Glacier2/callback/expect.py b/cs/demo/Glacier2/callback/expect.py index a3201105a50..d9044fb8780 100755 --- a/cs/demo/Glacier2/callback/expect.py +++ b/cs/demo/Glacier2/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Glacier2 import callback server = Util.spawn('./server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/async/expect.py b/cs/demo/Ice/async/expect.py index fe7e569598c..1cf962fb60d 100755 --- a/cs/demo/Ice/async/expect.py +++ b/cs/demo/Ice/async/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import async server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/bidir/expect.py b/cs/demo/Ice/bidir/expect.py index b5d2dd77d39..07d7bf4061f 100755 --- a/cs/demo/Ice/bidir/expect.py +++ b/cs/demo/Ice/bidir/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import bidir server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/callback/expect.py b/cs/demo/Ice/callback/expect.py index c0f99627fc2..ca6af990d77 100755 --- a/cs/demo/Ice/callback/expect.py +++ b/cs/demo/Ice/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import callback server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/hello/expect.py b/cs/demo/Ice/hello/expect.py index 02120b97512..e2f870f71d5 100755 --- a/cs/demo/Ice/hello/expect.py +++ b/cs/demo/Ice/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import hello server = Util.spawn('server.exe --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/cs/demo/Ice/invoke/expect.py b/cs/demo/Ice/invoke/expect.py index 9d815206632..b85166ce0cd 100755 --- a/cs/demo/Ice/invoke/expect.py +++ b/cs/demo/Ice/invoke/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import invoke server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/latency/expect.py b/cs/demo/Ice/latency/expect.py index 355c2d064ce..162f7be8233 100755 --- a/cs/demo/Ice/latency/expect.py +++ b/cs/demo/Ice/latency/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('server.exe --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing ping... ", +sys.stdout.write("testing ping... ") sys.stdout.flush() client = Util.spawn('client.exe') client.waitTestSuccess(timeout=100) -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess() -print client.before +print(client.before) diff --git a/cs/demo/Ice/minimal/expect.py b/cs/demo/Ice/minimal/expect.py index 879ee58dd12..ba1126f26d2 100755 --- a/cs/demo/Ice/minimal/expect.py +++ b/cs/demo/Ice/minimal/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,20 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('server.exe --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('client.exe') client.waitTestSuccess() server.expect('Hello World!') -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess(-signal.SIGINT) diff --git a/cs/demo/Ice/multicast/expect.py b/cs/demo/Ice/multicast/expect.py index ca379eeec9b..9f5bf6d525d 100755 --- a/cs/demo/Ice/multicast/expect.py +++ b/cs/demo/Ice/multicast/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import multicast multicast.run('client.exe', 'server.exe') diff --git a/cs/demo/Ice/nested/expect.py b/cs/demo/Ice/nested/expect.py index 3675dc8df2f..9a350308d70 100755 --- a/cs/demo/Ice/nested/expect.py +++ b/cs/demo/Ice/nested/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import nested server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/plugin/expect.py b/cs/demo/Ice/plugin/expect.py index f512bfa1114..d356efb6d0c 100755 --- a/cs/demo/Ice/plugin/expect.py +++ b/cs/demo/Ice/plugin/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import plugin server = Util.spawn('server.exe --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/cs/demo/Ice/serialize/expect.py b/cs/demo/Ice/serialize/expect.py index 67e3a1e9c8b..167c8aa3546 100755 --- a/cs/demo/Ice/serialize/expect.py +++ b/cs/demo/Ice/serialize/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import serialize server = Util.spawn('server.exe --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/cs/demo/Ice/session/expect.py b/cs/demo/Ice/session/expect.py index af2775285ec..2d7b35bd3c1 100755 --- a/cs/demo/Ice/session/expect.py +++ b/cs/demo/Ice/session/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import session server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/throughput/expect.py b/cs/demo/Ice/throughput/expect.py index ba511b50c67..155e6e1a057 100755 --- a/cs/demo/Ice/throughput/expect.py +++ b/cs/demo/Ice/throughput/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import throughput server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/Ice/value/expect.py b/cs/demo/Ice/value/expect.py index 7033d7206cc..a7efa8fbb32 100755 --- a/cs/demo/Ice/value/expect.py +++ b/cs/demo/Ice/value/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import value server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/IceBox/hello/expect.py b/cs/demo/IceBox/hello/expect.py index 169de72d791..0f0b39beec1 100755 --- a/cs/demo/IceBox/hello/expect.py +++ b/cs/demo/IceBox/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceBox import hello if Util.defaultHost: diff --git a/cs/demo/IceGrid/icebox/expect.py b/cs/demo/IceGrid/icebox/expect.py index a03c233400f..db05343e04a 100755 --- a/cs/demo/IceGrid/icebox/expect.py +++ b/cs/demo/IceGrid/icebox/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import icebox desc = 'application.xml' diff --git a/cs/demo/IceGrid/simple/expect.py b/cs/demo/IceGrid/simple/expect.py index 97925adc95f..7fec1de9984 100755 --- a/cs/demo/IceGrid/simple/expect.py +++ b/cs/demo/IceGrid/simple/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import simple def rewrite(fi, fo): diff --git a/cs/demo/IceStorm/clock/expect.py b/cs/demo/IceStorm/clock/expect.py index 4858bc0894e..36fa34e515f 100755 --- a/cs/demo/IceStorm/clock/expect.py +++ b/cs/demo/IceStorm/clock/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceStorm import clock clock.run('subscriber.exe', 'publisher.exe') diff --git a/cs/demo/book/lifecycle/expect.py b/cs/demo/book/lifecycle/expect.py index 175e2269fb4..aa802cd4209 100755 --- a/cs/demo/book/lifecycle/expect.py +++ b/cs/demo/book/lifecycle/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import lifecycle server = Util.spawn('server.exe --Ice.PrintAdapterReady') diff --git a/cs/demo/book/printer/expect.py b/cs/demo/book/printer/expect.py index 41dc18ab331..7dd1c5ebb42 100755 --- a/cs/demo/book/printer/expect.py +++ b/cs/demo/book/printer/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('server.exe --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('client.exe') client.waitTestSuccess() server.expect('Hello World!') server.kill(signal.SIGINT) server.waitTestSuccess(-signal.SIGINT) -print "ok" +print("ok") diff --git a/cs/demo/book/simple_filesystem/expect.py b/cs/demo/book/simple_filesystem/expect.py index e911326c6d4..b7a622e4f0e 100755 --- a/cs/demo/book/simple_filesystem/expect.py +++ b/cs/demo/book/simple_filesystem/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('server.exe --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('client.exe') client.expect('Contents of root directory:\n.*Down to a sunless sea.') client.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/cs/test/Glacier2/router/run.py b/cs/test/Glacier2/router/run.py index 5c65075b23c..ee03502de6d 100755 --- a/cs/test/Glacier2/router/run.py +++ b/cs/test/Glacier2/router/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = os.path.join(TestUtil.getCppBinDir(), "glacier2router") @@ -33,11 +33,12 @@ args = ' --Ice.Warn.Dispatch=0' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() routerConfig = TestUtil.DriverConfig("server") routerConfig.lang = "cpp" starterProc = TestUtil.startServer(router, args, count=2, config=routerConfig) -print "ok" +print("ok") TestUtil.clientServerTest() @@ -49,4 +50,3 @@ TestUtil.clientServerTest() TestUtil.clientServerTest(additionalClientOptions=" --shutdown") starterProc.waitTestSuccess() - diff --git a/cs/test/Glacier2/sessionHelper/run.py b/cs/test/Glacier2/sessionHelper/run.py index 14f5444fa0a..2c78cc668c4 100755 --- a/cs/test/Glacier2/sessionHelper/run.py +++ b/cs/test/Glacier2/sessionHelper/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = os.path.join(TestUtil.getCppBinDir(), "glacier2router") @@ -31,15 +31,13 @@ args = ' --Ice.Warn.Dispatch=0' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() routerConfig = TestUtil.DriverConfig("server") routerConfig.lang = "cpp" starterProc = TestUtil.startServer(router, args, count=2, config=routerConfig) -print "ok" - - +print("ok") TestUtil.clientServerTest(additionalClientOptions=" --shutdown") starterProc.waitTestSuccess() - diff --git a/cs/test/Ice/adapterDeactivation/run.py b/cs/test/Ice/adapterDeactivation/run.py index 77f0c8d938e..2577a21734d 100755 --- a/cs/test/Ice/adapterDeactivation/run.py +++ b/cs/test/Ice/adapterDeactivation/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cs/test/Ice/ami/run.py b/cs/test/Ice/ami/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/ami/run.py +++ b/cs/test/Ice/ami/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/background/run.py b/cs/test/Ice/background/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/background/run.py +++ b/cs/test/Ice/background/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/binding/run.py b/cs/test/Ice/binding/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/binding/run.py +++ b/cs/test/Ice/binding/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/checksum/run.py b/cs/test/Ice/checksum/run.py index 567f2b73758..d0a47cb5b0d 100755 --- a/cs/test/Ice/checksum/run.py +++ b/cs/test/Ice/checksum/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest(server = os.path.join(os.getcwd(), "server", "server")) - diff --git a/cs/test/Ice/defaultServant/run.py b/cs/test/Ice/defaultServant/run.py index 962474eacbc..c3b03943879 100755 --- a/cs/test/Ice/defaultServant/run.py +++ b/cs/test/Ice/defaultServant/run.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, " --Ice.Warn.Dispatch=0", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Ice/defaultValue/run.py b/cs/test/Ice/defaultValue/run.py index ab529efd138..3e488df3fcc 100755 --- a/cs/test/Ice/defaultValue/run.py +++ b/cs/test/Ice/defaultValue/run.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client...") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Ice/dictMapping/run.py b/cs/test/Ice/dictMapping/run.py index c9862180d69..6640de8b2d8 100755 --- a/cs/test/Ice/dictMapping/run.py +++ b/cs/test/Ice/dictMapping/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/dispatcher/run.py b/cs/test/Ice/dispatcher/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/dispatcher/run.py +++ b/cs/test/Ice/dispatcher/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/exceptions/run.py b/cs/test/Ice/exceptions/run.py index 44c084d0191..284c3164b5d 100755 --- a/cs/test/Ice/exceptions/run.py +++ b/cs/test/Ice/exceptions/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest(additionalClientOptions=" --Ice.Warn.Connections=0") -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/facets/run.py b/cs/test/Ice/facets/run.py index 77f0c8d938e..2577a21734d 100755 --- a/cs/test/Ice/facets/run.py +++ b/cs/test/Ice/facets/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cs/test/Ice/faultTolerance/run.py b/cs/test/Ice/faultTolerance/run.py index 567b9af49b1..ee45c2361bf 100755 --- a/cs/test/Ice/faultTolerance/run.py +++ b/cs/test/Ice/faultTolerance/run.py @@ -16,33 +16,35 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") client = os.path.join(os.getcwd(), "client") if TestUtil.isCygwin(): - print "\nYou may get spurious \"Signal 127\" messages during this test run." - print "These are expected and can be safely ignored.\n" + print("\nYou may get spurious \"Signal 127\" messages during this test run.") + print("These are expected and can be safely ignored.\n") num = 12 base = 12340 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer(server, " %d" % (base + i))) - print "ok" + print("ok") ports = "" for i in range(0, num): ports = "%s %d" % (ports, base + i) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, ports, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() @@ -51,4 +53,3 @@ for p in serverProc: # We simuluate the abort of the server by calling Process.Kill(). However, this # results in a non-zero exit status. Therefore we ignore the status. p.wait() - diff --git a/cs/test/Ice/hold/run.py b/cs/test/Ice/hold/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/hold/run.py +++ b/cs/test/Ice/hold/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/info/run.py b/cs/test/Ice/info/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/cs/test/Ice/info/run.py +++ b/cs/test/Ice/info/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/inheritance/run.py b/cs/test/Ice/inheritance/run.py index 77f0c8d938e..2577a21734d 100755 --- a/cs/test/Ice/inheritance/run.py +++ b/cs/test/Ice/inheritance/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cs/test/Ice/interceptor/run.py b/cs/test/Ice/interceptor/run.py index 962474eacbc..26dd9edd1a9 100755 --- a/cs/test/Ice/interceptor/run.py +++ b/cs/test/Ice/interceptor/run.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client...") +sys.stdout.flush() clientProc = TestUtil.startClient(client, " --Ice.Warn.Dispatch=0", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Ice/invoke/run.py b/cs/test/Ice/invoke/run.py index bcb78f3c4f3..caf7ed893df 100755 --- a/cs/test/Ice/invoke/run.py +++ b/cs/test/Ice/invoke/run.py @@ -16,13 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with Blobject server." +print("tests with Blobject server.") TestUtil.clientServerTest() -print "tests with BlobjectAsync server." +print("tests with BlobjectAsync server.") TestUtil.clientServerTest(additionalServerOptions = "--async") - diff --git a/cs/test/Ice/location/run.py b/cs/test/Ice/location/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/location/run.py +++ b/cs/test/Ice/location/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/objects/run.py b/cs/test/Ice/objects/run.py index 77f0c8d938e..2577a21734d 100755 --- a/cs/test/Ice/objects/run.py +++ b/cs/test/Ice/objects/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/cs/test/Ice/operations/run.py b/cs/test/Ice/operations/run.py index 3e283b7057f..81acfb12c18 100755 --- a/cs/test/Ice/operations/run.py +++ b/cs/test/Ice/operations/run.py @@ -16,18 +16,17 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0") -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="serveramd") -print "tests with TIE server." +print("tests with TIE server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="servertie") -print "tests with AMD TIE server." +print("tests with AMD TIE server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="serveramdtie") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/properties/run.py b/cs/test/Ice/properties/run.py index 238d312c8d3..bd4e789bd08 100755 --- a/cs/test/Ice/properties/run.py +++ b/cs/test/Ice/properties/run.py @@ -17,24 +17,32 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # Write config # -configPath = u"./config/ä¸å›½_client.config" +if sys.version_info[0] == 2: + configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config".decode("utf-8") + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=./config/ä¸å›½_client.config"]) +else: + configPath = "./config/\u4e2d\u56fd_client.config" + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") -TestUtil.createConfig(configPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=./config/ä¸å›½_client.config"]) - TestUtil.simpleTest() if os.path.exists(configPath): os.remove(configPath) - diff --git a/cs/test/Ice/proxy/run.py b/cs/test/Ice/proxy/run.py index c9862180d69..6640de8b2d8 100755 --- a/cs/test/Ice/proxy/run.py +++ b/cs/test/Ice/proxy/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/retry/run.py b/cs/test/Ice/retry/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/retry/run.py +++ b/cs/test/Ice/retry/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/seqMapping/run.py b/cs/test/Ice/seqMapping/run.py index c9862180d69..6640de8b2d8 100755 --- a/cs/test/Ice/seqMapping/run.py +++ b/cs/test/Ice/seqMapping/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/servantLocator/run.py b/cs/test/Ice/servantLocator/run.py index 0878a0bea14..6ab094299b9 100755 --- a/cs/test/Ice/servantLocator/run.py +++ b/cs/test/Ice/servantLocator/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/cs/test/Ice/slicing/exceptions/run.py b/cs/test/Ice/slicing/exceptions/run.py index e4431ee21f8..29c9d1ed808 100755 --- a/cs/test/Ice/slicing/exceptions/run.py +++ b/cs/test/Ice/slicing/exceptions/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") - diff --git a/cs/test/Ice/slicing/objects/run.py b/cs/test/Ice/slicing/objects/run.py index e4431ee21f8..29c9d1ed808 100755 --- a/cs/test/Ice/slicing/objects/run.py +++ b/cs/test/Ice/slicing/objects/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") - diff --git a/cs/test/Ice/stream/run.py b/cs/test/Ice/stream/run.py index 20e51607f28..706a33e09c7 100755 --- a/cs/test/Ice/stream/run.py +++ b/cs/test/Ice/stream/run.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, " --Ice.Warn.Dispatch=0 2>&1", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Ice/threadPoolPriority/run.py b/cs/test/Ice/threadPoolPriority/run.py index 30b2f67d975..0f5c95157d2 100644 --- a/cs/test/Ice/threadPoolPriority/run.py +++ b/cs/test/Ice/threadPoolPriority/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/timeout/run.py b/cs/test/Ice/timeout/run.py index 30b2f67d975..0f5c95157d2 100755 --- a/cs/test/Ice/timeout/run.py +++ b/cs/test/Ice/timeout/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/cs/test/Ice/udp/run.py b/cs/test/Ice/udp/run.py index 0da6d6cd315..9bb1bba1690 100755 --- a/cs/test/Ice/udp/run.py +++ b/cs/test/Ice/udp/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "server") client = os.path.join(os.getcwd(), "client") @@ -27,16 +27,17 @@ num = 5 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer(server, "%d" % i, adapter="McastTestAdapter")) - print "ok" + print("ok") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, "%d" % num, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/cs/test/IceBox/configuration/run.py b/cs/test/IceBox/configuration/run.py index dffb41c6ecb..be6f95c9b96 100755 --- a/cs/test/IceBox/configuration/run.py +++ b/cs/test/IceBox/configuration/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil icebox = TestUtil.getIceBox() @@ -26,4 +26,3 @@ TestUtil.clientServerTest(additionalServerOptions='--Ice.Config="%s"' % os.path. server=icebox) TestUtil.clientServerTest(additionalServerOptions='--Ice.Config="%s"' % os.path.join(os.getcwd(), "config.icebox2"), server=icebox) - diff --git a/cs/test/IceGrid/simple/run.py b/cs/test/IceGrid/simple/run.py index 15b7b57a29e..9ca6fbaa061 100755 --- a/cs/test/IceGrid/simple/run.py +++ b/cs/test/IceGrid/simple/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin # # Test client/server without on demand activation. @@ -32,4 +32,3 @@ if TestUtil.mono: IceGridAdmin.iceGridTest("simple_mono_server.xml", "--with-deploy") else: IceGridAdmin.iceGridTest("simple_server.xml", "--with-deploy") - diff --git a/cs/test/IceSSL/certs/makecerts.py b/cs/test/IceSSL/certs/makecerts.py index 31ffe817358..8aa5350113f 100755 --- a/cs/test/IceSSL/certs/makecerts.py +++ b/cs/test/IceSSL/certs/makecerts.py @@ -24,11 +24,11 @@ from scripts import * # Show usage information. # def usage(): - print "Usage: " + sys.argv[0] + " [options]" - print - print "Options:" - print "-h Show this message." - print "-f Force an update to the C# files." + print("Usage: " + sys.argv[0] + " [options]") + print("") + print("Options:") + print("-h Show this message.") + print("-f Force an update to the C# files.") # # Check arguments @@ -41,8 +41,8 @@ for x in sys.argv[1:]: elif x == "-f": force = 1 elif x.startswith("-"): - print sys.argv[0] + ": unknown option `" + x + "'" - print + print(sys.argv[0] + ": unknown option `" + x + "'") + print("") usage() sys.exit(1) else: @@ -71,9 +71,9 @@ for x in certs: cert = os.path.join(cppcerts, x) os.system("openssl pkcs12 -in " + cert + "_pub.pem -inkey " + cert + "_priv.pem -export -out " + x + \ ".pfx -passout pass:password") - print "Created " + x + ".pfx" + print("Created " + x + ".pfx") # # Done. # -print "Done." +print("Done.") diff --git a/cs/test/IceSSL/configuration/run.py b/cs/test/IceSSL/configuration/run.py index d9df827efcd..a21a590a2f7 100755 --- a/cs/test/IceSSL/configuration/run.py +++ b/cs/test/IceSSL/configuration/run.py @@ -16,13 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # The drive letter needs to be removed on Windows or loading the SSL # plug-in will not work. # TestUtil.clientServerTest(additionalClientOptions = '"%s"' % os.path.splitdrive(os.getcwd())[1]) - diff --git a/cs/test/IceUtil/inputUtil/run.py b/cs/test/IceUtil/inputUtil/run.py index 267b40578d3..125647947c3 100755 --- a/cs/test/IceUtil/inputUtil/run.py +++ b/cs/test/IceUtil/inputUtil/run.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, "", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Slice/keyword/run.py b/cs/test/Slice/keyword/run.py index 9b0c665b5ef..de94f7be0b9 100755 --- a/cs/test/Slice/keyword/run.py +++ b/cs/test/Slice/keyword/run.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/cs/test/Slice/structure/run.py b/cs/test/Slice/structure/run.py index 9b0c665b5ef..de94f7be0b9 100755 --- a/cs/test/Slice/structure/run.py +++ b/cs/test/Slice/structure/run.py @@ -16,15 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil client = os.path.join(os.getcwd(), "client") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/demoscript/Freeze/bench.py b/demoscript/Freeze/bench.py index 79b1033fd13..06e35438da5 100755 --- a/demoscript/Freeze/bench.py +++ b/demoscript/Freeze/bench.py @@ -13,55 +13,55 @@ import sys def run(client, isJava=False): if isJava: client.expect('IntIntMap \\(Collections API\\)') - print "IntIntMap (Collections API):" + print("IntIntMap (Collections API):") client.expect('IntIntMap \\(Fast API\\)', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap (Fast API):" + print("IntIntMap (Fast API):") client.expect('IntIntMap with index \\(Collections API\\)', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap with index (Collections API):" + print("IntIntMap with index (Collections API):") client.expect('IntIntMap with index \\(Fast API\\)', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap with index (Fast API):" + print("IntIntMap with index (Fast API):") client.expect('Struct1Struct2Map', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) else: client.expect('IntIntMap') - print "IntIntMap:" + print("IntIntMap:") client.expect('IntIntMap with index', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap with index:" + print("IntIntMap with index:") client.expect('Struct1Struct2Map', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "Struct1Struct2Map:" + print("Struct1Struct2Map:") client.expect('Struct1Struct2Map with index', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "Struct1Struct2Map with index:" + print("Struct1Struct2Map with index:") client.expect('Struct1Class1Map', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "Struct1Class1Map:" + print("Struct1Class1Map:") client.expect('Struct1Class1Map with index', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "Struct1Class1Map with index:" + print("Struct1Class1Map with index:") client.expect('Struct1ObjectMap', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "Struct1ObjectMap:" + print("Struct1ObjectMap:") client.expect('IntIntMap \\(read test\\)', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap (read test):" + print("IntIntMap (read test):") client.expect('IntIntMap with index \\(read test\\)', timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) - print "IntIntMap with index (read test):" + print("IntIntMap with index (read test):") client.waitTestSuccess(timeout=200) - print "%s " % (client.before) + print("%s " % (client.before)) diff --git a/demoscript/Freeze/casino.py b/demoscript/Freeze/casino.py index 4a58a0619ac..b7cbdc8902a 100755 --- a/demoscript/Freeze/casino.py +++ b/demoscript/Freeze/casino.py @@ -11,30 +11,30 @@ import sys, demoscript, signal def run(clientStr, serverStr): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() demoscript.Util.cleanDbDir("db") - print "ok" + print("ok") - print "starting server...", + sys.stdout.write("starting server... ") sys.stdout.flush() server = demoscript.Util.spawn(serverStr + ' --Ice.PrintAdapterReady --Freeze.Warn.Deadlocks=0') server.expect('Casino ready') - print "ok" + print("ok") - print "starting client1...", + sys.stdout.write("starting client1... ") sys.stdout.flush() client1 = demoscript.Util.spawn(clientStr) client1.expect('Retrieve bank and players... ok') - print "ok" + print("ok") - print "starting client2...", + sys.stdout.write("starting client2... ") sys.stdout.flush() client2 = demoscript.Util.spawn(clientStr) client2.expect('Retrieve bank and players... ok') - print "ok" + print("ok") - print "gambling...", + sys.stdout.write("gambling... ") sys.stdout.flush() client1.expect('All chips accounted for\? yes\nEach player buys 3,000 chips... ok\nAll chips accounted for\? yes'); server.expect('The bank has [0-9]+ outstanding chips') @@ -48,12 +48,12 @@ def run(clientStr, serverStr): client1.expect('All chips accounted for\? yes', timeout=400) client2.expect('All chips accounted for\? yes', timeout=400) - print "ok" + print("ok") - print "shutting down...", + sys.stdout.write("shutting down... ") sys.stdout.flush() client1.waitTestSuccess() client2.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Freeze/library.py b/demoscript/Freeze/library.py index 9ed0fbf1357..38dc33075cb 100755 --- a/demoscript/Freeze/library.py +++ b/demoscript/Freeze/library.py @@ -9,7 +9,7 @@ # ********************************************************************** import sys -from scripts import Expect +import Expect def dequote(s): cur = 0 @@ -38,7 +38,7 @@ def mkregexp(s): return s def run(client, server): - print "populating database... ", + sys.stdout.write("populating database... ") sys.stdout.flush() f = open("books", "r") books = [] @@ -47,16 +47,16 @@ def run(client, server): client.expect('added new book') isbn, title, author = dequote(l) books.append((isbn, title, author)) - print "ok" + print("ok") byauthor = {} for b in books: isbn, title, author = b - if not byauthor.has_key(author): + if author not in byauthor: byauthor[author] = [] byauthor[author].append(b) - print "testing isbn... ", + sys.stdout.write("testing isbn... ") sys.stdout.flush() for b in books: isbn, title, author = b @@ -67,11 +67,11 @@ def run(client, server): client.expect('authors: %s' %(author)) client.sendline('isbn 1000') client.expect('no book with that') - print "ok" + print("ok") - print "testing authors... ", + sys.stdout.write("testing authors... ") sys.stdout.flush() - for a, bl in byauthor.iteritems(): + for a, bl in byauthor.items(): client.sendline('authors "%s"' %(a)) client.expect('number of books found: ([0-9]+)') n = int(client.match.group(1)) @@ -97,9 +97,9 @@ def run(client, server): client.sendline('authors foo') client.expect('number of books found: 0') client.expect('no current book') - print "ok" + print("ok") - print "testing rent/return... ", + sys.stdout.write("testing rent/return... ") sys.stdout.flush() isbn, title, author = books[0] client.sendline('isbn %s' % (isbn)) @@ -117,9 +117,9 @@ def run(client, server): client.expect('rented:', timeout=2) except Expect.TIMEOUT: pass - print "ok" + print("ok") - print "testing remove... ", + sys.stdout.write("testing remove... ") sys.stdout.flush() isbn, title, author = books[0] client.sendline('isbn %s' % (isbn)) @@ -135,4 +135,4 @@ def run(client, server): client.sendline('exit') client.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Freeze/phonebook.py b/demoscript/Freeze/phonebook.py index 4a5148903f0..de17c0bd504 100755 --- a/demoscript/Freeze/phonebook.py +++ b/demoscript/Freeze/phonebook.py @@ -9,7 +9,7 @@ # ********************************************************************** import sys -from scripts import Expect +import Expect def dequote(s): cur = 0 @@ -38,7 +38,7 @@ def mkregexp(s): return s def run(client, server): - print "populating database... ", + sys.stdout.write("populating database... ") sys.stdout.flush() f = open("contacts", "r") for l in f: @@ -52,9 +52,9 @@ def run(client, server): client.expect('\n', timeout=1) except Expect.TIMEOUT: pass - print "ok" + print("ok") - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.sendline('find "Doe, John"') client.expect('number of contacts found: 3') @@ -95,4 +95,4 @@ def run(client, server): client.sendline('exit') client.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Freeze/transform.py b/demoscript/Freeze/transform.py index 0aaec65c62b..e7d6bdb4768 100755 --- a/demoscript/Freeze/transform.py +++ b/demoscript/Freeze/transform.py @@ -12,19 +12,21 @@ import sys, demoscript, time from scripts import Expect def run(createCmd, recreateCmd, readCmd, readnewCmd): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() demoscript.Util.cleanDbDir("db") demoscript.Util.cleanDbDir("dbnew") - print "ok" + print("ok") - print "creating database...", + sys.stdout.write("creating database... ") + sys.stdout.flush() create = demoscript.Util.spawn(createCmd) create.expect('7 contacts were successfully created or updated') create.waitTestSuccess() - print "ok" + print("ok") - print "reading database...", + sys.stdout.write("reading database... ") + sys.stdout.flush() read = demoscript.Util.spawn(readCmd) read.expect(["All contacts \(default order\)", 'arnold:\t{1,2}\(333\)333-3333 x1234', @@ -43,28 +45,32 @@ def run(createCmd, recreateCmd, readCmd, readnewCmd): 'ed:\t{1,2}\(666\)666-6666', 'don:\t{1,2}\(777\)777-7777']) read.waitTestSuccess() - print "ok" + print("ok") - print "transforming database...", + sys.stdout.write("transforming database... ") + sys.stdout.flush() transform = demoscript.Util.spawn('transformdb --old ContactData.ice --new NewContactData.ice -f transform.xml db dbnew') transform.waitTestSuccess() - print "ok" + print("ok") - print "reading new database...", + sys.stdout.write("reading new database... ") + sys.stdout.flush() readnew = demoscript.Util.spawn(readnewCmd) readnew.expect('All contacts \(default order\)') readnew.expect('All contacts \(ordered by phone number\)') readnew.expect('DbEnv \"dbnew\": contacts: DB_SECONDARY_BAD: Secondary index inconsistent with primary') readnew.waitTestSuccess(1) - print "ok" + print("ok") - print "recreating database...", + sys.stdout.write("recreating database... ") + sys.stdout.flush() recreate = demoscript.Util.spawn(recreateCmd) recreate.expect('Recreated contacts database successfully!') recreate.waitTestSuccess() - print "ok" + print("ok") - print "rereading new database...", + sys.stdout.write("rereading new database... ") + sys.stdout.flush() readnew = demoscript.Util.spawn(readnewCmd) readnew.expect(["All contacts \(default order\)", 'arnold:\t{1,2}\(333\)333-3333 x1234 arnold@gmail.com', @@ -83,4 +89,4 @@ def run(createCmd, recreateCmd, readCmd, readnewCmd): 'ed:\t{1,2}\(666\)666-6666 ed@gmail.com', 'don:\t{1,2}\(777\)777-7777 don@gmail.com',]) readnew.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Glacier2/callback.py b/demoscript/Glacier2/callback.py index 5d006ea64de..be51729c148 100755 --- a/demoscript/Glacier2/callback.py +++ b/demoscript/Glacier2/callback.py @@ -12,7 +12,7 @@ import sys, time, signal from scripts import Expect def run(client, server, glacier2): - print "testing ", + sys.stdout.write("testing ") sys.stdout.flush() client.expect('user id:') client.sendline("foo") @@ -21,42 +21,42 @@ def run(client, server, glacier2): client.expect("==>") - print "twoway", + sys.stdout.write("twoway ") sys.stdout.flush() client.sendline('t') server.expect('initiating callback to') client.expect('received callback') glacier2.expect('_fwd/t') - print "oneway", + sys.stdout.write("oneway ") sys.stdout.flush() client.sendline('o') server.expect('initiating callback to') client.expect('received callback') glacier2.expect('_fwd/o') - print "batch", + sys.stdout.write("batch ") sys.stdout.flush() client.sendline('O') + client.sendline('O') + client.sendline('f') try: server.expect('initiating callback to', timeout=1) except Expect.TIMEOUT: pass - client.sendline('O') - client.sendline('f') glacier2.expect('_fwd/O') - print "ok" + print("ok") - print "testing override context field...", + sys.stdout.write("testing override context field... ") sys.stdout.flush() client.sendline('v') client.sendline('t') glacier2.expect('_fwd/t, _ovrd/some_value') server.expect('initiating callback to') client.expect('received callback') - print "ok" + print("ok") - print "testing fake category...", + sys.stdout.write("testing fake category... ") sys.stdout.flush() client.sendline('v') client.sendline('F') @@ -66,7 +66,7 @@ def run(client, server, glacier2): client.expect('received callback', timeout=1) except Expect.TIMEOUT: pass - print "ok" + print("ok") client.sendline('s') server.expect('shutting down...') diff --git a/demoscript/Ice/async.py b/demoscript/Ice/async.py index cf779aa04f4..8b98d0eea21 100644 --- a/demoscript/Ice/async.py +++ b/demoscript/Ice/async.py @@ -9,11 +9,10 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect +import Expect def run(client, server): - print "testing client... ", + sys.stdout.write("testing client... ") sys.stdout.flush() client.sendline('i') server.expect('Hello World!') @@ -25,9 +24,9 @@ def run(client, server): client.sendline('i') server.expect('Hello World!') server.expect('Hello World!') - print "ok" + print("ok") - print "testing shutdown... ", + sys.stdout.write("testing shutdown... ") sys.stdout.flush() client.sendline('d') client.sendline('s') @@ -36,4 +35,4 @@ def run(client, server): client.expect('RequestCanceledException') client.sendline('x') client.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Ice/bidir.py b/demoscript/Ice/bidir.py index 09cb838c040..6cdca77fa30 100644 --- a/demoscript/Ice/bidir.py +++ b/demoscript/Ice/bidir.py @@ -9,34 +9,34 @@ # ********************************************************************** import sys, signal -from demoscript import * -from scripts import Expect +from demoscript import Util +import Expect def run(clientStr, server): - print "adding client 1... ", + sys.stdout.write("adding client 1... ") sys.stdout.flush() client1 = Util.spawn(clientStr) server.expect('adding client') client1.expect('received callback #1') - print "ok" + print("ok") - print "adding client 2... ", + sys.stdout.write("adding client 2... ") sys.stdout.flush() client2 = Util.spawn(clientStr) server.expect('adding client') client1.expect('received callback #') client2.expect('received callback #') - print "ok" + print("ok") - print "removing client 2...", + sys.stdout.write("removing client 2... ") sys.stdout.flush() client2.kill(signal.SIGINT) client2.waitTestSuccess(timeout=20) server.expect('removing client') client1.expect('received callback #') - print "ok" + print("ok") - print "removing client 1...", + sys.stdout.write("removing client 1... ") sys.stdout.flush() client1.kill(signal.SIGINT) client1.waitTestSuccess() @@ -45,4 +45,4 @@ def run(clientStr, server): server.kill(signal.SIGINT) server.waitTestSuccess(timeout=30) - print "ok" + print("ok") diff --git a/demoscript/Ice/callback.py b/demoscript/Ice/callback.py index 5e675161cec..9329fe5e362 100644 --- a/demoscript/Ice/callback.py +++ b/demoscript/Ice/callback.py @@ -9,11 +9,9 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def run(client, server): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.sendline('t') @@ -24,7 +22,7 @@ def run(client, server): server.expect('initiating callback') client.expect('received callback') - print "ok" + print("ok") client.sendline('s') server.waitTestSuccess() diff --git a/demoscript/Ice/hello.py b/demoscript/Ice/hello.py index baa2210fc5d..990e9426f30 100644 --- a/demoscript/Ice/hello.py +++ b/demoscript/Ice/hello.py @@ -9,26 +9,25 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect +import Expect def runtests(client, server, secure): - print "testing twoway", + sys.stdout.write("testing twoway ") sys.stdout.flush() client.sendline('t') server.expect('Hello World!') - print "oneway", + sys.stdout.write("oneway ") sys.stdout.flush() client.sendline('o') server.expect('Hello World!') if not secure: - print "datagram", + sys.stdout.write("datagram ") sys.stdout.flush() client.sendline('d') server.expect('Hello World!') - print "... ok" + print("... ok") - print "testing batch oneway", + sys.stdout.write("testing batch oneway ") sys.stdout.flush() client.sendline('O') try: @@ -40,7 +39,7 @@ def runtests(client, server, secure): server.expect('Hello World!') server.expect('Hello World!') if not secure: - print "datagram", + sys.stdout.write("datagram ") sys.stdout.flush() client.sendline('D') try: @@ -51,9 +50,9 @@ def runtests(client, server, secure): client.sendline('f') server.expect('Hello World!') server.expect('Hello World!') - print "... ok" + print("... ok") - print "testing timeout...", + sys.stdout.write("testing timeout... ") sys.stdout.flush() client.sendline('T') client.sendline('P') @@ -67,12 +66,12 @@ def runtests(client, server, secure): client.sendline('t') server.expect('Hello World!') client.sendline('T') - print "ok" + print("ok") def run(client, server): runtests(client, server, False) - print "repeating tests with SSL" + print("repeating tests with SSL") client.sendline('S') diff --git a/demoscript/Ice/interleaved.py b/demoscript/Ice/interleaved.py index a31204dd1d7..98df018a653 100644 --- a/demoscript/Ice/interleaved.py +++ b/demoscript/Ice/interleaved.py @@ -9,42 +9,40 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def runseries(client): - print "testing bytes..." + print("testing bytes...") client.expect('==> ', timeout=240) client.sendline('e') client.expect('==> ', timeout=2000) - print "echo: %s " % (client.before) + print("echo: %s " % (client.before)) - print "testing strings..." + print("testing strings...") client.sendline('2') client.expect('==> ', timeout=240) client.sendline('e') client.expect('==> ', timeout=2000) - print "echo: %s " % (client.before) + print("echo: %s " % (client.before)) - print "testing structs with string..." + print("testing structs with string...") client.sendline('3') client.expect('==> ', timeout=240) client.sendline('e') client.expect('==> ', timeout=2000) - print "echo: %s " % (client.before) + print("echo: %s " % (client.before)) - print "testing structs with two ints and double..." + print("testing structs with two ints and double...") client.sendline('4') client.expect('==> ', timeout=240) client.sendline('e') client.expect('==> ', timeout=2000) - print "echo: %s " % (client.before) + print("echo: %s " % (client.before)) def run(client, server): - print "testing with 2 outstanding requests\n" + print("testing with 2 outstanding requests\n") runseries(client) - print "testing with unlimited outstanding requests\n" + print("testing with unlimited outstanding requests\n") client.sendline('o') runseries(client) diff --git a/demoscript/Ice/invoke.py b/demoscript/Ice/invoke.py index 8120855930e..0b887c7147f 100644 --- a/demoscript/Ice/invoke.py +++ b/demoscript/Ice/invoke.py @@ -9,8 +9,7 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect +from demoscript import Util def runDemo(client, server): sys.stdout.flush() @@ -45,7 +44,8 @@ def runDemo(client, server): client.expect("Got string `hello' and class: s\\.name=green, s\\.value=green") def run(clientStr, server): - print "testing...", + sys.stdout.write("testing... ") + sys.stdout.flush() client = Util.spawn(clientStr) client.expect('==>') @@ -56,4 +56,4 @@ def run(clientStr, server): client.sendline('x') client.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/Ice/multicast.py b/demoscript/Ice/multicast.py index 65c3167ef11..970e3b5410b 100644 --- a/demoscript/Ice/multicast.py +++ b/demoscript/Ice/multicast.py @@ -9,8 +9,8 @@ # ********************************************************************** import sys, signal -from demoscript import * -from scripts import Expect +from demoscript import Util +import Expect def runClient(clientCmd, server1, server2): client = Util.spawn(clientCmd) @@ -25,7 +25,7 @@ def runClient(clientCmd, server1, server2): try: server2.expect('Hello World!', 1) received = True - except Expect.TIMEOUT, e: + except Expect.TIMEOUT as e: ex = e pass @@ -56,20 +56,20 @@ def runDemo(clientCmd, serverCmd): server2.waitTestSuccess() def run(clientCmd, serverCmd): - print "testing multicast discovery (Ipv4)...", + sys.stdout.write("testing multicast discovery (IPv4)... ") sys.stdout.flush() if serverCmd.startswith("java"): runDemo(clientCmd, "java -Djava.net.preferIPv4Stack=true Server") else: runDemo(clientCmd, serverCmd) - print "ok" + print("ok") if Util.getMapping() == "java" and Util.isWin32(): - print "skipping testing multicast discovery (IPv6) under windows...", + sys.stdout.write("skipping testing multicast discovery (IPv6) under Windows...") else: - print "testing multicast discovery (IPv6)...", + sys.stdout.write("testing multicast discovery (IPv6)... ") sys.stdout.flush() serverCmd += ' --Ice.IPv6=1 --Discover.Endpoints="udp -h \\"ff01::1:1\\" -p 10000"' clientCmd += ' --Ice.IPv6=1 --Discover.Proxy="discover:udp -h \\"ff01::1:1\\" -p 10000"' runDemo(clientCmd, serverCmd) - print "ok" + print("ok") diff --git a/demoscript/Ice/nested.py b/demoscript/Ice/nested.py index 71c24788ab4..3a21738aa5a 100644 --- a/demoscript/Ice/nested.py +++ b/demoscript/Ice/nested.py @@ -9,11 +9,9 @@ # ********************************************************************** import sys, signal -from demoscript import * -from scripts import Expect def run(client, server): - print "testing nested...", + sys.stdout.write("testing nested... ") sys.stdout.flush() client.sendline('1') server.expect('1') @@ -24,16 +22,16 @@ def run(client, server): client.sendline('3') server.expect('3\n1') client.expect('2\n.*for exit:') - print "ok" + print("ok") - print "testing blocking...", + sys.stdout.write("testing blocking... ") sys.stdout.flush() client.sendline('21') # This will cause a block. server.expect('\n'.join(['13', '11', '9', '7', '5', '3'])) client.expect('\n'.join(['12', '10', '8', '6', '4', '2'])) client.expect('TimeoutException', timeout=3000) server.expect('TimeoutException', timeout=3000) - print "ok" + print("ok") client.sendline('x') client.waitTestSuccess() diff --git a/demoscript/Ice/nrvo.py b/demoscript/Ice/nrvo.py index 7c2e3e202d2..4dc2fc0d23d 100644 --- a/demoscript/Ice/nrvo.py +++ b/demoscript/Ice/nrvo.py @@ -9,11 +9,9 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def run(client, server): - print "testing client... ", + sys.stdout.write("testing client... ") sys.stdout.flush() client.sendline('1') client.expect('==> ', timeout=2000) @@ -24,4 +22,4 @@ def run(client, server): client.sendline('s') client.expect('==> ', timeout=2000) client.sendline('x') - print "ok" + print("ok") diff --git a/demoscript/Ice/plugin.py b/demoscript/Ice/plugin.py index e5222bbcc62..b41ff66c561 100644 --- a/demoscript/Ice/plugin.py +++ b/demoscript/Ice/plugin.py @@ -9,15 +9,13 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def run(client, server): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.sendline('t') server.expect('PRINT: Hello World!') - print "ok" + print("ok") client.sendline('s') server.waitTestSuccess() diff --git a/demoscript/Ice/serialize.py b/demoscript/Ice/serialize.py index 85cf6840441..583bbe9cca8 100644 --- a/demoscript/Ice/serialize.py +++ b/demoscript/Ice/serialize.py @@ -9,26 +9,24 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def runtests(client, server, secure): - print "testing greeting...", + sys.stdout.write("testing greeting... ") sys.stdout.flush() client.sendline('g') server.expect('Hello there!') client.sendline('g') server.expect('Hello there!') - print "ok" + print("ok") - print "testing null greeting...", + sys.stdout.write("testing null greeting... ") sys.stdout.flush() client.sendline('t') client.sendline('g') server.expect('Received null greeting') client.sendline('g') server.expect('Received null greeting') - print "ok" + print("ok") def run(client, server): runtests(client, server, False) diff --git a/demoscript/Ice/session.py b/demoscript/Ice/session.py index d43db35d312..f607db2dcde 100644 --- a/demoscript/Ice/session.py +++ b/demoscript/Ice/session.py @@ -9,15 +9,14 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect +from demoscript import Util def run(clientStr, server): client = Util.spawn(clientStr) client.expect('==>') client.sendline('foo') - print "testing session creation...", + sys.stdout.write("testing session creation... ") sys.stdout.flush() server.expect('The session foo is now created.') client.sendline('c') @@ -28,9 +27,9 @@ def run(clientStr, server): client.sendline('x') client.waitTestSuccess() server.expect("The session foo is now destroyed.") - print "ok" + print("ok") - print "testing session cleanup...", + sys.stdout.write("testing session cleanup... ") sys.stdout.flush() client = Util.spawn(clientStr) client.expect('==>') @@ -40,7 +39,7 @@ def run(clientStr, server): client.sendline('t') client.waitTestSuccess() server.expect("The session foo is now destroyed.\n.*The session foo has timed out.", timeout=25) - print "ok" + print("ok") client = Util.spawn(clientStr) client.expect('==>') diff --git a/demoscript/Ice/throughput.py b/demoscript/Ice/throughput.py index 4f1c14edd23..09dfdd943c7 100644 --- a/demoscript/Ice/throughput.py +++ b/demoscript/Ice/throughput.py @@ -9,43 +9,42 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect +from demoscript import Util def runseries(client): client.expect('==> ', timeout=240) client.sendline('t') client.expect('==> ', timeout=2000) - print "twoway: %s " % (client.before) + print("twoway: %s " % (client.before)) if not Util.fast: client.sendline('o') client.expect('==> ', timeout=2000) - print "oneway: %s " % (client.before) + print("oneway: %s " % (client.before)) client.sendline('r') client.expect('==> ', timeout=2000) - print "receive: %s" % (client.before) + print("receive: %s" % (client.before)) client.sendline('e') client.expect('==> ', timeout=2000) - print "echo: %s" % (client.before) + print("echo: %s" % (client.before)) def run(client, server): - print "testing bytes" + print("testing bytes") runseries(client) - print "testing strings" + print("testing strings") client.sendline('2') runseries(client) - print "testing structs with string... " + print("testing structs with string") client.sendline('3') runseries(client) - print "testing structs with two ints and double... " + print("testing structs with two ints and double") client.sendline('4') runseries(client) diff --git a/demoscript/Ice/value.py b/demoscript/Ice/value.py index bb15cae2724..4c6577696d6 100644 --- a/demoscript/Ice/value.py +++ b/demoscript/Ice/value.py @@ -9,11 +9,9 @@ # ********************************************************************** import sys -from demoscript import * -from scripts import Expect def run(client, server, ruby = False): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.expect('press enter') client.sendline('') @@ -42,7 +40,7 @@ def run(client, server, ruby = False): client.expect('==> a derived message 4 u\n==> A DERIVED MESSAGE 4 U.*press enter') client.sendline('') client.expect('==> a derived message 4 u\n==> A DERIVED MESSAGE 4 U') - print "ok" + print("ok") server.waitTestSuccess() client.waitTestSuccess() diff --git a/demoscript/IceBox/hello.py b/demoscript/IceBox/hello.py index 8c64f9c0200..6f941be8e5c 100755 --- a/demoscript/IceBox/hello.py +++ b/demoscript/IceBox/hello.py @@ -9,25 +9,25 @@ # ********************************************************************** import sys, demoscript -from scripts import Expect +import Expect def runtests(client, server, secure): - print "testing twoway", + sys.stdout.write("testing twoway ") sys.stdout.flush() client.sendline('t') server.expect('Hello World!') - print "oneway", + sys.stdout.write("oneway ") sys.stdout.flush() client.sendline('o') server.expect('Hello World!') if not secure: - print "datagram", + sys.stdout.write("datagram ") sys.stdout.flush() client.sendline('d') server.expect('Hello World!') - print "... ok" + print("... ok") - print "testing batch oneway", + sys.stdout.write("testing batch oneway ") sys.stdout.flush() client.sendline('O') try: @@ -39,7 +39,7 @@ def runtests(client, server, secure): server.expect('Hello World!') server.expect('Hello World!') if not secure: - print "datagram", + sys.stdout.write("datagram ") sys.stdout.flush() client.sendline('D') try: @@ -50,13 +50,13 @@ def runtests(client, server, secure): client.sendline('f') server.expect('Hello World!') server.expect('Hello World!') - print "... ok" + print("... ok") def run(client, server): runtests(client, server, False) if not demoscript.Util.isMono(): - print "repeating tests with SSL" + print("repeating tests with SSL") client.sendline('S') diff --git a/demoscript/IceGrid/allocate.py b/demoscript/IceGrid/allocate.py index e1a768b8cc4..ed81add183f 100755 --- a/demoscript/IceGrid/allocate.py +++ b/demoscript/IceGrid/allocate.py @@ -9,11 +9,11 @@ # ********************************************************************** import sys, os -from demoscript import * -from scripts import Expect +from demoscript import Util +import Expect def run(clientCmd): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() nodeDir = os.path.join("db", "node") if not os.path.exists(nodeDir): @@ -25,28 +25,28 @@ def run(clientCmd): os.mkdir(regDir) else: Util.cleanDbDir(regDir) - print "ok" + print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' - print "starting icegridnode...", + sys.stdout.write("starting icegridnode... ") sys.stdout.flush() node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Registry.Internal ready\nIceGrid.Registry.Server ready\nIceGrid.Registry.Client ready\nIceGrid.Node ready') - print "ok" + print("ok") - print "deploying application...", + sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.grid') admin.expect('>>>') admin.sendline("application add \'application-single.xml\'") admin.expect('>>>') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() client1 = Util.spawn(clientCmd) client1.expect('user id:') @@ -77,15 +77,15 @@ def run(clientCmd): node.expect('detected termination of server') client2.sendline('x') client2.waitTestSuccess(timeout=1) - print "ok" + print("ok") - print "deploying multiple...", + sys.stdout.write("deploying multiple... ") sys.stdout.flush() admin.sendline("application update \'application-multiple.xml\'") admin.expect('>>>') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() client1 = Util.spawn(clientCmd) client1.expect('user id:') @@ -135,7 +135,7 @@ def run(clientCmd): client3.sendline('x') client3.waitTestSuccess(timeout=1) - print "ok" + print("ok") admin.sendline('registry shutdown Master') admin.sendline('exit') diff --git a/demoscript/IceGrid/icebox.py b/demoscript/IceGrid/icebox.py index e3cccfa572a..40de5974e36 100755 --- a/demoscript/IceGrid/icebox.py +++ b/demoscript/IceGrid/icebox.py @@ -9,11 +9,10 @@ # ********************************************************************** import sys, time, os -from demoscript import * -from scripts import Expect +from demoscript import Util def run(clientStr, desc = 'application'): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() nodeDir = os.path.join("db", "node") if not os.path.exists(nodeDir): @@ -25,14 +24,14 @@ def run(clientStr, desc = 'application'): os.mkdir(regDir) else: Util.cleanDbDir(regDir) - print "ok" + print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' - print "starting icegridnode...", + sys.stdout.write("starting icegridnode... ") sys.stdout.flush() node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Registry.Internal ready') @@ -41,9 +40,9 @@ def run(clientStr, desc = 'application'): if Util.getMapping() == "cpp": node.expect('IceGrid.Registry.AdminSessionManager ready') node.expect('IceGrid.Node ready') - print "ok" + print("ok") - print "deploying application...", + sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.grid') admin.expect('>>>') @@ -51,19 +50,19 @@ def run(clientStr, desc = 'application'): admin.expect('>>>') admin.sendline("server start IceBox") admin.expect('>>>', timeout=15) - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() for s in [ "Homer", "Marge", "Bart", "Lisa", "Maggie" ]: - client = Util.spawn(clientStr) - node.expect("Hello from %s" % s) - client.waitTestSuccess(timeout=1) + client = Util.spawn(clientStr) + node.expect("Hello from %s" % s) + client.waitTestSuccess(timeout=1) - print "ok" + print("ok") - print "testing stop/start of services...", + sys.stdout.write("testing stop/start of services... ") sys.stdout.flush() admin.sendline("service stop IceBox Lisa") @@ -78,7 +77,7 @@ def run(clientStr, desc = 'application'): client = Util.spawn(clientStr) node.expect("Hello from Marge") client.waitTestSuccess(timeout=1) - + client = Util.spawn(clientStr) node.expect("Hello from Bart") client.waitTestSuccess(timeout=1) @@ -104,7 +103,7 @@ def run(clientStr, desc = 'application'): client = Util.spawn(clientStr) node.expect("Hello from Lisa") client.waitTestSuccess(timeout=1) - + client = Util.spawn(clientStr) node.expect("Hello from Maggie") client.waitTestSuccess(timeout=1) @@ -113,9 +112,9 @@ def run(clientStr, desc = 'application'): node.expect("Hello from Bart") client.waitTestSuccess(timeout=1) - print "ok" + print("ok") - print "testing administration with Glacier2...", + sys.stdout.write("testing administration with Glacier2... ") sys.stdout.flush() admin.sendline("server start DemoGlacier2") @@ -124,13 +123,13 @@ def run(clientStr, desc = 'application'): # Windows seems to have problems with the password input. if Util.isWin32(): - admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Default.Router="DemoGlacier2/router:tcp -h localhost -p 4063" -u foo -p foo') + admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Default.Router="DemoGlacier2/router:tcp -h localhost -p 4063" -u foo -p foo') else: - admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Default.Router="DemoGlacier2/router:tcp -h localhost -p 4063"') - admin.expect('user id:') - admin.sendline('foo') - admin.expect('password:') - admin.sendline('foo') + admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Default.Router="DemoGlacier2/router:tcp -h localhost -p 4063"') + admin.expect('user id:') + admin.sendline('foo') + admin.expect('password:') + admin.sendline('foo') admin.expect('>>>', timeout=100) admin.sendline("service start IceBox Homer") @@ -158,7 +157,7 @@ def run(clientStr, desc = 'application'): node.expect("Hello from Bart") client.waitTestSuccess(timeout=1) - print "ok" + print("ok") admin.sendline('registry shutdown Master') admin.sendline('exit') diff --git a/demoscript/IceGrid/sessionActivation.py b/demoscript/IceGrid/sessionActivation.py index 81cf884e33c..d27264939aa 100755 --- a/demoscript/IceGrid/sessionActivation.py +++ b/demoscript/IceGrid/sessionActivation.py @@ -9,11 +9,10 @@ # ********************************************************************** import sys, os -from demoscript import * -from scripts import Expect +from demoscript import Util def run(clientCmd): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() nodeDir = os.path.join("db", "node") if not os.path.exists(nodeDir): @@ -25,28 +24,28 @@ def run(clientCmd): os.mkdir(regDir) else: Util.cleanDbDir(regDir) - print "ok" + print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' - print "starting icegridnode...", + sys.stdout.write("starting icegridnode... ") sys.stdout.flush() node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Registry.Internal ready\nIceGrid.Registry.Server ready\nIceGrid.Registry.Client ready\nIceGrid.Node ready') - print "ok" + print("ok") - print "deploying application...", + sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.grid') admin.expect('>>>') admin.sendline("application add \'application.xml\'") admin.expect('>>>') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() client = Util.spawn(clientCmd) @@ -75,7 +74,7 @@ def run(clientCmd): client.waitTestSuccess(timeout=1) node.expect('detected termination of server') - print "ok" + print("ok") admin.sendline('registry shutdown Master') admin.sendline('exit') diff --git a/demoscript/IceGrid/simple.py b/demoscript/IceGrid/simple.py index 054492c6baa..dd77a818846 100755 --- a/demoscript/IceGrid/simple.py +++ b/demoscript/IceGrid/simple.py @@ -9,11 +9,10 @@ # ********************************************************************** import sys, time, os -from demoscript import * -from scripts import Expect +from demoscript import Util def run(clientStr, desc = 'application'): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() nodeDir = os.path.join("db", "node") if not os.path.exists(nodeDir): @@ -25,31 +24,31 @@ def run(clientStr, desc = 'application'): os.mkdir(regDir) else: Util.cleanDbDir(regDir) - print "ok" + print("ok") if Util.defaultHost: args = ' --IceGrid.Node.PropertiesOverride="Ice.Default.Host=127.0.0.1"' else: args = '' - print "starting icegridnode...", + sys.stdout.write("starting icegridnode... ") sys.stdout.flush() node = Util.spawn(Util.getIceGridNode() + ' --Ice.Config=config.grid --Ice.PrintAdapterReady %s' % (args)) node.expect('IceGrid.Registry.Internal ready') node.expect('IceGrid.Registry.Server ready') node.expect('IceGrid.Registry.Client ready') node.expect('IceGrid.Node ready') - print "ok" + print("ok") - print "deploying application...", + sys.stdout.write("deploying application... ") sys.stdout.flush() admin = Util.spawn(Util.getIceGridAdmin() + ' --Ice.Config=config.grid') admin.expect('>>>') admin.sendline("application add \'%s.xml\'" %(desc)) admin.expect('>>>') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() client = Util.spawn(clientStr) client.expect('==>') @@ -62,15 +61,15 @@ def run(clientStr, desc = 'application'): client.sendline('x') client.waitTestSuccess(timeout=1) - print "ok" + print("ok") - print "deploying template...", + sys.stdout.write("deploying template... ") sys.stdout.flush() admin.sendline("application update \'%s_with_template.xml\'" % (desc)) admin.expect('>>>') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() client = Util.spawn(clientStr) client.expect('==>') @@ -83,15 +82,15 @@ def run(clientStr, desc = 'application'): client.sendline('x') client.waitTestSuccess(timeout=1) - print "ok" + print("ok") - print "deploying replicated version...", + sys.stdout.write("deploying replicated version... ") sys.stdout.flush() admin.sendline("application update \'%s_with_replication.xml\'" %(desc)) admin.expect('>>> ') - print "ok" + print("ok") - print "testing client...", + sys.stdout.write("testing client... ") sys.stdout.flush() def testserver(which): @@ -111,7 +110,7 @@ def run(clientStr, desc = 'application'): testserver(2) testserver(3) - print "ok" + print("ok") admin.sendline('registry shutdown Master') admin.sendline('exit') diff --git a/demoscript/IceStorm/clock.py b/demoscript/IceStorm/clock.py index 8ad9e241729..a5e75db91e0 100755 --- a/demoscript/IceStorm/clock.py +++ b/demoscript/IceStorm/clock.py @@ -9,11 +9,10 @@ # ********************************************************************** import sys, time, signal -from demoscript import * -from scripts import Expect +from demoscript import Util def runtest(icestorm, subCmd, subargs, pubCmd, pubargs): - print "testing pub%s/sub%s..." % (pubargs, subargs), + sys.stdout.write("testing pub%s/sub%s... " % (pubargs, subargs)) sys.stdout.flush() sub = Util.spawn('%s --Ice.PrintAdapterReady %s' %(subCmd, subargs)) sub.expect('.* ready') @@ -34,13 +33,13 @@ def runtest(icestorm, subCmd, subargs, pubCmd, pubargs): if sub.hasInterruptSupport(): icestorm.expect('unsubscribe:') - print "ok" + print("ok") def run(subCmd, pubCmd): - print "cleaning databases...", + sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") - print "ok" + print("ok") if Util.defaultHost: args = ' --IceBox.Service.IceStorm="IceStormService,34:createIceStorm --Ice.Config=config.service %s"' % Util.defaultHost diff --git a/demoscript/Util.py b/demoscript/Util.py index cd49103ca11..33f43d1734b 100644 --- a/demoscript/Util.py +++ b/demoscript/Util.py @@ -28,7 +28,8 @@ if os.path.isdir(os.path.join(toplevel, "cpp")): else: sourcedist = False -from scripts import Expect +sys.path.append(os.path.join(path[0], "scripts")) +import Expect keepGoing = False iceHome = None @@ -47,19 +48,18 @@ host = "127.0.0.1" # debug = False - origenv = {} def dumpenv(): - print "the following environment variables have been set:" + print("the following environment variables have been set:") for k, v in origenv.iteritems(): added = os.environ[k][:len(os.environ[k])-len(v)] - if len(v) > 0: - if isWin32(): - print "%s=%s%%%s%%" % (k, added, k) - else: - print "%s=%s$%s" % (k, added, k) - else: - print "%s=%s" % (k, added) + if len(v) > 0: + if isWin32(): + print("%s=%s%%%s%%" % (k, added, k)) + else: + print("%s=%s$%s" % (k, added, k)) + else: + print("%s=%s" % (k, added)) def addenv(var, val): global origenv @@ -73,10 +73,10 @@ def addenv(var, val): def configurePaths(): if iceHome: - print "[ using Ice installation from " + iceHome, + sys.stdout.write("[ using Ice installation from " + iceHome + " ") if x64: - print "(64bit)", - print "]" + sys.stdout.write("(64bit) ") + sys.stdout.write("]\n") # # If Ice is installed from RPMs, just set the CLASSPATH for Java. @@ -107,7 +107,7 @@ def configurePaths(): # 64-bits binaries are located in a subdirectory with binary # distributions. addenv("PATH", binDir) - if iceHome and x64: + if iceHome and x64: if isWin32(): binDir = os.path.join(binDir, "x64") elif isSolaris(): @@ -138,7 +138,7 @@ def configurePaths(): addenv("CLASSPATH", os.path.join(javaDir, "lib")) addenv("CLASSPATH", os.path.join("classes")) - # + # # On Windows, C# assemblies are found thanks to the .exe.config files. # if isWin32(): @@ -291,50 +291,49 @@ def runDemos(start, args, demos, num = 0, script = False, root = False): prefix = "" suffix = "" - print + sys.stdout.write("\n") if(num > 0): - print "[" + str(num) + "]", - print "%s*** running demo %d/%d in %s%s" % (prefix, index, total, dir, suffix) - print "%s*** configuration:" % prefix, + sys.stdout.write("[" + str(num) + "] ") + print("%s*** running demo %d/%d in %s%s" % (prefix, index, total, dir, suffix)) + sys.stdout.write("%s*** configuration: " % prefix) if len(args.strip()) == 0: - print "Default", + sys.stdout.write("Default ") else: - print args.strip(), - print suffix + sys.stdout.write(args.strip() + " ") + print(suffix) if script: - print "echo \"*** demo started: `date`\"" - print "cd %s" % dir + print("echo \"*** demo started: `date`\"") + print("cd %s" % dir) else: - print "*** demo started:", time.strftime("%x %X") + print("*** demo started: " + time.strftime("%x %X")) sys.stdout.flush() os.chdir(dir) if script: - print "if ! python %s %s; then" % (os.path.join(dir, "expect.py"), args) - print " echo 'demo in %s failed'" % os.path.abspath(dir) + print("if ! %s %s %s; then" % (sys.executable, os.path.join(dir, "expect.py"), args)) + print(" echo 'demo in %s failed'" % os.path.abspath(dir)) if not keepGoing: - print " exit 1" - print "fi" + print(" exit 1") + print("fi") else: - status = os.system('python "' + os.path.join(dir, "expect.py") + '" ' + args) + status = os.system(sys.executable + ' "' + os.path.join(dir, "expect.py") + '" ' + args) if status: if(num > 0): - print "[" + str(num) + "]", + sys.stdout.write("[" + str(num) + "] ") message = "demo in " + dir + " failed with exit status", status, - print message + print(message) if keepGoing == False: - print "exiting" + print("exiting") sys.exit(status) else: - print " ** Error logged and will be displayed again when suite is completed **" + print(" ** Error logged and will be displayed again when suite is completed **") demoErrors.append(message) - def run(demos, protobufDemos = [], root = False): def usage(): - print """usage: %s + print("""usage: %s --start=index Start running the demos at the given demo." --loop Run the demos in a loop." --filter=<regex> Run all the demos that match the given regex." @@ -352,10 +351,10 @@ def run(demos, protobufDemos = [], root = False): --script Generate a script to run the demos. --service-dir=<path> Directory to locate services for C++Builder/VC6. --env Dump the environment." - --noenv Do not automatically modify environment.""" % (sys.argv[0]) + --noenv Do not automatically modify environment.""" % (sys.argv[0])) sys.exit(2) - global keepGoing + global keepGoing try: opts, args = getopt.getopt(sys.argv[1:], "lr:R:", [ @@ -425,9 +424,9 @@ def run(demos, protobufDemos = [], root = False): runDemos(start, arg, demos, script = script, root = root) if len(demoErrors) > 0: - print "The following errors occurred:" + print("The following errors occurred:") for x in demoErrors: - print x + print(x) def guessBuildModeForDir(cwd): import glob @@ -450,7 +449,7 @@ def guessBuildMode(): if not iceHome and sourcedist: m = guessBuildModeForDir(os.path.join(toplevel, "cpp", "bin")) else: - m = guessBuildModeForDir(".") + m = guessBuildModeForDir(".") if m is None: raise RuntimeError("cannot guess debug or release mode") return m @@ -459,10 +458,10 @@ def isDebugBuild(): global buildmode # Guess the mode, if not set on the command line. if not isWin32(): - return False + return False if buildmode is None: - buildmode = guessBuildMode() - print "(guessed build mode %s)" % buildmode + buildmode = guessBuildMode() + print("(guessed build mode %s)" % buildmode) return buildmode == "debug" def getIceVersion(): @@ -486,7 +485,7 @@ def getIceBox(mapping = "cpp"): if isNoServices(): return os.path.join(getServiceDir(), "icebox.exe") if isWin32() and isDebugBuild(): - return "iceboxd" + return "iceboxd" return "icebox" elif mapping == "cs": if isMono(): # Mono cannot locate icebox in the PATH. @@ -533,7 +532,6 @@ def spawn(command, cwd = None, mapping = None): for arg in tokens[1:len(tokens)]: args += " " + arg - if defaultHost: command = '%s %s' % (command, defaultHost) args = '%s %s' % (args, defaultHost) @@ -553,7 +551,7 @@ def spawn(command, cwd = None, mapping = None): else: command = "./" + command elif mapping == "py": - command = "python -u " + command + command = sys.executable + " -u " + command elif mapping == "vb": command = "./" + command elif mapping == "java": @@ -572,7 +570,7 @@ def spawn(command, cwd = None, mapping = None): if isWin32(): # Under Win32 ./ does not work. command = command.replace("./", "") if debug: - print '(%s)' % (command) + print('(%s)' % (command)) return Expect.Expect(command, logfile = tracefile, desc = desc, mapping = mapping, cwd = cwd) def cleanDbDir(path): @@ -608,12 +606,12 @@ def addLdPath(libpath): def processCmdLine(): def usage(): - print "usage: " + sys.argv[0] + " --x64 --preferIPv4 --env --noenv --fast --trace=output --debug --host host --mode=[debug|release] --ice-home=<dir> --service-dir=<dir>" - sys.exit(2) + print("usage: " + sys.argv[0] + " --x64 --preferIPv4 --env --noenv --fast --trace=output --debug --host host --mode=[debug|release] --ice-home=<dir> --service-dir=<dir>") + sys.exit(2) try: - opts, args = getopt.getopt(sys.argv[1:], "", ["env", "noenv", "x64", "preferIPv4", "fast", "trace=", "debug", "host=", "mode=", "ice-home=", "--servicedir="]) + opts, args = getopt.getopt(sys.argv[1:], "", ["env", "noenv", "x64", "preferIPv4", "fast", "trace=", "debug", "host=", "mode=", "ice-home=", "--servicedir="]) except getopt.GetoptError: - usage() + usage() global fast global defaultHost @@ -635,38 +633,38 @@ def processCmdLine(): noenv = False for o, a in opts: - if o == "--debug": - debug = True - if o == "--trace": - if a == "stdout": - tracefile = sys.stdout - else: - tracefile = open(a, "w") - if o == "--host": - host = a - if o == "--env": - env = True - if o == "--noenv": - noenv = True - if o == "--fast": - fast = True - if o == "--x64": - x64 = True - if o == "--preferIPv4": - preferIPv4 = True + if o == "--debug": + debug = True + if o == "--trace": + if a == "stdout": + tracefile = sys.stdout + else: + tracefile = open(a, "w") + if o == "--host": + host = a + if o == "--env": + env = True + if o == "--noenv": + noenv = True + if o == "--fast": + fast = True + if o == "--x64": + x64 = True + if o == "--preferIPv4": + preferIPv4 = True if o == "--ice-home": iceHome = a if o == "--service-dir": serviceDir = a - if o == "--mode": - buildmode = a - if buildmode != 'debug' and buildmode != 'release': - usage() + if o == "--mode": + buildmode = a + if buildmode != 'debug' and buildmode != 'release': + usage() if host != "": - defaultHost = " --Ice.Default.Host=%s" % (host) + defaultHost = " --Ice.Default.Host=%s" % (host) else: - defaultHost = None + defaultHost = None if not iceHome and os.environ.get("USE_BIN_DIST", "no") == "yes" or os.environ.get("ICE_HOME", "") != "": if os.environ.get("ICE_HOME", "") != "": @@ -683,7 +681,7 @@ def processCmdLine(): dumpenv() if iceHome and isWin32() and not buildmode: - print "Error: please define --mode=debug or --mode=release" + print("Error: please define --mode=debug or --mode=release") sys.exit(1) import inspect diff --git a/demoscript/book/evictor_filesystem.py b/demoscript/book/evictor_filesystem.py index f7bb4b418eb..e7437477d66 100755 --- a/demoscript/book/evictor_filesystem.py +++ b/demoscript/book/evictor_filesystem.py @@ -11,7 +11,7 @@ import sys, signal def run(client, server): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.expect('>') client.sendline('pwd') @@ -133,4 +133,4 @@ def run(client, server): server.kill(signal.SIGINT) server.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/book/lifecycle.py b/demoscript/book/lifecycle.py index f7bb4b418eb..e7437477d66 100755 --- a/demoscript/book/lifecycle.py +++ b/demoscript/book/lifecycle.py @@ -11,7 +11,7 @@ import sys, signal def run(client, server): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.expect('>') client.sendline('pwd') @@ -133,4 +133,4 @@ def run(client, server): server.kill(signal.SIGINT) server.waitTestSuccess() - print "ok" + print("ok") diff --git a/demoscript/book/map_filesystem.py b/demoscript/book/map_filesystem.py index f7bb4b418eb..e7437477d66 100755 --- a/demoscript/book/map_filesystem.py +++ b/demoscript/book/map_filesystem.py @@ -11,7 +11,7 @@ import sys, signal def run(client, server): - print "testing...", + sys.stdout.write("testing... ") sys.stdout.flush() client.expect('>') client.sendline('pwd') @@ -133,4 +133,4 @@ def run(client, server): server.kill(signal.SIGINT) server.waitTestSuccess() - print "ok" + print("ok") diff --git a/java/allDemos.py b/java/allDemos.py index 2bde22c1d2a..c932bd4da5f 100755 --- a/java/allDemos.py +++ b/java/allDemos.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "demoscript")): break else: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(os.path.join(toplevel)) from demoscript import Util diff --git a/java/allTests.py b/java/allTests.py index bbc75544a32..4fcfb00b868 100755 --- a/java/allTests.py +++ b/java/allTests.py @@ -10,15 +10,16 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(toplevel)) -from scripts import * +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/java/demo/Freeze/bench/expect.py b/java/demo/Freeze/bench/expect.py index af460028ecd..a1ab4eddd16 100755 --- a/java/demo/Freeze/bench/expect.py +++ b/java/demo/Freeze/bench/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import bench -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") client = Util.spawn('java Client') bench.run(client, True) diff --git a/java/demo/Freeze/casino/expect.py b/java/demo/Freeze/casino/expect.py index 5d8c0264931..ad65259c972 100755 --- a/java/demo/Freeze/casino/expect.py +++ b/java/demo/Freeze/casino/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import casino casino.run('java Client', 'java Server') diff --git a/java/demo/Freeze/library/expect.py b/java/demo/Freeze/library/expect.py index 57d07e821b0..fe616da7bcd 100755 --- a/java/demo/Freeze/library/expect.py +++ b/java/demo/Freeze/library/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import library -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('.* ready') @@ -34,12 +34,12 @@ client.expect('>>> ') library.run(client, server) -print "running with collocated server" +print("running with collocated server") -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('>>> ') diff --git a/java/demo/Freeze/phonebook/expect.py b/java/demo/Freeze/phonebook/expect.py index c46b4cbc722..59bf8a58404 100755 --- a/java/demo/Freeze/phonebook/expect.py +++ b/java/demo/Freeze/phonebook/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import phonebook -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Server --Ice.PrintAdapterReady --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('.* ready') @@ -34,12 +34,12 @@ client.expect('>>> ') phonebook.run(client, server) -print "running with collocated server" +print("running with collocated server") -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Collocated --Freeze.Trace.Evictor=0 --Freeze.Trace.DbEnv=0') server.expect('>>> ') diff --git a/java/demo/Freeze/transform/expect.py b/java/demo/Freeze/transform/expect.py index 14d725b68a1..939c7746303 100755 --- a/java/demo/Freeze/transform/expect.py +++ b/java/demo/Freeze/transform/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Freeze import transform transform.run('java Create', 'java Recreate', 'java Read', 'java ReadNew') diff --git a/java/demo/Glacier2/callback/expect.py b/java/demo/Glacier2/callback/expect.py index 382fc8ec31f..2d68bec8e59 100755 --- a/java/demo/Glacier2/callback/expect.py +++ b/java/demo/Glacier2/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Glacier2 import callback server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/async/expect.py b/java/demo/Ice/async/expect.py index baa0ae25a0c..c5e4cf3357f 100755 --- a/java/demo/Ice/async/expect.py +++ b/java/demo/Ice/async/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import async server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/bidir/expect.py b/java/demo/Ice/bidir/expect.py index 16d8b8e9590..f5731570c69 100755 --- a/java/demo/Ice/bidir/expect.py +++ b/java/demo/Ice/bidir/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import bidir server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/callback/expect.py b/java/demo/Ice/callback/expect.py index 9ec3eb9aadf..a6d649e99b2 100755 --- a/java/demo/Ice/callback/expect.py +++ b/java/demo/Ice/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import callback server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/hello/expect.py b/java/demo/Ice/hello/expect.py index 9530e557b43..739538c7aeb 100755 --- a/java/demo/Ice/hello/expect.py +++ b/java/demo/Ice/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import hello server = Util.spawn('java Server --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/java/demo/Ice/invoke/expect.py b/java/demo/Ice/invoke/expect.py index e589427f420..18b75b32a0f 100755 --- a/java/demo/Ice/invoke/expect.py +++ b/java/demo/Ice/invoke/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import invoke server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/latency/expect.py b/java/demo/Ice/latency/expect.py index 95d316a5028..27e6a47e11d 100755 --- a/java/demo/Ice/latency/expect.py +++ b/java/demo/Ice/latency/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing ping... ", +sys.stdout.write("testing ping... ") sys.stdout.flush() client = Util.spawn('java Client') client.waitTestSuccess(timeout=100) -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess() -print client.before +print(client.before) diff --git a/java/demo/Ice/minimal/expect.py b/java/demo/Ice/minimal/expect.py index 2b4ed140c3f..87516d98575 100755 --- a/java/demo/Ice/minimal/expect.py +++ b/java/demo/Ice/minimal/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,20 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('java Client') client.waitTestSuccess() server.expect('Hello World!') -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess(-signal.SIGINT) diff --git a/java/demo/Ice/multicast/expect.py b/java/demo/Ice/multicast/expect.py index 8ea5eeefc5c..9d110c5bbee 100755 --- a/java/demo/Ice/multicast/expect.py +++ b/java/demo/Ice/multicast/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import multicast multicast.run('java Client', 'java Server') diff --git a/java/demo/Ice/nested/expect.py b/java/demo/Ice/nested/expect.py index db61db0dc5f..aa794c47bfa 100755 --- a/java/demo/Ice/nested/expect.py +++ b/java/demo/Ice/nested/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import nested server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/plugin/expect.py b/java/demo/Ice/plugin/expect.py index 13bc3e25fd0..c3aec76b956 100755 --- a/java/demo/Ice/plugin/expect.py +++ b/java/demo/Ice/plugin/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import plugin server = Util.spawn('java Server --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/java/demo/Ice/serialize/expect.py b/java/demo/Ice/serialize/expect.py index 78c9d42e285..76f88ed2885 100755 --- a/java/demo/Ice/serialize/expect.py +++ b/java/demo/Ice/serialize/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import serialize server = Util.spawn('java Server --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/java/demo/Ice/session/expect.py b/java/demo/Ice/session/expect.py index 778788f74c9..f1a6d02f024 100755 --- a/java/demo/Ice/session/expect.py +++ b/java/demo/Ice/session/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import session server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/throughput/expect.py b/java/demo/Ice/throughput/expect.py index 067af651d57..6bc12313685 100755 --- a/java/demo/Ice/throughput/expect.py +++ b/java/demo/Ice/throughput/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import throughput server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/Ice/value/expect.py b/java/demo/Ice/value/expect.py index 964dbb0f66e..2c7292af39d 100755 --- a/java/demo/Ice/value/expect.py +++ b/java/demo/Ice/value/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import value server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/IceBox/hello/expect.py b/java/demo/IceBox/hello/expect.py index cb6a4638b24..318c713b864 100755 --- a/java/demo/IceBox/hello/expect.py +++ b/java/demo/IceBox/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceBox import hello # Override the service load line. diff --git a/java/demo/IceGrid/icebox/expect.py b/java/demo/IceGrid/icebox/expect.py index c08b13a77bc..19a74ca2f47 100755 --- a/java/demo/IceGrid/icebox/expect.py +++ b/java/demo/IceGrid/icebox/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import icebox icebox.run('java Client') diff --git a/java/demo/IceGrid/simple/expect.py b/java/demo/IceGrid/simple/expect.py index 2b990944d05..4390cf4a0e0 100755 --- a/java/demo/IceGrid/simple/expect.py +++ b/java/demo/IceGrid/simple/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import simple simple.run('java Client') diff --git a/java/demo/IceStorm/clock/expect.py b/java/demo/IceStorm/clock/expect.py index 98cfc0f978c..8fd1422d20a 100755 --- a/java/demo/IceStorm/clock/expect.py +++ b/java/demo/IceStorm/clock/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceStorm import clock clock.run('java Subscriber', 'java Publisher') diff --git a/java/demo/book/evictor_filesystem/expect.py b/java/demo/book/evictor_filesystem/expect.py index 5915b407b27..4a6dcd0af06 100755 --- a/java/demo/book/evictor_filesystem/expect.py +++ b/java/demo/book/evictor_filesystem/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import evictor_filesystem -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') diff --git a/java/demo/book/lifecycle/expect.py b/java/demo/book/lifecycle/expect.py index 832dadac6ee..9bd197db805 100755 --- a/java/demo/book/lifecycle/expect.py +++ b/java/demo/book/lifecycle/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import lifecycle server = Util.spawn('java Server --Ice.PrintAdapterReady') diff --git a/java/demo/book/map_filesystem/expect.py b/java/demo/book/map_filesystem/expect.py index c78a186d65c..ed3e13a0a65 100755 --- a/java/demo/book/map_filesystem/expect.py +++ b/java/demo/book/map_filesystem/expect.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.book import map_filesystem -print "cleaning databases...", +sys.stdout.write("cleaning databases... ") sys.stdout.flush() Util.cleanDbDir("db") -print "ok" +print("ok") server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') diff --git a/java/demo/book/printer/expect.py b/java/demo/book/printer/expect.py index d08e5413ca5..987016ddc2f 100755 --- a/java/demo/book/printer/expect.py +++ b/java/demo/book/printer/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('java Client') client.waitTestSuccess() server.expect('Hello World!') server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/java/demo/book/simple_filesystem/expect.py b/java/demo/book/simple_filesystem/expect.py index 0465e2a8d9e..21e631c420a 100755 --- a/java/demo/book/simple_filesystem/expect.py +++ b/java/demo/book/simple_filesystem/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('java Server --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('java Client') client.expect('Contents of root directory:\n.*Down to a sunless sea.') client.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/java/test/Freeze/complex/run.py b/java/test/Freeze/complex/run.py index 672da20e992..d06d6dbc98b 100755 --- a/java/test/Freeze/complex/run.py +++ b/java/test/Freeze/complex/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # Clean the contents of the database directory. @@ -26,17 +26,19 @@ from scripts import * dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) -print "starting populate...", +sys.stdout.write("starting populate... ") +sys.stdout.flush() populateProc = TestUtil.startClient("test.Freeze.complex.Client", ' --dbdir "%s" populate' % os.getcwd(), startReader=False) -print "ok" +print("ok") populateProc.startReader() populateProc.waitTestSuccess() -print "starting verification client...", +sys.stdout.write("starting verification client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Freeze.complex.Client", ' --dbdir "%s" validate' % os.getcwd(), startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/java/test/Freeze/dbmap/run.py b/java/test/Freeze/dbmap/run.py index 8e5806fef86..57180532419 100755 --- a/java/test/Freeze/dbmap/run.py +++ b/java/test/Freeze/dbmap/run.py @@ -16,16 +16,16 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Freeze.dbmap.Client", '"' + os.getcwd() + '"', startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Freeze/evictor/run.py b/java/test/Freeze/evictor/run.py index 4813d2a4c49..0cb0f32d190 100755 --- a/java/test/Freeze/evictor/run.py +++ b/java/test/Freeze/evictor/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) @@ -26,4 +26,3 @@ TestUtil.cleanDbDir(dbdir) testOptions = ' --Freeze.Warn.Deadlocks=0 --Freeze.DbEnv.db.DbHome="%s/db" --Ice.Config="%s/config" ' % (os.getcwd(), os.getcwd()) TestUtil.clientServerTest(testOptions, testOptions) - diff --git a/java/test/Freeze/fileLock/run.py b/java/test/Freeze/fileLock/run.py index 8448cc3c6d0..0121ec0c704 100755 --- a/java/test/Freeze/fileLock/run.py +++ b/java/test/Freeze/fileLock/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil dbdir = os.path.join(os.getcwd(), "db") TestUtil.cleanDbDir(dbdir) -print "testing Freeze file lock...", +sys.stdout.write("testing Freeze file lock... ") sys.stdout.flush() client = os.path.join("test.Freeze.fileLock.Client") @@ -47,4 +47,4 @@ clientExe.expect('File lock acquired.\.*') clientExe.sendline('go') clientExe.expect('File lock released.') clientExe.wait() -print "ok" +print("ok") diff --git a/java/test/Glacier2/router/run.py b/java/test/Glacier2/router/run.py index df341eb8ffd..ce9a539e07d 100755 --- a/java/test/Glacier2/router/run.py +++ b/java/test/Glacier2/router/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = os.path.join(TestUtil.getCppBinDir(), "glacier2router") @@ -33,15 +33,15 @@ args = ' --Ice.Warn.Dispatch=0' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() routerConfig = TestUtil.DriverConfig("server") routerConfig.lang = "cpp" starterProc = TestUtil.startServer(router, args, count=2, config=routerConfig) -print "ok" +print("ok") TestUtil.clientServerTest() TestUtil.clientServerTest(additionalClientOptions=" --shutdown") starterProc.waitTestSuccess() - diff --git a/java/test/Glacier2/sessionHelper/run.py b/java/test/Glacier2/sessionHelper/run.py index 14f5444fa0a..2c78cc668c4 100755 --- a/java/test/Glacier2/sessionHelper/run.py +++ b/java/test/Glacier2/sessionHelper/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil router = os.path.join(TestUtil.getCppBinDir(), "glacier2router") @@ -31,15 +31,13 @@ args = ' --Ice.Warn.Dispatch=0' + \ ' --Ice.Admin.InstanceName=Glacier2' + \ ' --Glacier2.CryptPasswords="' + os.path.join(os.getcwd(), "passwords") + '"' -print "starting router...", +sys.stdout.write("starting router... ") +sys.stdout.flush() routerConfig = TestUtil.DriverConfig("server") routerConfig.lang = "cpp" starterProc = TestUtil.startServer(router, args, count=2, config=routerConfig) -print "ok" - - +print("ok") TestUtil.clientServerTest(additionalClientOptions=" --shutdown") starterProc.waitTestSuccess() - diff --git a/java/test/Ice/adapterDeactivation/run.py b/java/test/Ice/adapterDeactivation/run.py index 099ce110107..db68ff30b9a 100755 --- a/java/test/Ice/adapterDeactivation/run.py +++ b/java/test/Ice/adapterDeactivation/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/java/test/Ice/ami/run.py b/java/test/Ice/ami/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/ami/run.py +++ b/java/test/Ice/ami/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/background/run.py b/java/test/Ice/background/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/background/run.py +++ b/java/test/Ice/background/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/binding/run.py b/java/test/Ice/binding/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/binding/run.py +++ b/java/test/Ice/binding/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/checksum/run.py b/java/test/Ice/checksum/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/checksum/run.py +++ b/java/test/Ice/checksum/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/classLoader/run.py b/java/test/Ice/classLoader/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/classLoader/run.py +++ b/java/test/Ice/classLoader/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/custom/run.py b/java/test/Ice/custom/run.py index 099ce110107..db68ff30b9a 100755 --- a/java/test/Ice/custom/run.py +++ b/java/test/Ice/custom/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/java/test/Ice/defaultServant/run.py b/java/test/Ice/defaultServant/run.py index 78c568f8ddd..72d65e04f4a 100755 --- a/java/test/Ice/defaultServant/run.py +++ b/java/test/Ice/defaultServant/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.defaultServant.Client", "--Ice.Warn.Dispatch=0",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Ice/defaultValue/run.py b/java/test/Ice/defaultValue/run.py index 71cec9ec06a..c073e0a10f0 100755 --- a/java/test/Ice/defaultValue/run.py +++ b/java/test/Ice/defaultValue/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.defaultValue.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Ice/dispatcher/run.py b/java/test/Ice/dispatcher/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/dispatcher/run.py +++ b/java/test/Ice/dispatcher/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/exceptions/run.py b/java/test/Ice/exceptions/run.py index 0aa6485e573..080cf30b986 100755 --- a/java/test/Ice/exceptions/run.py +++ b/java/test/Ice/exceptions/run.py @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.exceptions.AMDServer") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/java/test/Ice/facets/run.py b/java/test/Ice/facets/run.py index 099ce110107..db68ff30b9a 100755 --- a/java/test/Ice/facets/run.py +++ b/java/test/Ice/facets/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/java/test/Ice/faultTolerance/run.py b/java/test/Ice/faultTolerance/run.py index 06457bf6fe0..a81a2c3e939 100755 --- a/java/test/Ice/faultTolerance/run.py +++ b/java/test/Ice/faultTolerance/run.py @@ -16,28 +16,29 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil num = 12 base = 12340 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer("test.Ice.faultTolerance.Server", " %d" % (base + i))) - print "ok" + print("ok") ports = "" for i in range(0, num): ports = "%s %d" % (ports, base + i) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.faultTolerance.Client", ports, startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/java/test/Ice/hold/run.py b/java/test/Ice/hold/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/hold/run.py +++ b/java/test/Ice/hold/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/info/run.py b/java/test/Ice/info/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/info/run.py +++ b/java/test/Ice/info/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/inheritance/run.py b/java/test/Ice/inheritance/run.py index 099ce110107..db68ff30b9a 100755 --- a/java/test/Ice/inheritance/run.py +++ b/java/test/Ice/inheritance/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/java/test/Ice/interceptor/run.py b/java/test/Ice/interceptor/run.py index cf3f6470343..4b5670757ee 100755 --- a/java/test/Ice/interceptor/run.py +++ b/java/test/Ice/interceptor/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.interceptor.Client", "--Ice.Warn.Dispatch=0",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Ice/invoke/run.py b/java/test/Ice/invoke/run.py index bcb78f3c4f3..caf7ed893df 100755 --- a/java/test/Ice/invoke/run.py +++ b/java/test/Ice/invoke/run.py @@ -16,13 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with Blobject server." +print("tests with Blobject server.") TestUtil.clientServerTest() -print "tests with BlobjectAsync server." +print("tests with BlobjectAsync server.") TestUtil.clientServerTest(additionalServerOptions = "--async") - diff --git a/java/test/Ice/location/run.py b/java/test/Ice/location/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/location/run.py +++ b/java/test/Ice/location/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/objects/run.py b/java/test/Ice/objects/run.py index 099ce110107..db68ff30b9a 100755 --- a/java/test/Ice/objects/run.py +++ b/java/test/Ice/objects/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/java/test/Ice/operations/run.py b/java/test/Ice/operations/run.py index 10c33f9c66b..3f51c03c0de 100755 --- a/java/test/Ice/operations/run.py +++ b/java/test/Ice/operations/run.py @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0") -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="test.Ice.operations.AMDServer") -print "tests with TIE server." +print("tests with TIE server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="test.Ice.operations.TieServer") -print "tests with AMD TIE server." +print("tests with AMD TIE server.") TestUtil.clientServerTest(additionalClientOptions = "--Ice.Warn.AMICallback=0", server="test.Ice.operations.AMDTieServer") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/java/test/Ice/packagemd/run.py b/java/test/Ice/packagemd/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/packagemd/run.py +++ b/java/test/Ice/packagemd/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/properties/run.py b/java/test/Ice/properties/run.py index 22f2a9903a9..92ff1bec700 100755 --- a/java/test/Ice/properties/run.py +++ b/java/test/Ice/properties/run.py @@ -17,25 +17,35 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # Write config # -configPath = u"./config/ä¸å›½_client.config" +if sys.version_info[0] == 2: + configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config".decode("utf-8") + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=./config/ä¸å›½_client.config"]) +else: + configPath = "./config/\u4e2d\u56fd_client.config" + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") -TestUtil.createConfig(configPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=./config/ä¸å›½_client.config"]) - -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.properties.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/java/test/Ice/proxy/run.py b/java/test/Ice/proxy/run.py index 742a256e68c..a4da3548a63 100755 --- a/java/test/Ice/proxy/run.py +++ b/java/test/Ice/proxy/run.py @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.proxy.AMDServer") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/java/test/Ice/retry/run.py b/java/test/Ice/retry/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/retry/run.py +++ b/java/test/Ice/retry/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/seqMapping/run.py b/java/test/Ice/seqMapping/run.py index a9017505f52..9d2dbfdf699 100755 --- a/java/test/Ice/seqMapping/run.py +++ b/java/test/Ice/seqMapping/run.py @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.seqMapping.AMDServer") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/java/test/Ice/serialize/run.py b/java/test/Ice/serialize/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/serialize/run.py +++ b/java/test/Ice/serialize/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/servantLocator/run.py b/java/test/Ice/servantLocator/run.py index 9bf24af74b3..aa2889a3e6b 100755 --- a/java/test/Ice/servantLocator/run.py +++ b/java/test/Ice/servantLocator/run.py @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.servantLocator.AMDServer") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/java/test/Ice/slicing/exceptions/run.py b/java/test/Ice/slicing/exceptions/run.py index 0409073e4fb..3d91ae5b336 100755 --- a/java/test/Ice/slicing/exceptions/run.py +++ b/java/test/Ice/slicing/exceptions/run.py @@ -16,13 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.slicing.exceptions.AMDServer") - diff --git a/java/test/Ice/slicing/objects/run.py b/java/test/Ice/slicing/objects/run.py index 85faac8212b..dd4af53b34f 100755 --- a/java/test/Ice/slicing/objects/run.py +++ b/java/test/Ice/slicing/objects/run.py @@ -16,13 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="test.Ice.slicing.objects.AMDServer") - diff --git a/java/test/Ice/stream/run.py b/java/test/Ice/stream/run.py index 46f0307572a..e8d941801d9 100755 --- a/java/test/Ice/stream/run.py +++ b/java/test/Ice/stream/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting test...", +sys.stdout.write("starting test... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.stream.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Ice/threadPoolPriority/run.py b/java/test/Ice/threadPoolPriority/run.py index 17cfc7c7b27..0c8b131318e 100755 --- a/java/test/Ice/threadPoolPriority/run.py +++ b/java/test/Ice/threadPoolPriority/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() - diff --git a/java/test/Ice/timeout/run.py b/java/test/Ice/timeout/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/java/test/Ice/timeout/run.py +++ b/java/test/Ice/timeout/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/java/test/Ice/udp/run.py b/java/test/Ice/udp/run.py index 8c1170071ad..f6db622ae1e 100755 --- a/java/test/Ice/udp/run.py +++ b/java/test/Ice/udp/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.addClasspath(os.path.join(os.getcwd(), "classes")) @@ -26,16 +26,17 @@ num = 5 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) + sys.stdout.flush() serverProc.append(TestUtil.startServer("test.Ice.udp.Server", "%d" % i , adapter="McastTestAdapter")) - print "ok" + print("ok") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Ice.udp.Client", "%d" % num, startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/java/test/IceBox/configuration/run.py b/java/test/IceBox/configuration/run.py index 7d638eb15c6..3786f2add8a 100755 --- a/java/test/IceBox/configuration/run.py +++ b/java/test/IceBox/configuration/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest(additionalServerOptions='--Ice.Config="%s"' % os.path.join(os.getcwd(), "config.icebox"), server=TestUtil.getIceBox()) TestUtil.clientServerTest(additionalServerOptions='--Ice.Config="%s"' % os.path.join(os.getcwd(), "config.icebox2"), server=TestUtil.getIceBox()) - diff --git a/java/test/IceGrid/simple/run.py b/java/test/IceGrid/simple/run.py index 568bbe5fa53..c0e31578fda 100755 --- a/java/test/IceGrid/simple/run.py +++ b/java/test/IceGrid/simple/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil, IceGridAdmin # # Test client/server without on demand activation. @@ -29,4 +29,3 @@ IceGridAdmin.iceGridClientServerTest("", "--TestAdapter.Endpoints=default --Test # Test client/server with on demand activation. # IceGridAdmin.iceGridTest("simple_server.xml", "--with-deploy") - diff --git a/java/test/IceSSL/configuration/run.py b/java/test/IceSSL/configuration/run.py index 81b828550ca..2af641e3027 100755 --- a/java/test/IceSSL/configuration/run.py +++ b/java/test/IceSSL/configuration/run.py @@ -16,11 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = '"%s"' % os.getcwd() TestUtil.clientServerTest(additionalClientOptions=testdir) - diff --git a/java/test/IceUtil/fileLock/run.py b/java/test/IceUtil/fileLock/run.py index 0066678ae60..05ac6b54492 100755 --- a/java/test/IceUtil/fileLock/run.py +++ b/java/test/IceUtil/fileLock/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil - -print "testing process file lock...", +sys.stdout.write("testing process file lock... ") sys.stdout.flush() client = os.path.join("test.IceUtil.fileLock.Client") @@ -56,5 +55,4 @@ clientExe.sendline('go') clientExe.expect('File lock released.') clientExe.wait() -print "ok" - +print("ok") diff --git a/java/test/IceUtil/inputUtil/run.py b/java/test/IceUtil/inputUtil/run.py index 6042580714e..ab22ebfef67 100755 --- a/java/test/IceUtil/inputUtil/run.py +++ b/java/test/IceUtil/inputUtil/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.IceUtil.inputUtil.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Slice/generation/run.py b/java/test/Slice/generation/run.py index d7cf9c52d2d..4d77c036b02 100755 --- a/java/test/Slice/generation/run.py +++ b/java/test/Slice/generation/run.py @@ -16,11 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel os.getcwd()!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel os.getcwd()!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "testing list-generated...", +sys.stdout.write("testing list-generated... ") +sys.stdout.flush() slice2java = os.path.join(TestUtil.getCppBinDir(), "slice2java") if not os.path.exists("classes"): @@ -28,23 +29,27 @@ if not os.path.exists("classes"): command = '"' + slice2java + '" --list-generated --output-dir classes File1.ice File2.ice' if TestUtil.debug: - print "(%s)" % command, + sys.stdout.write("(%s) " % command) p = TestUtil.runCommand(command) lines1 = p.stdout.readlines() lines2 = open(os.path.join(os.getcwd(), "list-generated.out"), "r").readlines() if len(lines1) != len(lines2): - print "failed!" + print("failed!") sys.exit(1) i = 0 while i < len(lines1): - line1 = lines1[i].strip() - line2 = lines2[i].strip() + if sys.version_info[0] == 2: + line1 = lines1[i].strip() + line2 = lines2[i].strip() + else: + line1 = lines1[i].decode("utf-8").strip() + line2 = lines2[i].strip() if line1 != line2: - print "failed!" + print("failed!") sys.exit(1) i = i + 1 else: - print "ok" + print("ok") sys.exit(0) diff --git a/java/test/Slice/keyword/run.py b/java/test/Slice/keyword/run.py index 74cd2954e11..1ea2a4eb6c1 100755 --- a/java/test/Slice/keyword/run.py +++ b/java/test/Slice/keyword/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Slice.keyword.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/java/test/Slice/structure/run.py b/java/test/Slice/structure/run.py index 4844d7a436c..99027de6ecf 100755 --- a/java/test/Slice/structure/run.py +++ b/java/test/Slice/structure/run.py @@ -16,12 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("test.Slice.structure.Client",startReader=False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/php/allTests.py b/php/allTests.py index c8e40b6ecb9..615ebe8ed6d 100755 --- a/php/allTests.py +++ b/php/allTests.py @@ -10,15 +10,16 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.normpath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(toplevel)) -from scripts import * +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/php/test/Ice/binding/run.py b/php/test/Ice/binding/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/php/test/Ice/binding/run.py +++ b/php/test/Ice/binding/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/checksum/run.py b/php/test/Ice/checksum/run.py index bdd5c1a3b99..c3224efcb6d 100755 --- a/php/test/Ice/checksum/run.py +++ b/php/test/Ice/checksum/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest(server='server/server') - diff --git a/php/test/Ice/defaultValue/run.py b/php/test/Ice/defaultValue/run.py index 66e12afbf73..39356ecb4cd 100755 --- a/php/test/Ice/defaultValue/run.py +++ b/php/test/Ice/defaultValue/run.py @@ -16,16 +16,17 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() client = os.path.join(testdir, "Client.php") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/php/test/Ice/exceptions/run.py b/php/test/Ice/exceptions/run.py index f8d6e35badc..c20334547f3 100755 --- a/php/test/Ice/exceptions/run.py +++ b/php/test/Ice/exceptions/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") - diff --git a/php/test/Ice/facets/run.py b/php/test/Ice/facets/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/php/test/Ice/facets/run.py +++ b/php/test/Ice/facets/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/info/run.py b/php/test/Ice/info/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/php/test/Ice/info/run.py +++ b/php/test/Ice/info/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/inheritance/run.py b/php/test/Ice/inheritance/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/php/test/Ice/inheritance/run.py +++ b/php/test/Ice/inheritance/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/ini/run.py b/php/test/Ice/ini/run.py index 17b2e0920c0..dd13b07789e 100755 --- a/php/test/Ice/ini/run.py +++ b/php/test/Ice/ini/run.py @@ -16,24 +16,24 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) - -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() client = os.path.join(testdir, "Client.php") -print "testing php INI settings...", +sys.stdout.write("testing php INI settings... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False, clientConfig = True, iceOptions = "--Ice.Trace.Network=1 --Ice.Warn.Connections=1") clientProc.startReader() clientProc.waitTestSuccess() -print "ok" - +print("ok") client = os.path.join(testdir, "ClientWithProfile.php") -print "testing php INI settings with profiles...", +sys.stdout.write("testing php INI settings with profiles... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False, clientConfig = True, iceOptions = "--Ice.Trace.Network=1 --Ice.Warn.Connections=1", iceProfile="Test") clientProc.startReader() clientProc.waitTestSuccess() -print "ok" +print("ok") diff --git a/php/test/Ice/objects/run.py b/php/test/Ice/objects/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/php/test/Ice/objects/run.py +++ b/php/test/Ice/objects/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/operations/run.py b/php/test/Ice/operations/run.py index f8d6e35badc..c20334547f3 100755 --- a/php/test/Ice/operations/run.py +++ b/php/test/Ice/operations/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") - diff --git a/php/test/Ice/proxy/run.py b/php/test/Ice/proxy/run.py index f8d6e35badc..c20334547f3 100755 --- a/php/test/Ice/proxy/run.py +++ b/php/test/Ice/proxy/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") - diff --git a/php/test/Ice/scope/run.py b/php/test/Ice/scope/run.py index 8a1986a2fe2..802b57f8f42 100755 --- a/php/test/Ice/scope/run.py +++ b/php/test/Ice/scope/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) - -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() diff --git a/php/test/Ice/slicing/exceptions/run.py b/php/test/Ice/slicing/exceptions/run.py index 04d6ba71ed6..6c214c5f45d 100755 --- a/php/test/Ice/slicing/exceptions/run.py +++ b/php/test/Ice/slicing/exceptions/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Ice/slicing/objects/run.py b/php/test/Ice/slicing/objects/run.py index 04d6ba71ed6..6c214c5f45d 100755 --- a/php/test/Ice/slicing/objects/run.py +++ b/php/test/Ice/slicing/objects/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/php/test/Slice/keyword/run.py b/php/test/Slice/keyword/run.py index e6463037467..39356ecb4cd 100755 --- a/php/test/Slice/keyword/run.py +++ b/php/test/Slice/keyword/run.py @@ -16,17 +16,17 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() client = os.path.join(testdir, "Client.php") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/php/test/Slice/structure/run.py b/php/test/Slice/structure/run.py index e6463037467..39356ecb4cd 100755 --- a/php/test/Slice/structure/run.py +++ b/php/test/Slice/structure/run.py @@ -16,17 +16,17 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil testdir = os.getcwd() client = os.path.join(testdir, "Client.php") -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/py/allDemos.py b/py/allDemos.py index 1a48f615ac7..16704586aa7 100755 --- a/py/allDemos.py +++ b/py/allDemos.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "demoscript")): break else: - raise "can't find toplevel directory!" + raise RutimeError("can't find toplevel directory!") sys.path.append(os.path.join(toplevel)) from demoscript import Util diff --git a/py/allTests.py b/py/allTests.py index ce7e46276d3..90707542ac5 100755 --- a/py/allTests.py +++ b/py/allTests.py @@ -10,15 +10,15 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" - -sys.path.append(os.path.join(toplevel)) -from scripts import * +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/py/config/Make.rules.mak b/py/config/Make.rules.mak index 29ae83b3bff..b67722477e2 100644 --- a/py/config/Make.rules.mak +++ b/py/config/Make.rules.mak @@ -33,7 +33,7 @@ CPP_COMPILER = VC90 # Set PYTHON_HOME to your Python installation directory.
#
!if "$(PYTHON_HOME)" == ""
-PYTHON_HOME = C:\Python26
+PYTHON_HOME = C:\Python32
!endif
#
diff --git a/py/demo/Glacier2/callback/Client.py b/py/demo/Glacier2/callback/Client.py index 93434ecee63..3ffb09dceba 100755 --- a/py/demo/Glacier2/callback/Client.py +++ b/py/demo/Glacier2/callback/Client.py @@ -13,7 +13,7 @@ Ice.loadSlice('Callback.ice') import Demo def menu(): - print """ + print(""" usage: t: send callback as twoway o: send callback as oneway @@ -25,31 +25,35 @@ s: shutdown server r: restart the session x: exit ?: help -""" +""") class CallbackReceiverI(Demo.CallbackReceiver): def callback(self, current=None): - print "received callback" + print("received callback") class Client(Glacier2.Application): def createSession(self): session = None while True: - print "This demo accepts any user-id / password combination." - id = raw_input("user id: ") - pw = raw_input("password: ") + print("This demo accepts any user-id / password combination.") + sys.stdout.write("user id: ") + sys.stdout.flush() + id = sys.stdin.readline().strip() + sys.stdout.write("password: ") + sys.stdout.flush() + pw = sys.stdin.readline().strip() try: session = self.router().createSession(id, pw) break - except Glacier2.PermissionDeniedException, ex: - print "permission denied:\n" + ex.reason - except Glacier2.CannotCreateSessionException, ex: - print "cannot create session:\n" + ex.reason + except Glacier2.PermissionDeniedException as ex: + print("permission denied:\n" + ex.reason) + except Glacier2.CannotCreateSessionException as ex: + print("cannot create session:\n" + ex.reason) return session def runWithSession(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 callbackReceiverIdent = self.createCallbackIdentity("callbackReceiver") @@ -79,7 +83,9 @@ class Client(Glacier2.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 't': context = {} context["_fwd"] = "t" @@ -103,10 +109,10 @@ class Client(Glacier2.Application): elif c == 'v': if len(override) == 0: override = "some_value" - print "override context field is now `" + override + "'" + print("override context field is now `" + override + "'") else: override = '' - print "override context field is empty" + print("override context field is empty") elif c == 'F': fake = not fake @@ -125,7 +131,7 @@ class Client(Glacier2.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except KeyboardInterrupt: break diff --git a/py/demo/Glacier2/callback/Server.py b/py/demo/Glacier2/callback/Server.py index 1ad915750ec..0c43c3f80a6 100755 --- a/py/demo/Glacier2/callback/Server.py +++ b/py/demo/Glacier2/callback/Server.py @@ -15,20 +15,20 @@ import Demo class CallbackI(Demo.Callback): def initiateCallback(self, proxy, current=None): - print "initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy) + print("initiating callback to: " + current.adapter.getCommunicator().proxyToString(proxy)) try: proxy.callback() except: traceback.print_exc() def shutdown(self, current=None): - print "shutting down..." + print("shutting down...") current.adapter.getCommunicator().shutdown() class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Callback.Server") diff --git a/py/demo/Glacier2/callback/expect.py b/py/demo/Glacier2/callback/expect.py index 30c5774ccb1..b36b80d1bc6 100755 --- a/py/demo/Glacier2/callback/expect.py +++ b/py/demo/Glacier2/callback/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(path[0]) + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0])) -from demoscript import * +from demoscript import Util from demoscript.Glacier2 import callback server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/async/Client.py b/py/demo/Ice/async/Client.py index 06a654a9613..f41fe3bc32c 100755 --- a/py/demo/Ice/async/Client.py +++ b/py/demo/Ice/async/Client.py @@ -19,30 +19,30 @@ class Callback: def exception(self, ex): if isinstance(ex, Demo.RequestCanceledException): - print "Demo.RequestCanceledException" + print("Demo.RequestCanceledException") else: - print "sayHello AMI call failed:" - print ex + print("sayHello AMI call failed:") + print(ex) def menu(): - print """ + print(""" usage: i: send immediate greeting d: send delayed greeting s: shutdown server x: exit ?: help -""" +""") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 hello = Demo.HelloPrx.checkedCast(self.communicator().propertyToProxy('Hello.Proxy')) if not hello: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 menu() @@ -50,7 +50,9 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 'i': hello.sayHello(0) elif c == 'd': @@ -63,14 +65,14 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except EOFError: break except KeyboardInterrupt: break - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) return 0 diff --git a/py/demo/Ice/async/Server.py b/py/demo/Ice/async/Server.py index e1458be5d6f..fc011c0a1b8 100755 --- a/py/demo/Ice/async/Server.py +++ b/py/demo/Ice/async/Server.py @@ -37,7 +37,7 @@ class WorkQueue(threading.Thread): self._cond.wait(self._callbacks[0].delay / 1000.0) if not self._done: - print "Belated Hello World!" + print("Belated Hello World!") self._callbacks[0].cb.ice_response() del self._callbacks[0] @@ -75,7 +75,7 @@ class HelloI(Demo.Hello): def sayHello_async(self, cb, delay, current=None): if delay == 0: - print "Hello World!" + print("Hello World!") cb.ice_response() else: self._workQueue.add(cb, delay) @@ -87,7 +87,7 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 self.callbackOnInterrupt() diff --git a/py/demo/Ice/async/expect.py b/py/demo/Ice/async/expect.py index 3eda015ea73..082b998d0c3 100755 --- a/py/demo/Ice/async/expect.py +++ b/py/demo/Ice/async/expect.py @@ -16,10 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) +sys.path.append(os.path.join(path[0], "scripts")) -from demoscript import * +from demoscript import Util from demoscript.Ice import async server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/bidir/Client.py b/py/demo/Ice/bidir/Client.py index 9f54cc3a186..601b77e31f1 100755 --- a/py/demo/Ice/bidir/Client.py +++ b/py/demo/Ice/bidir/Client.py @@ -12,7 +12,7 @@ import os, sys, Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Callback.ice") @@ -20,17 +20,17 @@ import Demo class CallbackReceiverI(Demo.CallbackReceiver): def callback(self, num, current=None): - print "received callback #" + str(num) + print("received callback #" + str(num)) class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 server = Demo.CallbackSenderPrx.checkedCast(self.communicator().propertyToProxy('CallbackSender.Proxy')) if not server: - print self.appName() + ": invalid proxy" + print(self.appName() + ": invalid proxy") return 1 adapter = self.communicator().createObjectAdapter("") @@ -43,7 +43,6 @@ class Client(Ice.Application): server.addClient(ident) self.communicator().waitForShutdown() - print "here" return 0 app = Client() diff --git a/py/demo/Ice/bidir/Server.py b/py/demo/Ice/bidir/Server.py index 065585a1e8e..6b2e7fc38a4 100755 --- a/py/demo/Ice/bidir/Server.py +++ b/py/demo/Ice/bidir/Server.py @@ -12,7 +12,7 @@ import os, sys, traceback, threading, Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Callback.ice") @@ -29,7 +29,7 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): def destroy(self): self._cond.acquire() - print "destroying callback sender" + print("destroying callback sender") self._destroy = True try: @@ -42,7 +42,7 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): def addClient(self, ident, current=None): self._cond.acquire() - print "adding client `" + self._communicator.identityToString(ident) + "'" + print("adding client `" + self._communicator.identityToString(ident) + "'") client = Demo.CallbackReceiverPrx.uncheckedCast(current.con.createProxy(ident)) self._clients.append(client) @@ -65,12 +65,12 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): if len(clients) > 0: num = num + 1 - + for p in clients: try: p.callback(num) except: - print "removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':" + print("removing client `" + self._communicator.identityToString(p.ice_getIdentity()) + "':") traceback.print_exc() self._cond.acquire() @@ -79,11 +79,10 @@ class CallbackSenderI(Demo.CallbackSender, threading.Thread): finally: self._cond.release() - class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Callback.Server") diff --git a/py/demo/Ice/bidir/expect.py b/py/demo/Ice/bidir/expect.py index e9afa31351f..9d9b23aad86 100755 --- a/py/demo/Ice/bidir/expect.py +++ b/py/demo/Ice/bidir/expect.py @@ -16,10 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) +sys.path.append(os.path.join(path[0], "scripts")) -from demoscript import * +from demoscript import Util from demoscript.Ice import bidir server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/callback/Client.py b/py/demo/Ice/callback/Client.py index 6b8f2a3e403..be583c01edc 100755 --- a/py/demo/Ice/callback/Client.py +++ b/py/demo/Ice/callback/Client.py @@ -14,29 +14,29 @@ Ice.loadSlice('Callback.ice') import Demo def menu(): - print """ + print(""" usage: t: send callback s: shutdown server x: exit ?: help -""" +""") class CallbackReceiverI(Demo.CallbackReceiver): def callback(self, current=None): - print "received callback" + print("received callback") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 sender = Demo.CallbackSenderPrx.checkedCast( self.communicator().propertyToProxy('CallbackSender.Proxy'). ice_twoway().ice_timeout(-1).ice_secure(False)) if not sender: - print self.appName() + ": invalid proxy" + print(self.appName() + ": invalid proxy") return 1 adapter = self.communicator().createObjectAdapter("Callback.Client") @@ -51,7 +51,9 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 't': sender.initiateCallback(receiver) elif c == 's': @@ -61,7 +63,7 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except EOFError: break diff --git a/py/demo/Ice/callback/Server.py b/py/demo/Ice/callback/Server.py index f6e1cdac6aa..eeae0e9f03e 100755 --- a/py/demo/Ice/callback/Server.py +++ b/py/demo/Ice/callback/Server.py @@ -15,14 +15,14 @@ import Demo class CallbackSenderI(Demo.CallbackSender): def initiateCallback(self, proxy, current=None): - print "initiating callback" + print("initiating callback") try: proxy.callback() except: traceback.print_exc() def shutdown(self, current=None): - print "Shutting down..." + print("Shutting down...") try: current.adapter.getCommunicator().shutdown() except: @@ -31,7 +31,7 @@ class CallbackSenderI(Demo.CallbackSender): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Callback.Server") diff --git a/py/demo/Ice/callback/expect.py b/py/demo/Ice/callback/expect.py index d988294f9e1..ee73df8b7f4 100755 --- a/py/demo/Ice/callback/expect.py +++ b/py/demo/Ice/callback/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import callback server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/converter/Client.py b/py/demo/Ice/converter/Client.py index 252b63a2f38..059cdaf12f3 100755 --- a/py/demo/Ice/converter/Client.py +++ b/py/demo/Ice/converter/Client.py @@ -14,14 +14,14 @@ Ice.loadSlice('Greet.ice') import Demo def menu(): - print """ + print(""" usage: t: send greeting with conversion u: send greeting without conversion s: shutdown server x: exit ?: help -""" +""") def decodeString(str): ret = "" @@ -39,17 +39,17 @@ communicator2 = None class Client: def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 greet1 = Demo.GreetPrx.checkedCast(communicator1.propertyToProxy('Greet.Proxy')) if not greet1: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 greet2 = Demo.GreetPrx.checkedCast(communicator2.propertyToProxy('Greet.Proxy')) if not greet2: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 menu() @@ -59,13 +59,15 @@ class Client: c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 't': ret = greet1.exchangeGreeting(greeting) - print "Received: \"" + decodeString(ret) + "\"" + print("Received: \"" + decodeString(ret) + "\"") elif c == 'u': ret = greet2.exchangeGreeting(greeting) - print "Received: \"" + decodeString(ret) + "\"" + print("Received: \"" + decodeString(ret) + "\"") elif c == 's': greet1.shutdown() elif c == 'x': @@ -73,14 +75,14 @@ class Client: elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except KeyboardInterrupt: break except EOFError: break - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) return 0 diff --git a/py/demo/Ice/converter/Server.py b/py/demo/Ice/converter/Server.py index f105e8b4dfa..160ea560484 100755 --- a/py/demo/Ice/converter/Server.py +++ b/py/demo/Ice/converter/Server.py @@ -26,7 +26,7 @@ def decodeString(str): class GreatI(Demo.Greet): def exchangeGreeting(self, msg, current=None): - print "Received (UTF-8): \"" + decodeString(msg) + "\"" + print("Received (UTF-8): \"" + decodeString(msg) + "\"") return "Bonne journ\303\251e" def shutdown(self, current=None): @@ -35,7 +35,7 @@ class GreatI(Demo.Greet): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Greet") diff --git a/py/demo/Ice/converter/expect.py b/py/demo/Ice/converter/expect.py index 77372ec3d25..9b7531c3872 100755 --- a/py/demo/Ice/converter/expect.py +++ b/py/demo/Ice/converter/expect.py @@ -16,28 +16,37 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('Server.py --Ice.PrintAdapterReady') server.expect('.* ready') client = Util.spawn('Client.py') client.expect('.*==>') -print "testing with conversion...", +sys.stdout.write("testing with conversion... ") sys.stdout.flush() client.sendline('u') -server.expect('Received \\(UTF-8\\): "Bonne journ\\\\351e"') -client.expect('Received: "Bonne journ\\\\303\\\\251e"') -print "ok" - -print "testing without conversion...", +if sys.version_info[0] == 2: + server.expect('Received \\(UTF-8\\): "Bonne journ\\\\351e"') + client.expect('Received: "Bonne journ\\\\303\\\\251e"') +else: + server.expect('Received \\(UTF-8\\): "Bonne journ\\\\o351e"') + client.expect('Received: "Bonne journ\\\\o303\\\\o251e"') +print("ok") + +sys.stdout.write("testing without conversion... ") +sys.stdout.flush() client.sendline('t') -server.expect('Received \\(UTF-8\\): "Bonne journ\\\\303\\\\251e"') -client.expect('Received: "Bonne journ\\\\351e"') -print "ok" +if sys.version_info[0] == 2: + server.expect('Received \\(UTF-8\\): "Bonne journ\\\\303\\\\251e"') + client.expect('Received: "Bonne journ\\\\351e"') +else: + server.expect('Received \\(UTF-8\\): "Bonne journ\\\\o303\\\\o251e"') + client.expect('Received: "Bonne journ\\\\o351e"') +print("ok") client.sendline('s') server.waitTestSuccess() diff --git a/py/demo/Ice/hello/Client.py b/py/demo/Ice/hello/Client.py index 8134c57a069..04ab665220c 100755 --- a/py/demo/Ice/hello/Client.py +++ b/py/demo/Ice/hello/Client.py @@ -14,7 +14,7 @@ Ice.loadSlice('Hello.ice') import Demo def menu(): - print """ + print(""" usage: t: send greeting as twoway o: send greeting as oneway @@ -28,18 +28,18 @@ S: switch secure mode on/off s: shutdown server x: exit ?: help -""" +""") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 twoway = Demo.HelloPrx.checkedCast(\ self.communicator().propertyToProxy('Hello.Proxy').ice_twoway().ice_timeout(-1).ice_secure(False)) if not twoway: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 oneway = Demo.HelloPrx.uncheckedCast(twoway.ice_oneway()) @@ -56,7 +56,9 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 't': twoway.sayHello(delay) elif c == 'o': @@ -65,12 +67,12 @@ class Client(Ice.Application): batchOneway.sayHello(delay) elif c == 'd': if secure: - print "secure datagrams are not supported" + print("secure datagrams are not supported") else: datagram.sayHello(delay) elif c == 'D': if secure: - print "secure datagrams are not supported" + print("secure datagrams are not supported") else: batchDatagram.sayHello(delay) elif c == 'f': @@ -86,9 +88,9 @@ class Client(Ice.Application): batchOneway = Demo.HelloPrx.uncheckedCast(batchOneway.ice_timeout(timeout)) if timeout == -1: - print "timeout is now switched off" + print("timeout is now switched off") else: - print "timeout is now set to 2000ms" + print("timeout is now set to 2000ms") elif c == 'P': if delay == 0: delay = 2500 @@ -96,9 +98,9 @@ class Client(Ice.Application): delay = 0 if delay == 0: - print "server delay is now deactivated" + print("server delay is now deactivated") else: - print "server delay is now set to 2500ms" + print("server delay is now set to 2500ms") elif c == 'S': secure = not secure @@ -109,9 +111,9 @@ class Client(Ice.Application): batchDatagram = Demo.HelloPrx.uncheckedCast(batchDatagram.ice_secure(secure)) if secure: - print "secure mode is now on" + print("secure mode is now on") else: - print "secure mode is now off" + print("secure mode is now off") elif c == 's': twoway.shutdown() elif c == 'x': @@ -119,14 +121,14 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except KeyboardInterrupt: break except EOFError: break - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) return 0 diff --git a/py/demo/Ice/hello/Server.py b/py/demo/Ice/hello/Server.py index 14a1afbd054..e03d6f724a8 100755 --- a/py/demo/Ice/hello/Server.py +++ b/py/demo/Ice/hello/Server.py @@ -11,13 +11,14 @@ import sys, traceback, time, Ice Ice.loadSlice('Hello.ice') +Ice.updateModules() import Demo class HelloI(Demo.Hello): def sayHello(self, delay, current=None): if delay != 0: time.sleep(delay / 1000.0) - print "Hello World!" + print("Hello World!") def shutdown(self, current=None): current.adapter.getCommunicator().shutdown() @@ -25,7 +26,7 @@ class HelloI(Demo.Hello): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Hello") diff --git a/py/demo/Ice/hello/expect.py b/py/demo/Ice/hello/expect.py index 2538d9c20a9..161ee904a6e 100755 --- a/py/demo/Ice/hello/expect.py +++ b/py/demo/Ice/hello/expect.py @@ -16,10 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) +sys.path.append(os.path.join(path[0], "scripts")) -from demoscript import * +from demoscript import Util from demoscript.Ice import hello server = Util.spawn('Server.py --Ice.PrintAdapterReady --Ice.Warn.Connections=0') diff --git a/py/demo/Ice/latency/Client.py b/py/demo/Ice/latency/Client.py index 35201fcffd4..6cdc4a69234 100755 --- a/py/demo/Ice/latency/Client.py +++ b/py/demo/Ice/latency/Client.py @@ -16,19 +16,19 @@ import Demo class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 ping = Demo.PingPrx.checkedCast(self.communicator().propertyToProxy('Ping.Proxy')) if not ping: - print "invalid proxy" + print("invalid proxy") return 1 # Initial ping to setup the connection. ping.ice_ping(); repetitions = 100000 - print "pinging server " + str(repetitions) + " times (this may take a while)" + print("pinging server " + str(repetitions) + " times (this may take a while)") tsec = time.time() @@ -40,8 +40,8 @@ class Client(Ice.Application): tsec = time.time() - tsec tmsec = tsec * 1000.0 - print "time for %d pings: %.3fms" % (repetitions, tmsec) - print "time per ping: %.3fms" % (tmsec / repetitions) + print("time for %d pings: %.3fms" % (repetitions, tmsec)) + print("time per ping: %.3fms" % (tmsec / repetitions)) return 0 diff --git a/py/demo/Ice/latency/Server.py b/py/demo/Ice/latency/Server.py index 768c78f3ed2..0ae8bb33f12 100755 --- a/py/demo/Ice/latency/Server.py +++ b/py/demo/Ice/latency/Server.py @@ -16,7 +16,7 @@ import Demo class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Latency") diff --git a/py/demo/Ice/latency/expect.py b/py/demo/Ice/latency/expect.py index 198b7634eda..d71e67602b1 100755 --- a/py/demo/Ice/latency/expect.py +++ b/py/demo/Ice/latency/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('Server.py --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing ping... ", +sys.stdout.write("testing ping... ") sys.stdout.flush() client = Util.spawn('Client.py') client.waitTestSuccess(timeout=100) -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess() -print client.before +print(client.before) diff --git a/py/demo/Ice/minimal/Server.py b/py/demo/Ice/minimal/Server.py index 048d4f6a155..926c838d4cd 100755 --- a/py/demo/Ice/minimal/Server.py +++ b/py/demo/Ice/minimal/Server.py @@ -15,7 +15,7 @@ import Demo class HelloI(Demo.Hello): def sayHello(self, current=None): - print "Hello World!" + print("Hello World!") try: communicator = Ice.initialize(sys.argv) diff --git a/py/demo/Ice/minimal/expect.py b/py/demo/Ice/minimal/expect.py index e0369ef3d23..63de5d4a87c 100755 --- a/py/demo/Ice/minimal/expect.py +++ b/py/demo/Ice/minimal/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,20 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('Server.py --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('Client.py') client.waitTestSuccess() server.expect('Hello World!') -print "ok" +print("ok") -import signal server.kill(signal.SIGTERM) server.waitTestSuccess(-signal.SIGTERM) diff --git a/py/demo/Ice/session/Client.py b/py/demo/Ice/session/Client.py index 9076bb1c82f..9fcd9eaa163 100755 --- a/py/demo/Ice/session/Client.py +++ b/py/demo/Ice/session/Client.py @@ -30,7 +30,7 @@ class SessionRefreshThread(threading.Thread): if not self._terminated: try: self._session.refresh() - except Ice.LocalException, ex: + except Ice.LocalException as ex: self._logger.warning("SessionRefreshThread: " + str(ex)) self._terminated = True finally: @@ -47,18 +47,20 @@ class SessionRefreshThread(threading.Thread): class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 while True: - name = raw_input("Please enter your name ==> ").strip() + sys.stdout.write("Please enter your name ==> ") + sys.stdout.flush() + name = sys.stdin.readline().strip() if len(name) != 0: break base = self.communicator().propertyToProxy('SessionFactory.Proxy') factory = Demo.SessionFactoryPrx.checkedCast(base) if not factory: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 session = factory.create(name) @@ -74,7 +76,9 @@ class Client(Ice.Application): shutdown = False while True: try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() s = str(c) if s.isdigit(): index = int(s) @@ -82,11 +86,11 @@ class Client(Ice.Application): hello = hellos[index] hello.sayHello() else: - print "Index is too high. " + str(len(hellos)) + " hello objects exist so far.\n" +\ - "Use `c' to create a new hello object." + print("Index is too high. " + str(len(hellos)) + " hello objects exist so far.\n" +\ + "Use `c' to create a new hello object.") elif c == 'c': hellos.append(session.createHello()) - print "Created hello object",len(hellos) - 1 + print("Created hello object",len(hellos) - 1) elif c == 's': destroy = False shutdown = True @@ -99,7 +103,7 @@ class Client(Ice.Application): elif c == '?': self.menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") self.menu() except EOFError: break @@ -131,7 +135,7 @@ class Client(Ice.Application): return 0 def menu(self): - print """ + print(""" usage: c: create a new per-client hello object 0-9: send a greeting to a hello object @@ -139,7 +143,7 @@ s: shutdown the server and exit x: exit t: exit without destroying the session ?: help -""" +""") app = Client() sys.exit(app.main(sys.argv, "config.client")) diff --git a/py/demo/Ice/session/Server.py b/py/demo/Ice/session/Server.py index 3ed1642b3a4..610778c90f4 100755 --- a/py/demo/Ice/session/Server.py +++ b/py/demo/Ice/session/Server.py @@ -19,8 +19,8 @@ class HelloI(Demo.Hello): self._id = id def sayHello(self, c): - print "Hello object #" + str(self._id) + " for session `" + self._name + "' says:\n" + \ - "Hello " + self._name + "!" + print("Hello object #" + str(self._id) + " for session `" + self._name + "' says:\n" + \ + "Hello " + self._name + "!") class SessionI(Demo.Session): def __init__(self, name): @@ -31,8 +31,8 @@ class SessionI(Demo.Session): self._nextId = 0 # The id of the next hello object. This is used for tracing purposes. self._objs = [] # List of per-client allocated Hello objects. - print "The session " + self._name + " is now created." - + print("The session " + self._name + " is now created.") + def createHello(self, c): self._lock.acquire() try: @@ -63,19 +63,19 @@ class SessionI(Demo.Session): return self._name finally: self._lock.release() - + def destroy(self, c): self._lock.acquire() try: if self._destroy: raise Ice.ObjectNotExistException() self._destroy = True - print "The session " + self._name + " is now destroyed." + print("The session " + self._name + " is now destroyed.") try: c.adapter.remove(c.id) for p in self._objs: c.adapter.remove(p.ice_getIdentity()) - except Ice.ObjectAdapterDeactivatedException, ex: + except Ice.ObjectAdapterDeactivatedException as ex: # This method is called on shutdown of the server, in # which case this exception is expected. pass @@ -91,7 +91,7 @@ class SessionI(Demo.Session): return self._timestamp finally: self._lock.release() - + class SessionProxyPair: def __init__(self, p, s): self.proxy = p @@ -121,7 +121,7 @@ class ReapThread(threading.Thread): if (time.time() - p.session.timestamp()) > self._timeout: name = p.proxy.getName() p.proxy.destroy() - print "The session " + name + " has timed out." + print("The session " + name + " has timed out.") self._sessions.remove(p) except Ice.ObjectNotExistException: self._sessions.remove(p) @@ -161,13 +161,13 @@ class SessionFactoryI(Demo.SessionFactory): self._lock.release() def shutdown(self, c): - print "Shutting down..." + print("Shutting down...") c.adapter.getCommunicator().shutdown() class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("SessionFactory") diff --git a/py/demo/Ice/session/expect.py b/py/demo/Ice/session/expect.py index f88d344c60a..22760d11d5a 100755 --- a/py/demo/Ice/session/expect.py +++ b/py/demo/Ice/session/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import session server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/throughput/Client.py b/py/demo/Ice/throughput/Client.py index c90d78cd282..97fe7aa6b21 100755 --- a/py/demo/Ice/throughput/Client.py +++ b/py/demo/Ice/throughput/Client.py @@ -14,7 +14,7 @@ Ice.loadSlice('Throughput.ice') import Demo def menu(): - print """ + print(""" usage: toggle type of data to send: @@ -33,24 +33,27 @@ other commands: s: shutdown server x: exit ?: help -""" +""") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 throughput = Demo.ThroughputPrx.checkedCast(self.communicator().propertyToProxy('Throughput.Proxy')) if not throughput: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 throughputOneway = Demo.ThroughputPrx.uncheckedCast(throughput.ice_oneway()) - bytes = [] - bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) - bytes = ['\x00' for x in bytes] - byteSeq = ''.join(bytes) + if sys.version_info[0] == 2: + b = [] + b[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) + b = ['\x00' for x in b] + byteSeq = ''.join(b) + else: + byteSeq = bytes([0 for x in range(0, Demo.ByteSeqSize)]) stringSeq = [] stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) @@ -86,7 +89,7 @@ class Client(Ice.Application): emptyStructs = [ Demo.StringDouble() ] emptyFixed = [ Demo.Fixed() ] - print "warming up the server...", + print("warming up the server...",) sys.stdout.flush() for i in range(0, 10000): throughput.sendByteSeq(emptyBytes) @@ -106,7 +109,7 @@ class Client(Ice.Application): throughput.endWarmup() - print "ok" + print("ok") else: throughput.ice_ping() # Initial ping to setup the connection. @@ -118,46 +121,48 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() repetitions = 100 if c == '1' or c == '2' or c == '3' or c == '4': currentType = c if c == '1': - print "using byte sequences" + print("using byte sequences") seqSize = Demo.ByteSeqSize elif c == '2': - print "using string sequences" + print("using string sequences") seqSize = Demo.StringSeqSize elif c == '3': - print "using variable-length struct sequences" + print("using variable-length struct sequences") seqSize = Demo.StringDoubleSeqSize elif c == '4': - print "using fixed-length struct sequences" + print("using fixed-length struct sequences") seqSize = Demo.FixedSeqSize elif c == 't' or c == 'o' or c == 'r' or c == 'e': if c == 't' or c == 'o': - print "sending", + sys.stdout.write("sending ") elif c == 'r': - print "receiving", + sys.stdout.write("receiving ") elif c == 'e': - print "sending and receiving", + sys.stdout.write("sending and receiving ") - print repetitions, + sys.stdout.write(str(repetitions) + " ") if currentType == '1': - print "byte", + sys.stdout.write("byte ") elif currentType == '2': - print "string", + sys.stdout.write("string ") elif currentType == '3': - print "variable-length struct", + sys.stdout.write("variable-length struct ") elif currentType == '4': - print "fixed-length struct", - + sys.stdout.write("fixed-length struct ") + if c == 'o': - print "sequences of size %d as oneway..." % seqSize + print("sequences of size %d as oneway..." % seqSize) else: - print "sequences of size %d..." % seqSize + print("sequences of size %d..." % seqSize) tsec = time.time() @@ -201,8 +206,8 @@ class Client(Ice.Application): tsec = time.time() - tsec tmsec = tsec * 1000.0 - print "time for %d sequences: %.3fms" % (repetitions, tmsec) - print "time per sequence: %.3fms" % (tmsec / repetitions) + print("time for %d sequences: %.3fms" % (repetitions, tmsec)) + print("time per sequence: %.3fms" % (tmsec / repetitions)) wireSize = 0 if currentType == '1': wireSize = 1 @@ -216,7 +221,7 @@ class Client(Ice.Application): mbit = repetitions * seqSize * wireSize * 8.0 / tsec / 1000000.0 if c == 'e': mbit = mbit * 2 - print "throughput: %.3fMbps" % mbit + print("throughput: %.3fMbps" % mbit) elif c == 's': throughput.shutdown() elif c == 'x': @@ -224,7 +229,7 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except EOFError: break diff --git a/py/demo/Ice/throughput/Server.py b/py/demo/Ice/throughput/Server.py index 3d1eb775d7c..ff51e35cc26 100755 --- a/py/demo/Ice/throughput/Server.py +++ b/py/demo/Ice/throughput/Server.py @@ -17,10 +17,13 @@ class ThroughputI(Demo.Throughput): def __init__(self): warmup = False - bytes = [] - bytes[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) - bytes = ['\x00' for x in bytes] - self.byteSeq = ''.join(bytes) + if sys.version_info[0] == 2: + b = [] + b[0:Demo.ByteSeqSize] = range(0, Demo.ByteSeqSize) + b = ['\x00' for x in b] + self.byteSeq = ''.join(b) + else: + self.byteSeq = bytes([0 for x in range(0, Demo.ByteSeqSize)]) self.stringSeq = [] self.stringSeq[0:Demo.StringSeqSize] = range(0, Demo.StringSeqSize) @@ -105,7 +108,7 @@ class ThroughputI(Demo.Throughput): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Throughput") diff --git a/py/demo/Ice/throughput/expect.py b/py/demo/Ice/throughput/expect.py index d6892753860..6f1c57aa68d 100755 --- a/py/demo/Ice/throughput/expect.py +++ b/py/demo/Ice/throughput/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import throughput server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/Ice/value/Client.py b/py/demo/Ice/value/Client.py index 4ab969673d5..88720ea82b5 100755 --- a/py/demo/Ice/value/Client.py +++ b/py/demo/Ice/value/Client.py @@ -30,124 +30,127 @@ class ObjectFactory(Ice.ObjectFactory): class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 initial = Demo.InitialPrx.checkedCast(self.communicator().propertyToProxy('Initial.Proxy')) if not initial: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 - print '\n'\ + print('\n'\ "Let's first transfer a simple object, for a class without\n"\ "operations, and print its contents. No factory is required\n"\ "for this.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() simple = initial.getSimple() - print "==> " + simple.message + print("==> " + simple.message) - print '\n'\ + print('\n'\ "Yes, this worked. Now let's try to transfer an object for a class\n"\ "with operations as type ::Demo::Printer, without installing a factory\n"\ "first. This should give us a `no factory' exception.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() try: printer, printerProxy = initial.getPrinter() - print args[0] + ": Did not get the expected NoObjectFactoryException!" + print(args[0] + ": Did not get the expected NoObjectFactoryException!") sys.exit(false) - except Ice.NoObjectFactoryException, ex: - print "==>", ex + except Ice.NoObjectFactoryException as ex: + print("==>", ex) - print '\n'\ + print('\n'\ "Yep, that's what we expected. Now let's try again, but with\n"\ "installing an appropriate factory first. If successful, we print\n"\ "the object's content.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() factory = ObjectFactory() self.communicator().addObjectFactory(factory, Demo.Printer.ice_staticId()) printer, printerProxy = initial.getPrinter() - print "==> " + printer.message + print("==> " + printer.message) - print '\n'\ + print('\n'\ "Cool, it worked! Let's try calling the printBackwards() method\n"\ "on the object we just received locally.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() - print "==>", + sys.stdout.write("==> ") + sys.stdout.flush() printer.printBackwards() - print '\n'\ + print('\n'\ "Now we call the same method, but on the remote object. Watch the\n"\ "server's output.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() printerProxy.printBackwards() - print '\n'\ + print('\n'\ "Next, we transfer a derived object from the server as a base\n"\ "object. Since we haven't yet installed a factory for the derived\n"\ "class, the derived class (::Demo::DerivedPrinter) is sliced\n"\ "to its base class (::Demo::Printer).\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() derivedAsBase = initial.getDerivedPrinter() - print "==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\"" + print("==> The type ID of the received object is \"" + derivedAsBase.ice_id() + "\"") assert(derivedAsBase.ice_id() == Demo.Printer.ice_staticId()) - print '\n'\ + print('\n'\ "Now we install a factory for the derived class, and try again.\n"\ "Because we receive the derived object as a base object, we\n"\ "we need to do a dynamic_cast<> to get from the base to the derived object.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() self.communicator().addObjectFactory(factory, Demo.DerivedPrinter.ice_staticId()) derived = initial.getDerivedPrinter() - print "==> The type ID of the received object is \"" + derived.ice_id() + "\"" + print("==> The type ID of the received object is \"" + derived.ice_id() + "\"") - print '\n'\ + print('\n'\ "Let's print the message contained in the derived object, and\n"\ "call the operation printUppercase() on the derived object\n"\ "locally.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() - print "==> " + derived.derivedMessage - print "==>", + print("==> " + derived.derivedMessage) + sys.stdout.write("==> ") + sys.stdout.flush() derived.printUppercase() - print '\n'\ + print('\n'\ "Finally, we try the same again, but instead of returning the\n"\ "derived object, we throw an exception containing the derived\n"\ "object.\n"\ - "[press enter]" - raw_input() + "[press enter]") + sys.stdin.readline() try: initial.throwDerivedPrinter() - print args[0] + "Did not get the expected DerivedPrinterException!" + print(args[0] + "Did not get the expected DerivedPrinterException!") sys.exit(false) - except Demo.DerivedPrinterException, ex: + except Demo.DerivedPrinterException as ex: derived = ex.derived assert(derived) - print "==> " + derived.derivedMessage - print "==>", + print("==> " + derived.derivedMessage) + sys.stdout.write("==> ") + sys.stdout.flush() derived.printUppercase() - print '\n'\ - "That's it for this demo. Have fun with Ice!" + print('\n'\ + "That's it for this demo. Have fun with Ice!") initial.shutdown() diff --git a/py/demo/Ice/value/Printer.py b/py/demo/Ice/value/Printer.py index 1d76f2e8af0..7b1e8e00c70 100755 --- a/py/demo/Ice/value/Printer.py +++ b/py/demo/Ice/value/Printer.py @@ -12,8 +12,8 @@ import Demo, string class PrinterI(Demo.Printer): def printBackwards(self, current=None): - print self.message[::-1] + print(self.message[::-1]) class DerivedPrinterI(Demo.DerivedPrinter, PrinterI): def printUppercase(self, current=None): - print string.upper(self.derivedMessage) + print(self.derivedMessage.upper()) diff --git a/py/demo/Ice/value/Server.py b/py/demo/Ice/value/Server.py index 7abec6d0315..399ad346960 100755 --- a/py/demo/Ice/value/Server.py +++ b/py/demo/Ice/value/Server.py @@ -47,7 +47,7 @@ class InitialI(Demo.Initial): class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 adapter = self.communicator().createObjectAdapter("Value") diff --git a/py/demo/Ice/value/expect.py b/py/demo/Ice/value/expect.py index 81793e544b7..2e68a040322 100755 --- a/py/demo/Ice/value/expect.py +++ b/py/demo/Ice/value/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import value server = Util.spawn('Server.py --Ice.PrintAdapterReady') diff --git a/py/demo/IceGrid/simple/Client.py b/py/demo/IceGrid/simple/Client.py index 20a84e2e1f6..3a5c94ba044 100755 --- a/py/demo/IceGrid/simple/Client.py +++ b/py/demo/IceGrid/simple/Client.py @@ -15,18 +15,18 @@ import Demo def menu(): - print """ + print(""" usage: t: send greeting as twoway s: shutdown server x: exit ?: help -""" +""") class Client(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 hello = None @@ -37,7 +37,7 @@ class Client(Ice.Application): hello = Demo.HelloPrx.checkedCast(query.findObjectByType("::Demo::Hello")) if not hello: - print self.appName() + ": couldn't find a `::Demo::Hello' object." + print(self.appName() + ": couldn't find a `::Demo::Hello' object.") return 1 menu() @@ -45,7 +45,9 @@ class Client(Ice.Application): c = None while c != 'x': try: - c = raw_input("==> ") + sys.stdout.write("==> ") + sys.stdout.flush() + c = sys.stdin.readline().strip() if c == 't': hello.sayHello() elif c == 's': @@ -55,7 +57,7 @@ class Client(Ice.Application): elif c == '?': menu() else: - print "unknown command `" + c + "'" + print("unknown command `" + c + "'") menu() except EOFError: break diff --git a/py/demo/IceGrid/simple/Server.py b/py/demo/IceGrid/simple/Server.py index 0dd15137918..eac5cb19c64 100755 --- a/py/demo/IceGrid/simple/Server.py +++ b/py/demo/IceGrid/simple/Server.py @@ -18,16 +18,16 @@ class HelloI(Demo.Hello): self.name = name def sayHello(self, current=None): - print self.name + " says Hello World!" + print(self.name + " says Hello World!") def shutdown(self, current=None): - print self.name + " shutting down..." + print(self.name + " shutting down...") current.adapter.getCommunicator().shutdown() class Server(Ice.Application): def run(self, args): if len(args) > 1: - print self.appName() + ": too many arguments" + print(self.appName() + ": too many arguments") return 1 properties = self.communicator().getProperties() diff --git a/py/demo/IceGrid/simple/expect.py b/py/demo/IceGrid/simple/expect.py index f12d7722b5f..57c2b114b98 100755 --- a/py/demo/IceGrid/simple/expect.py +++ b/py/demo/IceGrid/simple/expect.py @@ -16,16 +16,19 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceGrid import simple def rewrite(namein, nameout): fi = open(namein, "r") fo = open(nameout, "w") for l in fi: + if sys.version_info[0] == 3: + if l.find('exe="python"') != -1: + l = l.replace('exe="python"', 'exe="python3"') if l.find('option') != -1: fo.write('<option>-u</option>') fo.write(l) diff --git a/py/demo/IceStorm/clock/Publisher.py b/py/demo/IceStorm/clock/Publisher.py index fa6ac657b9f..8c82fe7dca5 100755 --- a/py/demo/IceStorm/clock/Publisher.py +++ b/py/demo/IceStorm/clock/Publisher.py @@ -15,7 +15,7 @@ import Demo class Publisher(Ice.Application): def usage(self): - print "Usage: " + self.appName() + " [--datagram|--twoway|--oneway] [topic]" + print("Usage: " + self.appName() + " [--datagram|--twoway|--oneway] [topic]") def run(self, args): try: @@ -47,7 +47,7 @@ class Publisher(Ice.Application): manager = IceStorm.TopicManagerPrx.checkedCast(self.communicator().propertyToProxy('TopicManager.Proxy')) if not manager: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 # @@ -55,11 +55,11 @@ class Publisher(Ice.Application): # try: topic = manager.retrieve(topicName) - except IceStorm.NoSuchTopic, e: + except IceStorm.NoSuchTopic: try: topic = manager.create(topicName) - except IceStorm.TopicExists, ex: - print self.appName() + ": temporary error. try again" + except IceStorm.TopicExists: + print(self.appName() + ": temporary error. try again") return 1 # @@ -76,15 +76,15 @@ class Publisher(Ice.Application): publisher = publisher.ice_oneway(); clock = Demo.ClockPrx.uncheckedCast(publisher) - print "publishing tick events. Press ^C to terminate the application." + print("publishing tick events. Press ^C to terminate the application.") try: while 1: clock.tick(time.strftime("%m/%d/%Y %H:%M:%S")) time.sleep(1) - except IOError, e: + except IOError: # Ignore pass - except Ice.CommunicatorDestroyedException, e: + except Ice.CommunicatorDestroyedException: # Ignore pass diff --git a/py/demo/IceStorm/clock/Subscriber.py b/py/demo/IceStorm/clock/Subscriber.py index bc96d09c8e8..f350c0fa7d4 100755 --- a/py/demo/IceStorm/clock/Subscriber.py +++ b/py/demo/IceStorm/clock/Subscriber.py @@ -15,29 +15,29 @@ import Demo class ClockI(Demo.Clock): def tick(self, date, current=None): - print date + print(date) class Subscriber(Ice.Application): def usage(self): - print "Usage: " + self.appName() + \ - " [--batch] [--datagram|--twoway|--ordered|--oneway] [--retryCount count] [--id id] [topic]" + print("Usage: " + self.appName() + \ + " [--batch] [--datagram|--twoway|--ordered|--oneway] [--retryCount count] [--id id] [topic]") def run(self, args): try: opts, args = getopt.getopt(args[1:], '', ['datagram', 'twoway', 'oneway', 'ordered', 'batch', - 'retryCount=', 'id=']) + 'retryCount=', 'id=']) except getopt.GetoptError: self.usage() return 1 - batch = False - option = "None" + batch = False + option = "None" topicName = "time" id = "" retryCount = "" for o, a in opts: - oldoption = option + oldoption = option if o == "--datagram": option = "Datagram" elif o =="--twoway": @@ -45,38 +45,38 @@ class Subscriber(Ice.Application): elif o =="--ordered": option = "Ordered" elif o =="--oneway": - option = "Oneway" + option = "Oneway" elif o =="--batch": batch = True - elif o == "--id": - id = a - elif o == "--retryCount": - retryCount = a - if oldoption != option and oldoption != "None": - self.usage() - return 1 + elif o == "--id": + id = a + elif o == "--retryCount": + retryCount = a + if oldoption != option and oldoption != "None": + self.usage() + return 1 if len(args) > 1: - self.usage() - return 1 + self.usage() + return 1 if len(args) > 0: topicName = args[0] - if len(retryCount) > 0: - if option == "None": - option = "Twoway" - elif option != "Twoway" and option != "Ordered": - print self.appName() + ": retryCount requires a twoway proxy" - return 1 + if len(retryCount) > 0: + if option == "None": + option = "Twoway" + elif option != "Twoway" and option != "Ordered": + print(self.appName() + ": retryCount requires a twoway proxy") + return 1 if batch and (option in ("Twoway", "Ordered")): - print self.appName() + ": batch can only be set with oneway or datagram" + print(self.appName() + ": batch can only be set with oneway or datagram") return 1 manager = IceStorm.TopicManagerPrx.checkedCast(self.communicator().propertyToProxy('TopicManager.Proxy')) if not manager: - print args[0] + ": invalid proxy" + print(args[0] + ": invalid proxy") return 1 # @@ -84,41 +84,41 @@ class Subscriber(Ice.Application): # try: topic = manager.retrieve(topicName) - except IceStorm.NoSuchTopic, e: + except IceStorm.NoSuchTopic as e: try: topic = manager.create(topicName) - except IceStorm.TopicExists, ex: - print self.appName() + ": temporary error. try again" + except IceStorm.TopicExists as ex: + print(self.appName() + ": temporary error. try again") return 1 adapter = self.communicator().createObjectAdapter("Clock.Subscriber") - # - # Add a servant for the Ice object. If --id is used the identity - # comes from the command line, otherwise a UUID is used. - # - # id is not directly altered since it is used below to detect - # whether subscribeAndGetPublisher can raise AlreadySubscribed. - # - - subId = Ice.Identity() - subId.name = id - if len(subId.name) == 0: - subId.name = Ice.generateUUID() + # + # Add a servant for the Ice object. If --id is used the identity + # comes from the command line, otherwise a UUID is used. + # + # id is not directly altered since it is used below to detect + # whether subscribeAndGetPublisher can raise AlreadySubscribed. + # + + subId = Ice.Identity() + subId.name = id + if len(subId.name) == 0: + subId.name = Ice.generateUUID() subscriber = adapter.add(ClockI(), subId) qos = {} - if len(retryCount) > 0: - qos["retryCount"] = retryCount + if len(retryCount) > 0: + qos["retryCount"] = retryCount - # - # Set up the proxy. - # + # + # Set up the proxy. + # if option == "Datagram": - if batch: - subscriber = subscriber.ice_batchDatagram() - else: - subscriber = subscriber.ice_datagram() + if batch: + subscriber = subscriber.ice_batchDatagram() + else: + subscriber = subscriber.ice_datagram() elif option == "Twoway": # Do nothing to the subscriber proxy. Its already twoway. pass @@ -126,18 +126,18 @@ class Subscriber(Ice.Application): # Do nothing to the subscriber proxy. Its already twoway. qos["reliability"] = "ordered" elif option == "Oneway" or option == "None": - if batch: - subscriber = subscriber.ice_batchOneway() - else: - subscriber = subscriber.ice_oneway() - - try: - topic.subscribeAndGetPublisher(qos, subscriber) - except IceStorm.AlreadySubscribed, ex: - # If we're manually setting the subscriber id ignore. - if len(id) == 0: - raise - print "reactivating persistent subscriber" + if batch: + subscriber = subscriber.ice_batchOneway() + else: + subscriber = subscriber.ice_oneway() + + try: + topic.subscribeAndGetPublisher(qos, subscriber) + except IceStorm.AlreadySubscribed as ex: + # If we're manually setting the subscriber id ignore. + if len(id) == 0: + raise + print("reactivating persistent subscriber") adapter.activate() @@ -148,7 +148,7 @@ class Subscriber(Ice.Application): # Unsubscribe all subscribed objects. # topic.unsubscribe(subscriber) - + return 0 app = Subscriber() diff --git a/py/demo/IceStorm/clock/expect.py b/py/demo/IceStorm/clock/expect.py index e6172aa1ecd..02332c30a31 100755 --- a/py/demo/IceStorm/clock/expect.py +++ b/py/demo/IceStorm/clock/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.IceStorm import clock clock.run('Subscriber.py', 'Publisher.py') diff --git a/py/demo/book/printer/Server.py b/py/demo/book/printer/Server.py index fba7f0973a6..24ac6c85b23 100755 --- a/py/demo/book/printer/Server.py +++ b/py/demo/book/printer/Server.py @@ -15,7 +15,7 @@ import Demo class PrinterI(Demo.Printer): def printString(self, s, current=None): - print s + print(s) status = 0 ice = None diff --git a/py/demo/book/printer/expect.py b/py/demo/book/printer/expect.py index 7522533afc9..23854359e52 100755 --- a/py/demo/book/printer/expect.py +++ b/py/demo/book/printer/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,18 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) - -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('Server.py --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('Client.py') client.waitTestSuccess() server.expect('Hello World!') server.kill(signal.SIGTERM) server.waitTestSuccess(-signal.SIGTERM) -print "ok" +print("ok") diff --git a/py/demo/book/simple_filesystem/Client.py b/py/demo/book/simple_filesystem/Client.py index 7d3fb0cb7c6..23caad1fb21 100755 --- a/py/demo/book/simple_filesystem/Client.py +++ b/py/demo/book/simple_filesystem/Client.py @@ -29,15 +29,15 @@ def listRecursive(dir, depth): for node in contents: subdir = Filesystem.DirectoryPrx.checkedCast(node) file = Filesystem.FilePrx.uncheckedCast(node) - print indent + node.name(), + sys.stdout.write(indent + node.name() + " ") if subdir: - print "(directory):" + print("(directory):") listRecursive(subdir, depth) else: - print "(file):" + print("(file):") text = file.read() for line in text: - print indent + "\t" + line + print(indent + "\t" + line) status = 0 ic = None @@ -56,7 +56,7 @@ try: # Recursively list the contents of the root directory # - print "Contents of root directory:" + print("Contents of root directory:") listRecursive(rootDir, 0) except: traceback.print_exc() diff --git a/py/demo/book/simple_filesystem/Server.py b/py/demo/book/simple_filesystem/Server.py index 14561ca1fa0..266f3a39667 100755 --- a/py/demo/book/simple_filesystem/Server.py +++ b/py/demo/book/simple_filesystem/Server.py @@ -94,7 +94,7 @@ class Server(Ice.Application): # Create an object adapter # adapter = self.communicator().createObjectAdapterWithEndpoints( - "SimpleFileSystem", "default -h localhost -p 10000") + "SimpleFileSystem", "default -h localhost -p 10000") # Create the root directory (with name "/" and no parent) # @@ -107,8 +107,8 @@ class Server(Ice.Application): text = [ "This file system contains a collection of poetry." ] try: file.write(text) - except Filesystem.GenericError, e: - print e.reason + except Filesystem.GenericError as e: + print(e.reason) file.activate(adapter) # Create a directory called "Coleridge" in the root directory @@ -126,8 +126,8 @@ class Server(Ice.Application): "Down to a sunless sea." ] try: file.write(text) - except Filesystem.GenericError, e: - print e.reason + except Filesystem.GenericError as e: + print(e.reason) file.activate(adapter) # All objects are created, allow client requests now @@ -139,7 +139,7 @@ class Server(Ice.Application): self.communicator().waitForShutdown() if self.interrupted(): - print self.appName() + ": terminating" + print(self.appName() + ": terminating") return 0 diff --git a/py/demo/book/simple_filesystem/expect.py b/py/demo/book/simple_filesystem/expect.py index 0a5b93a08cc..606df3ed297 100755 --- a/py/demo/book/simple_filesystem/expect.py +++ b/py/demo/book/simple_filesystem/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,20 +16,18 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) - -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('Server.py --Ice.PrintAdapterReady') server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('Client.py') client.expect('Contents of root directory:\n.*Down to a sunless sea.') client.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/py/modules/IcePy/Communicator.cpp b/py/modules/IcePy/Communicator.cpp index ca5a4392b1a..a51fc516576 100644 --- a/py/modules/IcePy/Communicator.cpp +++ b/py/modules/IcePy/Communicator.cpp @@ -63,9 +63,10 @@ struct CommunicatorObject extern "C" #endif static CommunicatorObject* -communicatorNew(PyObject* /*arg*/) +communicatorNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - CommunicatorObject* self = PyObject_New(CommunicatorObject, &CommunicatorType); + assert(type && type->tp_alloc); + CommunicatorObject* self = reinterpret_cast<CommunicatorObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -286,7 +287,7 @@ communicatorDealloc(CommunicatorObject* self) delete self->communicator; delete self->shutdownMonitor; delete self->shutdownThread; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -1441,8 +1442,7 @@ PyTypeObject CommunicatorType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Communicator"), /* tp_name */ sizeof(CommunicatorObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1451,7 +1451,7 @@ PyTypeObject CommunicatorType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1523,7 +1523,7 @@ IcePy::createCommunicator(const Ice::CommunicatorPtr& communicator) return p->second; } - CommunicatorObject* obj = communicatorNew(0); + CommunicatorObject* obj = communicatorNew(&CommunicatorType, 0, 0); if(obj) { obj->communicator = new Ice::CommunicatorPtr(communicator); diff --git a/py/modules/IcePy/Config.h b/py/modules/IcePy/Config.h index 6339ed0f04c..a8700b66cb4 100644 --- a/py/modules/IcePy/Config.h +++ b/py/modules/IcePy/Config.h @@ -32,12 +32,4 @@ #endif #define STRCAST(s) const_cast<char*>(s) -// -// Python 2.5 compatibility. -// -#if PY_VERSION_HEX < 0x02050000 - typedef int Py_ssize_t; -# define ICEPY_OLD_EXCEPTIONS -#endif - #endif diff --git a/py/modules/IcePy/Connection.cpp b/py/modules/IcePy/Connection.cpp index 31478d04ab7..f50e591a16a 100644 --- a/py/modules/IcePy/Connection.cpp +++ b/py/modules/IcePy/Connection.cpp @@ -41,9 +41,10 @@ struct ConnectionObject extern "C" #endif static ConnectionObject* -connectionNew(PyObject* /*arg*/) +connectionNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - ConnectionObject* self = PyObject_New(ConnectionObject, &ConnectionType); + assert(type && type->tp_alloc); + ConnectionObject* self = reinterpret_cast<ConnectionObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -61,27 +62,63 @@ connectionDealloc(ConnectionObject* self) { delete self->connection; delete self->communicator; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 extern "C" #endif -static int -connectionCompare(ConnectionObject* c1, ConnectionObject* c2) +static PyObject* +connectionCompare(ConnectionObject* c1, PyObject* other, int op) { - if(*c1->connection < *c2->connection) - { - return -1; - } - else if(*c1->connection == *c2->connection) + bool result; + + if(PyObject_TypeCheck(other, &ConnectionType)) { - return 0; + ConnectionObject* c2 = reinterpret_cast<ConnectionObject*>(other); + + switch(op) + { + case Py_EQ: + result = *c1->connection == *c2->connection; + break; + case Py_NE: + result = *c1->connection != *c2->connection; + break; + case Py_LE: + result = *c1->connection <= *c2->connection; + break; + case Py_GE: + result = *c1->connection >= *c2->connection; + break; + case Py_LT: + result = *c1->connection < *c2->connection; + break; + case Py_GT: + result = *c1->connection > *c2->connection; + break; + } } else { - return 1; + if(op == Py_EQ) + { + result = false; + } + else if(op == Py_NE) + { + result = true; + } + else + { + PyErr_Format(PyExc_TypeError, "can't compare %s to %s", Py_TYPE(c1)->tp_name, Py_TYPE(other)->tp_name); + return 0; + } } + + PyObject* r = result ? getTrue() : getFalse(); + Py_INCREF(r); + return r; } #ifdef WIN32 @@ -361,7 +398,7 @@ connectionTimeout(ConnectionObject* self) return 0; } - return PyInt_FromLong(timeout); + return PyLong_FromLong(timeout); } #ifdef WIN32 @@ -459,8 +496,7 @@ PyTypeObject ConnectionType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Connection"), /* tp_name */ sizeof(ConnectionObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -469,7 +505,7 @@ PyTypeObject ConnectionType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - reinterpret_cast<cmpfunc>(connectionCompare), /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -480,11 +516,16 @@ PyTypeObject ConnectionType = 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ +#if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */ +#endif 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + reinterpret_cast<richcmpfunc>(connectionCompare), /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -524,7 +565,7 @@ IcePy::initConnection(PyObject* module) PyObject* IcePy::createConnection(const Ice::ConnectionPtr& connection, const Ice::CommunicatorPtr& communicator) { - ConnectionObject* obj = connectionNew(0); + ConnectionObject* obj = connectionNew(&ConnectionType, 0, 0); if(obj) { obj->connection = new Ice::ConnectionPtr(connection); diff --git a/py/modules/IcePy/ConnectionInfo.cpp b/py/modules/IcePy/ConnectionInfo.cpp index 080d6d45e2a..ad917c5790f 100644 --- a/py/modules/IcePy/ConnectionInfo.cpp +++ b/py/modules/IcePy/ConnectionInfo.cpp @@ -32,9 +32,9 @@ struct ConnectionInfoObject extern "C" #endif static ConnectionInfoObject* -connectionInfoNew(PyObject* /*arg*/) +connectionInfoNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { - PyErr_Format(PyExc_RuntimeError, STRCAST("An connection info cannot be created directly")); + PyErr_Format(PyExc_RuntimeError, STRCAST("A connection info cannot be created directly")); return 0; } @@ -45,7 +45,7 @@ static void connectionInfoDealloc(ConnectionInfoObject* self) { delete self->connectionInfo; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -87,7 +87,7 @@ ipConnectionInfoGetLocalPort(ConnectionInfoObject* self) { Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo); assert(info); - return PyInt_FromLong(info->localPort); + return PyLong_FromLong(info->localPort); } #ifdef WIN32 @@ -109,7 +109,7 @@ ipConnectionInfoGetRemotePort(ConnectionInfoObject* self) { Ice::IPConnectionInfoPtr info = Ice::IPConnectionInfoPtr::dynamicCast(*self->connectionInfo); assert(info); - return PyInt_FromLong(info->remotePort); + return PyLong_FromLong(info->remotePort); } #ifdef WIN32 @@ -131,7 +131,7 @@ udpConnectionInfoGetMcastPort(ConnectionInfoObject* self, void* member) { Ice::UDPConnectionInfoPtr info = Ice::UDPConnectionInfoPtr::dynamicCast(*self->connectionInfo); assert(info); - return PyInt_FromLong(info->mcastPort); + return PyLong_FromLong(info->mcastPort); } static PyGetSetDef ConnectionInfoGetters[] = @@ -172,8 +172,7 @@ PyTypeObject ConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.ConnectionInfo"), /* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -182,7 +181,7 @@ PyTypeObject ConnectionInfoType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -220,8 +219,7 @@ PyTypeObject IPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.IPConnectionInfo"), /* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -230,7 +228,7 @@ PyTypeObject IPConnectionInfoType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -268,8 +266,7 @@ PyTypeObject TCPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.TCPConnectionInfo"),/* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -278,7 +275,7 @@ PyTypeObject TCPConnectionInfoType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -316,8 +313,7 @@ PyTypeObject UDPConnectionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.UDPConnectionInfo"),/* tp_name */ sizeof(ConnectionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -326,7 +322,7 @@ PyTypeObject UDPConnectionInfoType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -440,7 +436,7 @@ IcePy::createConnectionInfo(const Ice::ConnectionInfoPtr& connectionInfo) type = &ConnectionInfoType; } - ConnectionInfoObject* obj = PyObject_New(ConnectionInfoObject, type); + ConnectionInfoObject* obj = reinterpret_cast<ConnectionInfoObject*>(type->tp_alloc(type, 0)); if(!obj) { return 0; diff --git a/py/modules/IcePy/Current.cpp b/py/modules/IcePy/Current.cpp index 860be1a5100..6ec6c15e73b 100644 --- a/py/modules/IcePy/Current.cpp +++ b/py/modules/IcePy/Current.cpp @@ -55,9 +55,9 @@ const Py_ssize_t CURRENT_REQUEST_ID = 7; extern "C" #endif static CurrentObject* -currentNew(PyObject* /*arg*/) +currentNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - CurrentObject* self = PyObject_New(CurrentObject, &CurrentType); + CurrentObject* self = reinterpret_cast<CurrentObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -91,7 +91,7 @@ currentDealloc(CurrentObject* self) Py_XDECREF(self->ctx); Py_XDECREF(self->requestId); delete self->current; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -216,7 +216,7 @@ currentGetter(CurrentObject* self, void* closure) { if(!self->requestId) { - self->requestId = PyInt_FromLong(self->current->requestId); + self->requestId = PyLong_FromLong(self->current->requestId); assert(self->requestId); } Py_INCREF(self->requestId); @@ -256,8 +256,7 @@ PyTypeObject CurrentType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Current"), /* tp_name */ sizeof(CurrentObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -266,7 +265,7 @@ PyTypeObject CurrentType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -324,7 +323,7 @@ IcePy::createCurrent(const Ice::Current& current) // // Return an instance of IcePy.Current to hold the current information. // - CurrentObject* obj = currentNew(0); + CurrentObject* obj = currentNew(&CurrentType, 0, 0); if(obj) { *obj->current = current; diff --git a/py/modules/IcePy/Endpoint.cpp b/py/modules/IcePy/Endpoint.cpp index 979193fa7fd..84d0c725cf9 100644 --- a/py/modules/IcePy/Endpoint.cpp +++ b/py/modules/IcePy/Endpoint.cpp @@ -32,7 +32,7 @@ struct EndpointObject extern "C" #endif static EndpointObject* -endpointNew(PyObject* /*arg*/) +endpointNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { PyErr_Format(PyExc_RuntimeError, STRCAST("An endpoint cannot be created directly")); return 0; @@ -45,27 +45,63 @@ static void endpointDealloc(EndpointObject* self) { delete self->endpoint; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 extern "C" #endif -static int -endpointCompare(EndpointObject* p1, EndpointObject* p2) +static PyObject* +endpointCompare(EndpointObject* p1, PyObject* other, int op) { - if(*p1->endpoint < *p2->endpoint) - { - return -1; - } - else if(*p1->endpoint == *p2->endpoint) + bool result; + + if(PyObject_TypeCheck(other, &EndpointType)) { - return 0; + EndpointObject* p2 = reinterpret_cast<EndpointObject*>(other); + + switch(op) + { + case Py_EQ: + result = *p1->endpoint == *p2->endpoint; + break; + case Py_NE: + result = *p1->endpoint != *p2->endpoint; + break; + case Py_LE: + result = *p1->endpoint <= *p2->endpoint; + break; + case Py_GE: + result = *p1->endpoint >= *p2->endpoint; + break; + case Py_LT: + result = *p1->endpoint < *p2->endpoint; + break; + case Py_GT: + result = *p1->endpoint > *p2->endpoint; + break; + } } else { - return 1; + if(op == Py_EQ) + { + result = false; + } + else if(op == Py_NE) + { + result = true; + } + else + { + PyErr_Format(PyExc_TypeError, "can't compare %s to %s", Py_TYPE(p1)->tp_name, Py_TYPE(other)->tp_name); + return 0; + } } + + PyObject* r = result ? getTrue() : getFalse(); + Py_INCREF(r); + return r; } #ifdef WIN32 @@ -131,18 +167,17 @@ PyTypeObject EndpointType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Endpoint"), /* tp_name */ sizeof(EndpointObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)endpointCompare, /* tp_compare */ - (reprfunc)endpointRepr, /* tp_repr */ + 0, /* tp_reserved */ + reinterpret_cast<reprfunc>(endpointRepr), /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ @@ -152,11 +187,18 @@ PyTypeObject EndpointType = 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ +#if PY_VERSION_HEX >= 0x03000000 + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */ +#endif 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + reinterpret_cast<richcmpfunc>(endpointCompare), /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -170,7 +212,7 @@ PyTypeObject EndpointType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -204,7 +246,7 @@ IcePy::getEndpoint(PyObject* obj) PyObject* IcePy::createEndpoint(const Ice::EndpointPtr& endpoint) { - EndpointObject* obj = PyObject_New(EndpointObject, &EndpointType); + EndpointObject* obj = reinterpret_cast<EndpointObject*>(EndpointType.tp_alloc(&EndpointType, 0)); if(!obj) { return 0; diff --git a/py/modules/IcePy/EndpointInfo.cpp b/py/modules/IcePy/EndpointInfo.cpp index 46df1510902..c096ed77006 100644 --- a/py/modules/IcePy/EndpointInfo.cpp +++ b/py/modules/IcePy/EndpointInfo.cpp @@ -31,7 +31,7 @@ struct EndpointInfoObject extern "C" #endif static EndpointInfoObject* -endpointInfoNew(PyObject* /*arg*/) +endpointInfoNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { PyErr_Format(PyExc_RuntimeError, STRCAST("An endpoint info cannot be created directly")); return 0; @@ -44,7 +44,7 @@ static void endpointInfoDealloc(EndpointInfoObject* self) { delete self->endpointInfo; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } // @@ -60,7 +60,7 @@ endpointInfoType(EndpointInfoObject* self) try { Ice::Short type = (*self->endpointInfo)->type(); - return PyInt_FromLong(type); + return PyLong_FromLong(type); } catch(const Ice::Exception& ex) { @@ -125,7 +125,7 @@ extern "C" static PyObject* endpointInfoGetTimeout(EndpointInfoObject* self) { - return PyInt_FromLong((*self->endpointInfo)->timeout); + return PyLong_FromLong((*self->endpointInfo)->timeout); } #ifdef WIN32 @@ -158,7 +158,7 @@ ipEndpointInfoGetPort(EndpointInfoObject* self) { Ice::IPEndpointInfoPtr info = Ice::IPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->port); + return PyLong_FromLong(info->port); } #ifdef WIN32 @@ -169,7 +169,7 @@ udpEndpointInfoGetProtocolMajor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->protocolMajor); + return PyLong_FromLong(info->protocolMajor); } #ifdef WIN32 @@ -180,7 +180,7 @@ udpEndpointInfoGetProtocolMinor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->protocolMinor); + return PyLong_FromLong(info->protocolMinor); } #ifdef WIN32 @@ -191,7 +191,7 @@ udpEndpointInfoGetEncodingMajor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->encodingMajor); + return PyLong_FromLong(info->encodingMajor); } #ifdef WIN32 @@ -202,7 +202,7 @@ udpEndpointInfoGetEncodingMinor(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->encodingMinor); + return PyLong_FromLong(info->encodingMinor); } #ifdef WIN32 @@ -224,7 +224,7 @@ udpEndpointInfoGetMcastTtl(EndpointInfoObject* self) { Ice::UDPEndpointInfoPtr info = Ice::UDPEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); - return PyInt_FromLong(info->mcastTtl); + return PyLong_FromLong(info->mcastTtl); } #ifdef WIN32 @@ -235,8 +235,13 @@ opaqueEndpointInfoGetRawBytes(EndpointInfoObject* self) { Ice::OpaqueEndpointInfoPtr info = Ice::OpaqueEndpointInfoPtr::dynamicCast(*self->endpointInfo); assert(info); +#if PY_VERSION_HEX >= 0x03000000 + return PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&info->rawBytes[0]), + static_cast<int>(info->rawBytes.size())); +#else return PyString_FromStringAndSize(reinterpret_cast<const char*>(&info->rawBytes[0]), static_cast<int>(info->rawBytes.size())); +#endif } static PyMethodDef EndpointInfoMethods[] = @@ -299,17 +304,16 @@ PyTypeObject EndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.EndpointInfo"), /* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -338,7 +342,7 @@ PyTypeObject EndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -347,17 +351,16 @@ PyTypeObject IPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.IPEndpointInfo"), /* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -386,7 +389,7 @@ PyTypeObject IPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -395,17 +398,16 @@ PyTypeObject TCPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.TCPEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -434,7 +436,7 @@ PyTypeObject TCPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -443,17 +445,16 @@ PyTypeObject UDPEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.UDPEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -482,7 +483,7 @@ PyTypeObject UDPEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -491,17 +492,16 @@ PyTypeObject OpaqueEndpointInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.OpaqueEndpointInfo"),/* tp_name */ sizeof(EndpointInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)endpointInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(endpointInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -530,7 +530,7 @@ PyTypeObject OpaqueEndpointInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)endpointInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(endpointInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -630,7 +630,7 @@ IcePy::createEndpointInfo(const Ice::EndpointInfoPtr& endpointInfo) type = &EndpointInfoType; } - EndpointInfoObject* obj = PyObject_New(EndpointInfoObject, type); + EndpointInfoObject* obj = reinterpret_cast<EndpointInfoObject*>(type->tp_alloc(type, 0)); if(!obj) { return 0; diff --git a/py/modules/IcePy/ImplicitContext.cpp b/py/modules/IcePy/ImplicitContext.cpp index d60a216411e..5ceae0f6ea6 100644 --- a/py/modules/IcePy/ImplicitContext.cpp +++ b/py/modules/IcePy/ImplicitContext.cpp @@ -36,9 +36,9 @@ struct ImplicitContextObject extern "C" #endif static ImplicitContextObject* -implicitContextNew(PyObject* /*arg*/) +implicitContextNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - ImplicitContextObject* self = PyObject_New(ImplicitContextObject, &ImplicitContextType); + ImplicitContextObject* self = reinterpret_cast<ImplicitContextObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -54,27 +54,63 @@ static void implicitContextDealloc(ImplicitContextObject* self) { delete self->implicitContext; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 extern "C" #endif -static int -implicitContextCompare(ImplicitContextObject* c1, ImplicitContextObject* c2) +static PyObject* +implicitContextCompare(ImplicitContextObject* c1, PyObject* other, int op) { - if(*c1->implicitContext < *c2->implicitContext) + bool result; + + if(PyObject_TypeCheck(other, &ImplicitContextType)) { - return -1; - } - else if(*c1->implicitContext == *c2->implicitContext) - { - return 0; + ImplicitContextObject* c2 = reinterpret_cast<ImplicitContextObject*>(other); + + switch(op) + { + case Py_EQ: + result = *c1->implicitContext == *c2->implicitContext; + break; + case Py_NE: + result = *c1->implicitContext != *c2->implicitContext; + break; + case Py_LE: + result = *c1->implicitContext <= *c2->implicitContext; + break; + case Py_GE: + result = *c1->implicitContext >= *c2->implicitContext; + break; + case Py_LT: + result = *c1->implicitContext < *c2->implicitContext; + break; + case Py_GT: + result = *c1->implicitContext > *c2->implicitContext; + break; + } } else { - return 1; + if(op == Py_EQ) + { + result = false; + } + else if(op == Py_NE) + { + result = true; + } + else + { + PyErr_Format(PyExc_TypeError, "can't compare %s to %s", Py_TYPE(c1)->tp_name, Py_TYPE(other)->tp_name); + return 0; + } } + + PyObject* r = result ? getTrue() : getFalse(); + Py_INCREF(r); + return r; } #ifdef WIN32 @@ -278,8 +314,7 @@ PyTypeObject ImplicitContextType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.ImplicitContext"), /* tp_name */ sizeof(ImplicitContextObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -288,7 +323,7 @@ PyTypeObject ImplicitContextType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - reinterpret_cast<cmpfunc>(implicitContextCompare), /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -299,15 +334,20 @@ PyTypeObject ImplicitContextType = 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ +#if PY_VERSION_HEX >= 0x03000000 Py_TPFLAGS_DEFAULT, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_HAVE_RICHCOMPARE, /* tp_flags */ +#endif 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + reinterpret_cast<richcmpfunc>(implicitContextCompare), /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - ImplicitContextMethods, /* tp_methods */ + ImplicitContextMethods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ @@ -343,7 +383,7 @@ IcePy::initImplicitContext(PyObject* module) PyObject* IcePy::createImplicitContext(const Ice::ImplicitContextPtr& implicitContext) { - ImplicitContextObject* obj = implicitContextNew(0); + ImplicitContextObject* obj = implicitContextNew(&ImplicitContextType, 0, 0); if(obj) { obj->implicitContext = new Ice::ImplicitContextPtr(implicitContext); diff --git a/py/modules/IcePy/Init.cpp b/py/modules/IcePy/Init.cpp index eec84a7d4f0..c5b383d9fc2 100644 --- a/py/modules/IcePy/Init.cpp +++ b/py/modules/IcePy/Init.cpp @@ -73,14 +73,41 @@ static PyMethodDef methods[] = { 0, 0 } /* sentinel */ }; +#if PY_VERSION_HEX >= 0x03000000 + +# define INIT_RETURN return(0) + +static struct PyModuleDef iceModule = +{ + PyModuleDef_HEAD_INIT, + "IcePy", + "The Internet Communications Engine.", + -1, + methods, + NULL, + NULL, + NULL, + NULL +}; + +#else + +# define INIT_RETURN return + PyDoc_STRVAR(moduleDoc, "The Internet Communications Engine."); +#endif + #if defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x550) extern "C" __global void #else PyMODINIT_FUNC #endif +#if PY_VERSION_HEX >= 0x03000000 +PyInit_IcePy(void) +#else initIcePy(void) +#endif { PyObject* module; @@ -89,64 +116,75 @@ initIcePy(void) // PyEval_InitThreads(); +#if PY_VERSION_HEX >= 0x03000000 + // + // Create the module. + // + module = PyModule_Create(&iceModule); +#else // // Initialize the module. // module = Py_InitModule3(STRCAST("IcePy"), methods, moduleDoc); +#endif // // Install built-in Ice types. // if(!initProxy(module)) { - return; + INIT_RETURN; } if(!initTypes(module)) { - return; + INIT_RETURN; } if(!initProperties(module)) { - return; + INIT_RETURN; } if(!initCommunicator(module)) { - return; + INIT_RETURN; } if(!initCurrent(module)) { - return; + INIT_RETURN; } if(!initObjectAdapter(module)) { - return; + INIT_RETURN; } if(!initOperation(module)) { - return; + INIT_RETURN; } if(!initLogger(module)) { - return; + INIT_RETURN; } if(!initConnection(module)) { - return; + INIT_RETURN; } if(!initConnectionInfo(module)) { - return; + INIT_RETURN; } if(!initImplicitContext(module)) { - return; + INIT_RETURN; } if(!initEndpoint(module)) { - return; + INIT_RETURN; } if(!initEndpointInfo(module)) { - return; + INIT_RETURN; } + +#if PY_VERSION_HEX >= 0x03000000 + return module; +#endif } diff --git a/py/modules/IcePy/Logger.cpp b/py/modules/IcePy/Logger.cpp index 3d7bca5d895..bacf5c45395 100644 --- a/py/modules/IcePy/Logger.cpp +++ b/py/modules/IcePy/Logger.cpp @@ -108,9 +108,9 @@ IcePy::LoggerWrapper::getObject() extern "C" #endif static LoggerObject* -loggerNew(PyObject* /*arg*/) +loggerNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - LoggerObject* self = PyObject_New(LoggerObject, &LoggerType); + LoggerObject* self = reinterpret_cast<LoggerObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -126,7 +126,7 @@ static void loggerDealloc(LoggerObject* self) { delete self->logger; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -338,8 +338,7 @@ PyTypeObject LoggerType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Logger"), /* tp_name */ sizeof(LoggerObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -348,7 +347,7 @@ PyTypeObject LoggerType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -403,7 +402,7 @@ IcePy::initLogger(PyObject* module) PyObject* IcePy::createLogger(const Ice::LoggerPtr& logger) { - LoggerObject* obj = loggerNew(0); + LoggerObject* obj = loggerNew(&LoggerType, 0, 0); if(obj) { obj->logger = new Ice::LoggerPtr(logger); diff --git a/py/modules/IcePy/ObjectAdapter.cpp b/py/modules/IcePy/ObjectAdapter.cpp index 5e55ff3fc91..a45274bca62 100644 --- a/py/modules/IcePy/ObjectAdapter.cpp +++ b/py/modules/IcePy/ObjectAdapter.cpp @@ -269,7 +269,7 @@ IcePy::ServantLocatorWrapper::Cookie::~Cookie() extern "C" #endif static ObjectAdapterObject* -adapterNew(PyObject* /*arg*/) +adapterNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { PyErr_Format(PyExc_RuntimeError, STRCAST("Use communicator.createObjectAdapter to create an adapter")); return 0; @@ -294,7 +294,7 @@ adapterDealloc(ObjectAdapterObject* self) delete self->deactivateThread; delete self->holdMonitor; delete self->holdThread; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -1661,8 +1661,7 @@ PyTypeObject ObjectAdapterType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.ObjectAdapter"), /* tp_name */ sizeof(ObjectAdapterObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1671,7 +1670,7 @@ PyTypeObject ObjectAdapterType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1728,7 +1727,8 @@ IcePy::initObjectAdapter(PyObject* module) PyObject* IcePy::createObjectAdapter(const Ice::ObjectAdapterPtr& adapter) { - ObjectAdapterObject* obj = PyObject_New(ObjectAdapterObject, &ObjectAdapterType); + ObjectAdapterObject* obj = + reinterpret_cast<ObjectAdapterObject*>(ObjectAdapterType.tp_alloc(&ObjectAdapterType, 0)); if(obj) { obj->adapter = new Ice::ObjectAdapterPtr(adapter); diff --git a/py/modules/IcePy/Operation.cpp b/py/modules/IcePy/Operation.cpp index 8d8c1b8e6e2..4a14afcb137 100644 --- a/py/modules/IcePy/Operation.cpp +++ b/py/modules/IcePy/Operation.cpp @@ -480,9 +480,9 @@ callSent(PyObject* callback, const string& method, bool sentSynchronously, bool extern "C" #endif static OperationObject* -operationNew(PyObject* /*arg*/) +operationNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - OperationObject* self = PyObject_New(OperationObject, &OperationType); + OperationObject* self = reinterpret_cast<OperationObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -528,7 +528,7 @@ static void operationDealloc(OperationObject* self) { delete self->op; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -642,9 +642,9 @@ operationDeprecate(OperationObject* self, PyObject* args) extern "C" #endif static AMDCallbackObject* -amdCallbackNew(PyObject* /*arg*/) +amdCallbackNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - AMDCallbackObject* self = PyObject_New(AMDCallbackObject, &AMDCallbackType); + AMDCallbackObject* self = reinterpret_cast<AMDCallbackObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -660,7 +660,7 @@ static void amdCallbackDealloc(AMDCallbackObject* self) { delete self->upcall; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -724,9 +724,9 @@ amdCallbackIceException(AMDCallbackObject* self, PyObject* args) extern "C" #endif static AsyncResultObject* -asyncResultNew(PyObject* /*arg*/) +asyncResultNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - AsyncResultObject* self = PyObject_New(AsyncResultObject, &AsyncResultType); + AsyncResultObject* self = reinterpret_cast<AsyncResultObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -750,7 +750,7 @@ asyncResultDealloc(AsyncResultObject* self) Py_XDECREF(self->proxy); Py_XDECREF(self->connection); Py_XDECREF(self->communicator); - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -992,15 +992,15 @@ IcePy::Operation::Operation(const char* n, PyObject* m, PyObject* sm, int amdFla // mode // PyObjectHandle modeValue = PyObject_GetAttrString(m, STRCAST("value")); - assert(PyInt_Check(modeValue.get())); - mode = (Ice::OperationMode)static_cast<int>(PyInt_AS_LONG(modeValue.get())); + mode = (Ice::OperationMode)static_cast<int>(PyLong_AsLong(modeValue.get())); + assert(!PyErr_Occurred()); // // sendMode // PyObjectHandle sendModeValue = PyObject_GetAttrString(sm, STRCAST("value")); - assert(PyInt_Check(sendModeValue.get())); - sendMode = (Ice::OperationMode)static_cast<int>(PyInt_AS_LONG(sendModeValue.get())); + sendMode = (Ice::OperationMode)static_cast<int>(PyLong_AsLong(sendModeValue.get())); + assert(!PyErr_Occurred()); // // amd @@ -1169,8 +1169,7 @@ PyTypeObject OperationType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Operation"), /* tp_name */ sizeof(OperationObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1179,7 +1178,7 @@ PyTypeObject OperationType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1217,8 +1216,7 @@ PyTypeObject AMDCallbackType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.AMDCallback"), /* tp_name */ sizeof(AMDCallbackObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1227,7 +1225,7 @@ PyTypeObject AMDCallbackType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1265,8 +1263,7 @@ PyTypeObject AsyncResultType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.AsyncResult"), /* tp_name */ sizeof(AsyncResultObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -1275,7 +1272,7 @@ PyTypeObject AsyncResultType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1651,7 +1648,8 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) // // Unmarshal a user exception. // - pair<const Ice::Byte*, const Ice::Byte*> rb(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + pair<const Ice::Byte*, const Ice::Byte*> rb(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(!result.empty()) { rb.first = &result[0]; @@ -1671,7 +1669,8 @@ IcePy::SyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) // Unmarshal the results. If there is more than one value to be returned, then return them // in a tuple of the form (result, outParam1, ...). Otherwise just return the value. // - pair<const Ice::Byte*, const Ice::Byte*> rb(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + pair<const Ice::Byte*, const Ice::Byte*> rb(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(!result.empty()) { rb.first = &result[0]; @@ -1886,7 +1885,7 @@ IcePy::AsyncTypedInvocation::invoke(PyObject* args, PyObject* /* kwds */) } assert(result); - AsyncResultObject* obj = asyncResultNew(0); + AsyncResultObject* obj = asyncResultNew(&AsyncResultType, 0, 0); if(!obj) { return 0; @@ -2266,31 +2265,48 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) PyObject* inParams; PyObject* operationModeType = lookupType("Ice.OperationMode"); PyObject* ctx = 0; +#if PY_VERSION_HEX >= 0x03000000 + if(!PyArg_ParseTuple(args, STRCAST("sO!O!|O"), &operation, operationModeType, &mode, &PyBytes_Type, &inParams, + &ctx)) + { + return 0; + } +#else if(!PyArg_ParseTuple(args, STRCAST("sO!O!|O"), &operation, operationModeType, &mode, &PyBuffer_Type, &inParams, &ctx)) { return 0; } +#endif PyObjectHandle modeValue = PyObject_GetAttrString(mode, STRCAST("value")); - Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyInt_AS_LONG(modeValue.get())); + Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyLong_AsLong(modeValue.get())); + assert(!PyErr_Occurred()); +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = PyBytes_GET_SIZE(inParams); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); + if(sz > 0) + { + in.first = reinterpret_cast<Ice::Byte*>(PyBytes_AS_STRING(inParams)); + in.second = in.first + sz; + } +#else // // Use the array API to avoid copying the data. // -#if PY_VERSION_HEX < 0x02050000 - const char* charBuf = 0; -#else char* charBuf = 0; -#endif Py_ssize_t sz = inParams->ob_type->tp_as_buffer->bf_getcharbuffer(inParams, 0, &charBuf); const Ice::Byte* mem = reinterpret_cast<const Ice::Byte*>(charBuf); - pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(sz > 0) { in.first = mem; in.second = mem + sz; } +#endif try { @@ -2328,11 +2344,26 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) throwPythonException(); } +#if PY_VERSION_HEX >= 0x03000000 + PyObjectHandle op; + if(out.empty()) + { + op = PyBytes_FromString(""); + } + else + { + op = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&out[0]), out.size()); + } + if(!op.get()) + { + throwPythonException(); + } +#else // // Create the output buffer and copy in the outParams. // - PyObjectHandle ip = PyBuffer_New(out.size()); - if(!ip.get()) + PyObjectHandle op = PyBuffer_New(out.size()); + if(!op.get()) { throwPythonException(); } @@ -2340,18 +2371,19 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) { void* buf; Py_ssize_t sz; - if(PyObject_AsWriteBuffer(ip.get(), &buf, &sz)) + if(PyObject_AsWriteBuffer(op.get(), &buf, &sz)) { throwPythonException(); } memcpy(buf, &out[0], sz); } +#endif - if(PyTuple_SET_ITEM(result.get(), 1, ip.get()) < 0) + if(PyTuple_SET_ITEM(result.get(), 1, op.get()) < 0) { throwPythonException(); } - ip.release(); // PyTuple_SET_ITEM steals a reference. + op.release(); // PyTuple_SET_ITEM steals a reference. return result.release(); } @@ -2403,16 +2435,25 @@ IcePy::AsyncBlobjectInvocation::invoke(PyObject* args, PyObject* kwds) PyObject* ex = Py_None; PyObject* sent = Py_None; PyObject* pyctx = Py_None; +#if PY_VERSION_HEX >= 0x03000000 + if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("sO!O!|OOOO"), argNames, &operation, operationModeType, &mode, + &PyBytes_Type, &inParams, &response, &ex, &sent, &pyctx)) + { + return 0; + } +#else if(!PyArg_ParseTupleAndKeywords(args, kwds, STRCAST("sO!O!|OOOO"), argNames, &operation, operationModeType, &mode, &PyBuffer_Type, &inParams, &response, &ex, &sent, &pyctx)) { return 0; } +#endif _op = operation; PyObjectHandle modeValue = PyObject_GetAttrString(mode, STRCAST("value")); - Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyInt_AS_LONG(modeValue.get())); + Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyLong_AsLong(modeValue.get())); + assert(!PyErr_Occurred()); if(PyCallable_Check(response)) { @@ -2460,22 +2501,30 @@ IcePy::AsyncBlobjectInvocation::invoke(PyObject* args, PyObject* kwds) return 0; } +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = PyBytes_GET_SIZE(inParams); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); + if(sz > 0) + { + in.first = reinterpret_cast<Ice::Byte*>(PyBytes_AS_STRING(inParams)); + in.second = in.first + sz; + } +#else // // Use the array API to avoid copying the data. // -#if PY_VERSION_HEX < 0x02050000 - const char* charBuf = 0; -#else char* charBuf = 0; -#endif Py_ssize_t sz = inParams->ob_type->tp_as_buffer->bf_getcharbuffer(inParams, 0, &charBuf); const Ice::Byte* mem = reinterpret_cast<const Ice::Byte*>(charBuf); - pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(sz > 0) { in.first = mem; in.second = mem + sz; } +#endif Ice::AsyncResultPtr result; try @@ -2536,7 +2585,7 @@ IcePy::AsyncBlobjectInvocation::invoke(PyObject* args, PyObject* kwds) } assert(result); - AsyncResultObject* obj = asyncResultNew(0); + AsyncResultObject* obj = asyncResultNew(&AsyncResultType, 0, 0); if(!obj) { return 0; @@ -2576,29 +2625,46 @@ IcePy::AsyncBlobjectInvocation::end(const Ice::ObjectPrx& proxy, const Ice::Asyn return 0; } +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = results.second - results.first; + PyObjectHandle op; + if(sz == 0) + { + op = PyBytes_FromString(""); + } + else + { + op = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(results.first), sz); + } + if(!op.get()) + { + return 0; + } +#else // // Create the output buffer and copy in the outParams. // - PyObjectHandle ip = PyBuffer_New(results.second - results.first); - if(!ip.get()) + PyObjectHandle op = PyBuffer_New(results.second - results.first); + if(!op.get()) { return 0; } void* buf; Py_ssize_t sz; - if(PyObject_AsWriteBuffer(ip.get(), &buf, &sz)) + if(PyObject_AsWriteBuffer(op.get(), &buf, &sz)) { return 0; } assert(sz == results.second - results.first); memcpy(buf, results.first, sz); +#endif - if(PyTuple_SET_ITEM(args.get(), 1, ip.get()) < 0) + if(PyTuple_SET_ITEM(args.get(), 1, op.get()) < 0) { return 0; } - ip.release(); // PyTuple_SET_ITEM steals a reference. + op.release(); // PyTuple_SET_ITEM steals a reference. return args.release(); } @@ -2644,11 +2710,29 @@ IcePy::AsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*, c return; } +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = results.second - results.first; + PyObjectHandle op; + if(sz == 0) + { + op = PyBytes_FromString(""); + } + else + { + op = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(results.first), sz); + } + if(!op.get()) + { + assert(PyErr_Occurred()); + PyErr_Print(); + return; + } +#else // // Create the output buffer and copy in the outParams. // - PyObjectHandle ip = PyBuffer_New(results.second - results.first); - if(!ip.get()) + PyObjectHandle op = PyBuffer_New(results.second - results.first); + if(!op.get()) { assert(PyErr_Occurred()); PyErr_Print(); @@ -2657,7 +2741,7 @@ IcePy::AsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*, c void* buf; Py_ssize_t sz; - if(PyObject_AsWriteBuffer(ip.get(), &buf, &sz)) + if(PyObject_AsWriteBuffer(op.get(), &buf, &sz)) { assert(PyErr_Occurred()); PyErr_Print(); @@ -2665,14 +2749,15 @@ IcePy::AsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*, c } assert(sz == results.second - results.first); memcpy(buf, results.first, sz); +#endif - if(PyTuple_SET_ITEM(args.get(), 1, ip.get()) < 0) + if(PyTuple_SET_ITEM(args.get(), 1, op.get()) < 0) { assert(PyErr_Occurred()); PyErr_Print(); return; } - ip.release(); // PyTuple_SET_ITEM steals a reference. + op.release(); // PyTuple_SET_ITEM steals a reference. PyObjectHandle tmp = PyObject_Call(_response, args.get(), 0); if(PyErr_Occurred()) @@ -2723,34 +2808,51 @@ IcePy::OldAsyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) PyObject* inParams; PyObject* operationModeType = lookupType("Ice.OperationMode"); PyObject* ctx = 0; +#if PY_VERSION_HEX >= 0x03000000 + if(!PyArg_ParseTuple(args, STRCAST("OsO!O!|O"), &_callback, &operation, operationModeType, &mode, + &PyBytes_Type, &inParams, &ctx)) + { + return 0; + } +#else if(!PyArg_ParseTuple(args, STRCAST("OsO!O!|O"), &_callback, &operation, operationModeType, &mode, &PyBuffer_Type, &inParams, &ctx)) { return 0; } +#endif Py_INCREF(_callback); _op = operation; PyObjectHandle modeValue = PyObject_GetAttrString(mode, STRCAST("value")); - Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyInt_AS_LONG(modeValue.get())); + Ice::OperationMode sendMode = (Ice::OperationMode)static_cast<int>(PyLong_AsLong(modeValue.get())); + assert(!PyErr_Occurred()); +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = PyBytes_GET_SIZE(inParams); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); + if(sz > 0) + { + in.first = reinterpret_cast<Ice::Byte*>(PyBytes_AS_STRING(inParams)); + in.second = in.first + sz; + } +#else // // Use the array API to avoid copying the data. // -#if PY_VERSION_HEX < 0x02050000 - const char* charBuf = 0; -#else char* charBuf = 0; -#endif Py_ssize_t sz = inParams->ob_type->tp_as_buffer->bf_getcharbuffer(inParams, 0, &charBuf); const Ice::Byte* mem = reinterpret_cast<const Ice::Byte*>(charBuf); - pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), static_cast<const Ice::Byte*>(0)); + pair<const ::Ice::Byte*, const ::Ice::Byte*> in(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(sz > 0) { in.first = mem; in.second = mem + sz; } +#endif bool sentSynchronously = false; try @@ -2824,11 +2926,29 @@ IcePy::OldAsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte* return; } +#if PY_VERSION_HEX >= 0x03000000 + Py_ssize_t sz = results.second - results.first; + PyObjectHandle op; + if(sz == 0) + { + op = PyBytes_FromString(""); + } + else + { + op = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(results.first), sz); + } + if(!op.get()) + { + assert(PyErr_Occurred()); + PyErr_Print(); + return; + } +#else // // Create the output buffer and copy in the outParams. // - PyObjectHandle ip = PyBuffer_New(results.second - results.first); - if(!ip.get()) + PyObjectHandle op = PyBuffer_New(results.second - results.first); + if(!op.get()) { assert(PyErr_Occurred()); PyErr_Print(); @@ -2837,7 +2957,7 @@ IcePy::OldAsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte* void* buf; Py_ssize_t sz; - if(PyObject_AsWriteBuffer(ip.get(), &buf, &sz)) + if(PyObject_AsWriteBuffer(op.get(), &buf, &sz)) { assert(PyErr_Occurred()); PyErr_Print(); @@ -2845,14 +2965,15 @@ IcePy::OldAsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte* } assert(sz == results.second - results.first); memcpy(buf, results.first, sz); +#endif - if(PyTuple_SET_ITEM(args.get(), 1, ip.get()) < 0) + if(PyTuple_SET_ITEM(args.get(), 1, op.get()) < 0) { assert(PyErr_Occurred()); PyErr_Print(); return; } - ip.release(); // PyTuple_SET_ITEM steals a reference. + op.release(); // PyTuple_SET_ITEM steals a reference. const string methodName = "ice_response"; if(!PyObject_HasAttrString(_callback, STRCAST(methodName.c_str()))) @@ -2967,7 +3088,7 @@ IcePy::TypedUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, con // // Create the callback object and pass it as the first argument. // - AMDCallbackObject* obj = amdCallbackNew(0); + AMDCallbackObject* obj = amdCallbackNew(&AMDCallbackType, 0, 0); if(!obj) { throwPythonException(); @@ -3109,7 +3230,8 @@ IcePy::TypedUpcall::response(PyObject* args) Ice::ByteSeq bytes; os->finished(bytes); - pair<const Ice::Byte*, const Ice::Byte*> ob(static_cast<const Ice::Byte*>(0), static_cast<const Ice::Byte*>(0)); + pair<const Ice::Byte*, const Ice::Byte*> ob(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(!bytes.empty()) { ob.first = &bytes[0]; @@ -3188,7 +3310,8 @@ IcePy::TypedUpcall::exception(PyException& ex) Ice::ByteSeq bytes; os->finished(bytes); - pair<const Ice::Byte*, const Ice::Byte*> ob(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + pair<const Ice::Byte*, const Ice::Byte*> ob(static_cast<const Ice::Byte*>(0), + static_cast<const Ice::Byte*>(0)); if(!bytes.empty()) { ob.first = &bytes[0]; @@ -3259,12 +3382,23 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, throwPythonException(); } + PyObjectHandle ip; + +#if PY_VERSION_HEX >= 0x03000000 + if(inBytes.second == inBytes.first) + { + ip = PyBytes_FromString(""); + } + else + { + ip = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(inBytes.first), inBytes.second - inBytes.first); + } +#else // // If using AMD we need to copy the bytes since the bytes may be // accessed after this method is over, otherwise // PyBuffer_FromMemory can be used which doesn't do a copy. // - PyObjectHandle ip; if(!_amd) { ip = PyBuffer_FromMemory((void*)inBytes.first, inBytes.second - inBytes.first); @@ -3289,6 +3423,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, assert(sz == inBytes.second - inBytes.first); memcpy(buf, inBytes.first, sz); } +#endif if(PyTuple_SET_ITEM(args.get(), start, ip.get()) < 0) { @@ -3315,7 +3450,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, // // Create the callback object and pass it as the first argument. // - AMDCallbackObject* obj = amdCallbackNew(0); + AMDCallbackObject* obj = amdCallbackNew(&AMDCallbackType, 0, 0); if(!obj) { throwPythonException(); @@ -3377,7 +3512,7 @@ IcePy::BlobjectUpcall::response(PyObject* args) _finished = true; // - // The return value is a tuple of (bool, PyBuffer). + // The return value is a tuple of (bool, results). // if(!PyTuple_Check(args) || PyTuple_GET_SIZE(args) != 2) { @@ -3397,7 +3532,9 @@ IcePy::BlobjectUpcall::response(PyObject* args) int isTrue = PyObject_IsTrue(arg); arg = PyTuple_GET_ITEM(args, 1); - if(!PyBuffer_Check(arg)) + +#if PY_VERSION_HEX >= 0x03000000 + if(!PyBytes_Check(arg)) { ostringstream ostr; ostr << "invalid return value for operation `ice_invoke'"; @@ -3406,17 +3543,31 @@ IcePy::BlobjectUpcall::response(PyObject* args) throw Ice::MarshalException(__FILE__, __LINE__); } -#if PY_VERSION_HEX < 0x02050000 - const char* charBuf = 0; + Py_ssize_t sz = PyBytes_GET_SIZE(arg); + pair<const ::Ice::Byte*, const ::Ice::Byte*> r(static_cast<const Ice::Byte*>(0),static_cast<const Ice::Byte*>(0)); + if(sz > 0) + { + r.first = reinterpret_cast<Ice::Byte*>(PyBytes_AS_STRING(arg)); + r.second = r.first + sz; + } #else + if(!PyBuffer_Check(arg)) + { + ostringstream ostr; + ostr << "invalid return value for operation `ice_invoke'"; + string str = ostr.str(); + PyErr_Warn(PyExc_RuntimeWarning, const_cast<char*>(str.c_str())); + throw Ice::MarshalException(__FILE__, __LINE__); + } + char* charBuf = 0; -#endif Py_ssize_t sz = arg->ob_type->tp_as_buffer->bf_getcharbuffer(arg, 0, &charBuf); const Ice::Byte* mem = reinterpret_cast<const Ice::Byte*>(charBuf); - const pair<const ::Ice::Byte*, const ::Ice::Byte*> bytes(mem, mem + sz); + const pair<const ::Ice::Byte*, const ::Ice::Byte*> r(mem, mem + sz); +#endif AllowThreads allowThreads; // Release Python's global interpreter lock during blocking calls. - _callback->ice_response(isTrue, bytes); + _callback->ice_response(isTrue, r); } void @@ -3564,7 +3715,7 @@ IcePy::endIceInvoke(PyObject* proxy, PyObject* args) PyObject* IcePy::createAsyncResult(const Ice::AsyncResultPtr& r, PyObject* proxy, PyObject* connection, PyObject* communicator) { - AsyncResultObject* obj = asyncResultNew(0); + AsyncResultObject* obj = asyncResultNew(&AsyncResultType, 0, 0); if(!obj) { return 0; diff --git a/py/modules/IcePy/Properties.cpp b/py/modules/IcePy/Properties.cpp index 039df377b75..77d68c664da 100644 --- a/py/modules/IcePy/Properties.cpp +++ b/py/modules/IcePy/Properties.cpp @@ -33,9 +33,9 @@ struct PropertiesObject extern "C" #endif static PropertiesObject* -propertiesNew(PyObject* /*arg*/) +propertiesNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - PropertiesObject* self = PyObject_New(PropertiesObject, &PropertiesType); + PropertiesObject* self = reinterpret_cast<PropertiesObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -138,7 +138,7 @@ static void propertiesDealloc(PropertiesObject* self) { delete self->properties; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 @@ -275,7 +275,7 @@ propertiesGetPropertyAsInt(PropertiesObject* self, PyObject* args) return 0; } - return PyInt_FromLong(value); + return PyLong_FromLong(value); } #ifdef WIN32 @@ -309,7 +309,7 @@ propertiesGetPropertyAsIntWithDefault(PropertiesObject* self, PyObject* args) return 0; } - return PyInt_FromLong(value); + return PyLong_FromLong(value); } #ifdef WIN32 @@ -709,8 +709,7 @@ PyTypeObject PropertiesType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.Properties"), /* tp_name */ sizeof(PropertiesObject), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -719,7 +718,7 @@ PyTypeObject PropertiesType = 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -774,7 +773,7 @@ IcePy::initProperties(PyObject* module) PyObject* IcePy::createProperties(const Ice::PropertiesPtr& props) { - PropertiesObject* obj = propertiesNew(0); + PropertiesObject* obj = propertiesNew(&PropertiesType, 0, 0); if(obj) { obj->properties = new Ice::PropertiesPtr(props); diff --git a/py/modules/IcePy/Proxy.cpp b/py/modules/IcePy/Proxy.cpp index f7c67609c06..90df0035ad8 100644 --- a/py/modules/IcePy/Proxy.cpp +++ b/py/modules/IcePy/Proxy.cpp @@ -72,7 +72,7 @@ allocateProxy(const Ice::ObjectPrx& proxy, const Ice::CommunicatorPtr& communica extern "C" #endif static ProxyObject* -proxyNew(PyObject* /*arg*/) +proxyNew(PyTypeObject* /*type*/, PyObject* /*args*/, PyObject* /*kwds*/) { PyErr_Format(PyExc_RuntimeError, STRCAST("A proxy cannot be created directly")); return 0; @@ -86,27 +86,63 @@ proxyDealloc(ProxyObject* self) { delete self->proxy; delete self->communicator; - self->ob_type->tp_free(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 extern "C" #endif -static int -proxyCompare(ProxyObject* p1, ProxyObject* p2) +static PyObject* +proxyCompare(ProxyObject* p1, PyObject* other, int op) { - if(*p1->proxy < *p2->proxy) - { - return -1; - } - else if(*p1->proxy == *p2->proxy) + bool result; + + if(PyObject_TypeCheck(other, &ProxyType)) { - return 0; + ProxyObject* p2 = reinterpret_cast<ProxyObject*>(other); + + switch(op) + { + case Py_EQ: + result = *p1->proxy == *p2->proxy; + break; + case Py_NE: + result = *p1->proxy != *p2->proxy; + break; + case Py_LE: + result = *p1->proxy <= *p2->proxy; + break; + case Py_GE: + result = *p1->proxy >= *p2->proxy; + break; + case Py_LT: + result = *p1->proxy < *p2->proxy; + break; + case Py_GT: + result = *p1->proxy > *p2->proxy; + break; + } } else { - return 1; + if(op == Py_EQ) + { + result = false; + } + else if(op == Py_NE) + { + result = true; + } + else + { + PyErr_Format(PyExc_TypeError, "can't compare %s to %s", Py_TYPE(p1)->tp_name, Py_TYPE(other)->tp_name); + return 0; + } } + + PyObject* r = result ? getTrue() : getFalse(); + Py_INCREF(r); + return r; } #ifdef WIN32 @@ -504,7 +540,7 @@ proxyIceContext(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -616,7 +652,7 @@ proxyIceAdapterId(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -704,7 +740,7 @@ proxyIceEndpoints(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -718,7 +754,7 @@ proxyIceGetLocatorCacheTimeout(ProxyObject* self) try { Ice::Int timeout = (*self->proxy)->ice_getLocatorCacheTimeout(); - return PyInt_FromLong(timeout); + return PyLong_FromLong(timeout); } catch(const Ice::Exception& ex) { @@ -772,7 +808,7 @@ proxyIceLocatorCacheTimeout(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -829,7 +865,7 @@ proxyIceConnectionCached(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -917,7 +953,7 @@ proxyIceEndpointSelection(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -974,8 +1010,7 @@ proxyIceSecure(ProxyObject* self, PyObject* args) return 0; } - PyTypeObject* type = self->ob_type; // Necessary to prevent GCC's strict-alias warnings. - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1032,7 +1067,7 @@ proxyIcePreferSecure(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1098,7 +1133,7 @@ proxyIceRouter(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1164,7 +1199,7 @@ proxyIceLocator(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1186,7 +1221,7 @@ proxyIceTwoway(ProxyObject* self) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1231,7 +1266,7 @@ proxyIceOneway(ProxyObject* self) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1276,7 +1311,7 @@ proxyIceBatchOneway(ProxyObject* self) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1321,7 +1356,7 @@ proxyIceDatagram(ProxyObject* self) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1366,7 +1401,7 @@ proxyIceBatchDatagram(ProxyObject* self) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1423,7 +1458,7 @@ proxyIceCompress(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1451,7 +1486,7 @@ proxyIceTimeout(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } // NOTE: ice_collocationOptimized is not currently supported. @@ -1487,7 +1522,7 @@ proxyIceConnectionId(ProxyObject* self, PyObject* args) return 0; } - return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(self->ob_type)); + return createProxy(newProxy, *self->communicator, reinterpret_cast<PyObject*>(Py_TYPE(self))); } #ifdef WIN32 @@ -1901,7 +1936,7 @@ proxyIceCheckedCast(PyObject* type, PyObject* args) PyObject* facet = 0; - if(PyString_Check(facetOrCtx)) + if(checkString(facetOrCtx)) { facet = facetOrCtx; } @@ -2013,7 +2048,7 @@ proxyCheckedCast(PyObject* /*self*/, PyObject* args) if(arg1 != 0) { - if(!PyString_Check(arg1)) + if(!checkString(arg1)) { PyErr_Format(PyExc_ValueError, STRCAST("facet argument to checkedCast must be a string")); return 0; @@ -2030,7 +2065,7 @@ proxyCheckedCast(PyObject* /*self*/, PyObject* args) } else if(arg1 != 0 && arg1 != Py_None) { - if(PyString_Check(arg1)) + if(checkString(arg1)) { facet = arg1; } @@ -2238,33 +2273,37 @@ PyTypeObject ProxyType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.ObjectPrx"), /* tp_name */ sizeof(ProxyObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)proxyDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(proxyDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)proxyCompare, /* tp_compare */ - (reprfunc)proxyRepr, /* tp_repr */ + 0, /* tp_reserved */ + reinterpret_cast<reprfunc>(proxyRepr), /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)proxyHash, /* tp_hash */ + reinterpret_cast<hashfunc>(proxyHash), /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ +#if PY_VERSION_HEX >= 0x03000000 + Py_TPFLAGS_BASETYPE, /* tp_flags */ +#else Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HAVE_RICHCOMPARE | Py_TPFLAGS_HAVE_CLASS, /* tp_flags */ +#endif 0, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - 0, /* tp_richcompare */ + reinterpret_cast<richcmpfunc>(proxyCompare), /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ @@ -2278,7 +2317,7 @@ PyTypeObject ProxyType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)proxyNew, /* tp_new */ + reinterpret_cast<newfunc>(proxyNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; diff --git a/py/modules/IcePy/Slice.cpp b/py/modules/IcePy/Slice.cpp index 7eb6b4b03aa..5d5575093ea 100644 --- a/py/modules/IcePy/Slice.cpp +++ b/py/modules/IcePy/Slice.cpp @@ -185,7 +185,11 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) } PyDict_SetItemString(globals.get(), "__builtins__", PyEval_GetBuiltins()); +#if PY_VERSION_HEX >= 0x03000000 + PyObjectHandle val = PyEval_EvalCode(src.get(), globals.get(), 0); +#else PyObjectHandle val = PyEval_EvalCode(reinterpret_cast<PyCodeObject*>(src.get()), globals.get(), 0); +#endif if(!val.get()) { return 0; diff --git a/py/modules/IcePy/Types.cpp b/py/modules/IcePy/Types.cpp index 2a491a75549..dfd043ebc47 100644 --- a/py/modules/IcePy/Types.cpp +++ b/py/modules/IcePy/Types.cpp @@ -82,11 +82,11 @@ writeString(PyObject* p, const Ice::OutputStreamPtr& os) { os->write(string()); } - else if(PyString_Check(p)) + else if(checkString(p)) { - os->write(string(PyString_AS_STRING(p), PyString_GET_SIZE(p))); + os->write(getString(p)); } -#ifdef Py_USING_UNICODE +#if defined(Py_USING_UNICODE) && PY_VERSION_HEX < 0x03000000 else if(PyUnicode_Check(p)) { // @@ -98,7 +98,7 @@ writeString(PyObject* p, const Ice::OutputStreamPtr& os) { return false; } - os->write(string(PyString_AS_STRING(h.get()), PyString_GET_SIZE(h.get())), false); + os->write(getString(h.get()), false); } #endif else @@ -115,9 +115,9 @@ writeString(PyObject* p, const Ice::OutputStreamPtr& os) extern "C" #endif static TypeInfoObject* -typeInfoNew(PyObject* /*arg*/) +typeInfoNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - TypeInfoObject* self = PyObject_New(TypeInfoObject, &TypeInfoType); + TypeInfoObject* self = reinterpret_cast<TypeInfoObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -133,16 +133,16 @@ static void typeInfoDealloc(TypeInfoObject* self) { delete self->info; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } #ifdef WIN32 extern "C" #endif static ExceptionInfoObject* -exceptionInfoNew(PyObject* /*arg*/) +exceptionInfoNew(PyTypeObject* type, PyObject* /*args*/, PyObject* /*kwds*/) { - ExceptionInfoObject* self = PyObject_New(ExceptionInfoObject, &ExceptionInfoType); + ExceptionInfoObject* self = reinterpret_cast<ExceptionInfoObject*>(type->tp_alloc(type, 0)); if(!self) { return 0; @@ -158,7 +158,7 @@ static void exceptionInfoDealloc(ExceptionInfoObject* self) { delete self->info; - PyObject_Del(self); + Py_TYPE(self)->tp_free(reinterpret_cast<PyObject*>(self)); } // @@ -306,25 +306,7 @@ IcePy::PrimitiveInfo::validate(PyObject* p) } case PrimitiveInfo::KindByte: { - long val; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - return false; - } + long val = PyLong_AsLong(p); if(PyErr_Occurred() || val < 0 || val > 255) { @@ -334,25 +316,7 @@ IcePy::PrimitiveInfo::validate(PyObject* p) } case PrimitiveInfo::KindShort: { - long val; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - return false; - } + long val = PyLong_AsLong(p); if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) { @@ -362,25 +326,7 @@ IcePy::PrimitiveInfo::validate(PyObject* p) } case PrimitiveInfo::KindInt: { - long val; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - return false; - } + long val = PyLong_AsLong(p); if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) { @@ -390,18 +336,8 @@ IcePy::PrimitiveInfo::validate(PyObject* p) } case PrimitiveInfo::KindLong: { - PyObjectHandle n = PyNumber_Long(p); - if(n.get()) - { - p = n.get(); - } - - if(PyErr_Occurred() || (!PyInt_Check(p) && !PyLong_Check(p))) - { - return false; - } + PyLong_AsLongLong(p); // Just to see if it raises an error. - PyLong_AsLongLong(p); if(PyErr_Occurred()) { return false; @@ -412,24 +348,36 @@ IcePy::PrimitiveInfo::validate(PyObject* p) case PrimitiveInfo::KindFloat: case PrimitiveInfo::KindDouble: { - PyObjectHandle n = PyNumber_Float(p); - if(n.get()) + if(!PyFloat_Check(p)) { - p = n.get(); + if(PyLong_Check(p)) + { + PyLong_AsDouble(p); // Just to see if it raises an error. + if(PyErr_Occurred()) + { + return false; + } + } +#if PY_VERSION_HEX < 0x03000000 + else if(PyInt_Check(p)) + { + return true; + } +#endif + else + { + return false; + } } - if(!PyInt_Check(p) && !PyLong_Check(p) && !PyFloat_Check(p)) - { - return false; - } break; } case PrimitiveInfo::KindString: { -#ifdef Py_USING_UNICODE - if(p != Py_None && !PyString_Check(p) && !PyUnicode_Check(p)) +#if defined(Py_USING_UNICODE) && PY_VERSION_HEX < 0x03000000 + if(p != Py_None && !checkString(p) && !PyUnicode_Check(p)) #else - if(p != Py_None && !PyString_Check(p)) + if(p != Py_None && !checkString(p)) #endif { return false; @@ -458,26 +406,7 @@ IcePy::PrimitiveInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec } case PrimitiveInfo::KindByte: { - long val = 0; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - assert(false); // validate() should have caught this. - } - + long val = PyLong_AsLong(p); assert(!PyErr_Occurred()); // validate() should have caught this. assert(val >= 0 && val <= 255); // validate() should have caught this. os->write(static_cast<Ice::Byte>(val)); @@ -485,26 +414,7 @@ IcePy::PrimitiveInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec } case PrimitiveInfo::KindShort: { - long val = 0; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - assert(false); // validate() should have caught this. - } - + long val = PyLong_AsLong(p); assert(!PyErr_Occurred()); // validate() should have caught this. assert(val >= SHRT_MIN && val <= SHRT_MAX); // validate() should have caught this. os->write(static_cast<Ice::Short>(val)); @@ -512,26 +422,7 @@ IcePy::PrimitiveInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec } case PrimitiveInfo::KindInt: { - long val = 0; - PyObjectHandle n = PyNumber_Int(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLong(p); - } - else - { - assert(false); // validate() should have caught this. - } - + long val = PyLong_AsLong(p); assert(!PyErr_Occurred()); // validate() should have caught this. assert(val >= INT_MIN && val <= INT_MAX); // validate() should have caught this. os->write(static_cast<Ice::Int>(val)); @@ -539,54 +430,17 @@ IcePy::PrimitiveInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec } case PrimitiveInfo::KindLong: { - Ice::Long val = 0; - PyObjectHandle n = PyNumber_Long(p); - if(n.get()) - { - p = n.get(); - } - - if(PyInt_Check(p)) - { - val = PyInt_AS_LONG(p); - } - else if(PyLong_Check(p)) - { - val = PyLong_AsLongLong(p); - } - else - { - assert(false); // validate() should have caught this. - } - + Ice::Long val = PyLong_AsLongLong(p); assert(!PyErr_Occurred()); // validate() should have caught this. os->write(val); break; } case PrimitiveInfo::KindFloat: { - float val = 0; - PyObjectHandle n = PyNumber_Float(p); - if(n.get()) - { - p = n.get(); - } - - if(PyFloat_Check(p)) - { - val = static_cast<float>(PyFloat_AS_DOUBLE(p)); - } - else if(PyInt_Check(p)) - { - val = static_cast<float>(PyInt_AS_LONG(p)); - } - else if(PyLong_Check(p)) - { - val = static_cast<float>(PyLong_AsLongLong(p)); - } - else + float val = static_cast<float>(PyFloat_AsDouble(p)); // Attempts to perform conversion. + if(PyErr_Occurred()) { - assert(false); // validate() should have caught this. + throw AbortMarshaling(); } os->write(val); @@ -594,28 +448,10 @@ IcePy::PrimitiveInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, Objec } case PrimitiveInfo::KindDouble: { - double val = 0; - PyObjectHandle n = PyNumber_Float(p); - if(n.get()) - { - p = n.get(); - } - - if(PyFloat_Check(p)) - { - val = PyFloat_AS_DOUBLE(p); - } - else if(PyInt_Check(p)) - { - val = static_cast<double>(PyInt_AS_LONG(p)); - } - else if(PyLong_Check(p)) - { - val = static_cast<double>(PyLong_AsLongLong(p)); - } - else + double val = PyFloat_AsDouble(p); // Attempts to perform conversion. + if(PyErr_Occurred()) { - assert(false); + throw AbortMarshaling(); } os->write(val); @@ -657,7 +493,7 @@ IcePy::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCa { Ice::Byte val; is->read(val); - PyObjectHandle p = PyInt_FromLong(val); + PyObjectHandle p = PyLong_FromLong(val); cb->unmarshaled(p.get(), target, closure); break; } @@ -665,7 +501,7 @@ IcePy::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCa { Ice::Short val; is->read(val); - PyObjectHandle p = PyInt_FromLong(val); + PyObjectHandle p = PyLong_FromLong(val); cb->unmarshaled(p.get(), target, closure); break; } @@ -673,7 +509,7 @@ IcePy::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCa { Ice::Int val; is->read(val); - PyObjectHandle p = PyInt_FromLong(val); + PyObjectHandle p = PyLong_FromLong(val); cb->unmarshaled(p.get(), target, closure); break; } @@ -705,7 +541,7 @@ IcePy::PrimitiveInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCa { string val; is->read(val); - PyObjectHandle p = PyString_FromStringAndSize(val.c_str(), static_cast<Py_ssize_t>(val.size())); + PyObjectHandle p = createString(val); cb->unmarshaled(p.get(), target, closure); break; } @@ -725,8 +561,8 @@ IcePy::PrimitiveInfo::print(PyObject* value, IceUtilInternal::Output& out, Print { return; } - assert(PyString_Check(p.get())); - out << PyString_AS_STRING(p.get()); + assert(checkString(p.get())); + out << getString(p.get()); } // @@ -758,12 +594,16 @@ IcePy::EnumInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMap* assert(PyErr_Occurred()); throw AbortMarshaling(); } +#if PY_VERSION_HEX >= 0x03000000 + if(!PyLong_Check(val.get())) +#else if(!PyInt_Check(val.get())) +#endif { PyErr_Format(PyExc_ValueError, STRCAST("value for enum %s is not an int"), id.c_str()); throw AbortMarshaling(); } - Ice::Int ival = static_cast<Ice::Int>(PyInt_AsLong(val.get())); + Ice::Int ival = static_cast<Ice::Int>(PyLong_AsLong(val.get())); Ice::Int count = static_cast<Ice::Int>(enumerators.size()); if(ival < 0 || ival >= count) { @@ -832,8 +672,8 @@ IcePy::EnumInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObjec { return; } - assert(PyString_Check(p.get())); - out << PyString_AS_STRING(p.get()); + assert(checkString(p.get())); + out << getString(p.get()); } // @@ -1192,10 +1032,23 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje { if(pi->kind == PrimitiveInfo::KindByte) { +#if PY_VERSION_HEX >= 0x03000000 // - // Accept a string or a sequence for sequence<byte>. + // For sequence<byte>, accept a bytes object or a sequence. // - if(!PyString_Check(p)) + if(!PyBytes_Check(p)) + { + fs = PySequence_Fast(p, STRCAST("expected a bytes, sequence, or buffer value")); + if(!fs.get()) + { + return; + } + } +#else + // + // For sequence<byte>, accept a string or a sequence. + // + if(!checkString(p)) { fs = PySequence_Fast(p, STRCAST("expected a string, sequence, or buffer value")); if(!fs.get()) @@ -1203,6 +1056,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje return; } } +#endif } else { @@ -1244,10 +1098,17 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje { if(!fs.get()) { +#if PY_VERSION_HEX >= 0x03000000 + assert(PyBytes_Check(p)); + char* str; + PyBytes_AsStringAndSize(p, &str, &sz); + os->write(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); +#else assert(PyString_Check(p)); - const char* str = PyString_AS_STRING(p); - sz = PyString_GET_SIZE(p); + char* str; + PyString_AsStringAndSize(p, &str, &sz); os->write(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); +#endif } else { @@ -1262,21 +1123,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - long val = -1; - PyObjectHandle n = PyNumber_Int(item); - if(n.get()) - { - item = n.get(); - } - - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } + long val = PyLong_AsLong(item); if(PyErr_Occurred() || val < 0 || val > 255) { @@ -1303,21 +1150,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - long val = SHRT_MIN - 1; - PyObjectHandle n = PyNumber_Int(item); - if(n.get()) - { - item = n.get(); - } - - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } + long val = PyLong_AsLong(item); if(PyErr_Occurred() || val < SHRT_MIN || val > SHRT_MAX) { @@ -1343,27 +1176,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - long val; - PyObjectHandle n = PyNumber_Int(item); - if(n.get()) - { - item = n.get(); - } - - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<int>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } + long val = PyLong_AsLong(item); if(PyErr_Occurred() || val < INT_MIN || val > INT_MAX) { @@ -1389,27 +1202,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - Ice::Long val; - PyObjectHandle n = PyNumber_Long(item); - if(n.get()) - { - item = n.get(); - } - - if(PyInt_Check(item)) - { - val = PyInt_AS_LONG(item); - } - else if(PyLong_Check(item)) - { - val = PyLong_AsLongLong(item); - } - else - { - PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<long>"), - static_cast<int>(i)); - throw AbortMarshaling(); - } + Ice::Long val = PyLong_AsLongLong(item); if(PyErr_Occurred()) { @@ -1435,26 +1228,8 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - float val; - PyObjectHandle n = PyNumber_Float(item); - if(n.get()) - { - item = n.get(); - } - - if(PyFloat_Check(item)) - { - val = static_cast<float>(PyFloat_AS_DOUBLE(item)); - } - else if(PyInt_Check(item)) - { - val = static_cast<float>(PyInt_AS_LONG(item)); - } - else if(PyLong_Check(item)) - { - val = static_cast<float>(PyLong_AsLongLong(item)); - } - else + float val = static_cast<float>(PyFloat_AsDouble(item)); + if(PyErr_Occurred()) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<float>"), static_cast<int>(i)); @@ -1479,26 +1254,8 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - double val; - PyObjectHandle n = PyNumber_Float(item); - if(n.get()) - { - item = n.get(); - } - - if(PyFloat_Check(item)) - { - val = PyFloat_AS_DOUBLE(item); - } - else if(PyInt_Check(item)) - { - val = static_cast<double>(PyInt_AS_LONG(item)); - } - else if(PyLong_Check(item)) - { - val = static_cast<double>(PyLong_AsLongLong(item)); - } - else + double val = PyFloat_AsDouble(item); + if(PyErr_Occurred()) { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<double>"), static_cast<int>(i)); @@ -1523,10 +1280,10 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } -#ifdef Py_USING_UNICODE - if(item != Py_None && !PyString_Check(item) && !PyUnicode_Check(item)) +#if defined(Py_USING_UNICODE) && PY_VERSION_HEX < 0x03000000 + if(item != Py_None && !checkString(item) && !PyUnicode_Check(item)) #else - if(item != Py_None && !PyString_Check(item)) + if(item != Py_None && !checkString(item)) #endif { PyErr_Format(PyExc_ValueError, STRCAST("invalid value for element %d of sequence<string>"), @@ -1580,7 +1337,11 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons int sz = static_cast<int>(p.second - p.first); if(sm->type == SequenceMapping::SEQ_DEFAULT) { +#if PY_VERSION_HEX >= 0x03000000 + result = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); +#else result = PyString_FromStringAndSize(reinterpret_cast<const char*>(p.first), sz); +#endif if(!result.get()) { assert(PyErr_Occurred()); @@ -1598,7 +1359,7 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons for(int i = 0; i < sz; ++i) { - PyObjectHandle item = PyInt_FromLong(p.first[i]); + PyObjectHandle item = PyLong_FromLong(p.first[i]); if(!item.get()) { assert(PyErr_Occurred()); @@ -1624,7 +1385,7 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons for(int i = 0; i < sz; ++i) { - PyObjectHandle item = PyInt_FromLong(p.first[i]); + PyObjectHandle item = PyLong_FromLong(p.first[i]); if(!item.get()) { assert(PyErr_Occurred()); @@ -1649,7 +1410,7 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons for(int i = 0; i < sz; ++i) { - PyObjectHandle item = PyInt_FromLong(p.first[i]); + PyObjectHandle item = PyLong_FromLong(p.first[i]); if(!item.get()) { assert(PyErr_Occurred()); @@ -1748,7 +1509,7 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, cons for(int i = 0; i < sz; ++i) { - PyObjectHandle item = PyString_FromStringAndSize(seq[i].c_str(), static_cast<Py_ssize_t>(seq[i].size())); + PyObjectHandle item = createString(seq[i]); if(!item.get()) { assert(PyErr_Occurred()); @@ -1895,9 +1656,14 @@ IcePy::CustomInfo::marshal(PyObject* p, const Ice::OutputStreamPtr& os, ObjectMa throw AbortMarshaling(); } - assert(PyString_Check(obj.get())); - const char* str = PyString_AS_STRING(obj.get()); - Py_ssize_t sz = PyString_GET_SIZE(obj.get()); + assert(checkString(obj.get())); + char* str; + Py_ssize_t sz; +#if PY_VERSION_HEX >= 0x03000000 + PyBytes_AsStringAndSize(obj.get(), &str, &sz); +#else + PyString_AsStringAndSize(obj.get(), &str, &sz); +#endif os->write(reinterpret_cast<const Ice::Byte*>(str), reinterpret_cast<const Ice::Byte*>(str + sz)); } @@ -1942,7 +1708,11 @@ IcePy::CustomInfo::unmarshal(const Ice::InputStreamPtr& is, const UnmarshalCallb // // Convert the seq to a string. // +#if PY_VERSION_HEX >= 0x03000000 + obj = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(seq.first), sz); +#else obj = PyString_FromStringAndSize(reinterpret_cast<const char*>(seq.first), sz); +#endif if(!obj.get()) { assert(PyErr_Occurred()); @@ -2417,8 +2187,8 @@ IcePy::ProxyInfo::print(PyObject* value, IceUtilInternal::Output& out, PrintObje { return; } - assert(PyString_Check(p.get())); - out << PyString_AS_STRING(p.get()); + assert(checkString(p.get())); + out << getString(p.get()); } } @@ -2859,17 +2629,16 @@ PyTypeObject TypeInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.TypeInfo"), /* tp_name */ sizeof(TypeInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)typeInfoDealloc, /* tp_dealloc */ + reinterpret_cast<destructor>(typeInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2898,7 +2667,7 @@ PyTypeObject TypeInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)typeInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(typeInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -2907,17 +2676,16 @@ PyTypeObject ExceptionInfoType = { /* The ob_type field must be initialized in the module init function * to be portable to Windows without using C++. */ - PyObject_HEAD_INIT(0) - 0, /* ob_size */ + PyVarObject_HEAD_INIT(0, 0) STRCAST("IcePy.ExceptionInfo"), /* tp_name */ sizeof(ExceptionInfoObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)exceptionInfoDealloc,/* tp_dealloc */ + reinterpret_cast<destructor>(exceptionInfoDealloc), /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2946,7 +2714,7 @@ PyTypeObject ExceptionInfoType = 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - (newfunc)exceptionInfoNew, /* tp_new */ + reinterpret_cast<newfunc>(exceptionInfoNew), /* tp_new */ 0, /* tp_free */ 0, /* tp_is_gc */ }; @@ -3062,7 +2830,7 @@ IcePy::getType(PyObject* obj) PyObject* IcePy::createType(const TypeInfoPtr& info) { - TypeInfoObject* obj = typeInfoNew(0); + TypeInfoObject* obj = typeInfoNew(&TypeInfoType, 0, 0); if(obj) { obj->info = new IcePy::TypeInfoPtr(info); @@ -3081,7 +2849,7 @@ IcePy::getException(PyObject* obj) PyObject* IcePy::createException(const ExceptionInfoPtr& info) { - ExceptionInfoObject* obj = exceptionInfoNew(0); + ExceptionInfoObject* obj = exceptionInfoNew(&ExceptionInfoType, 0, 0); if(obj) { obj->info = new IcePy::ExceptionInfoPtr(info); @@ -3134,7 +2902,7 @@ convertDataMembers(PyObject* members, DataMemberList& l) assert(PyTuple_GET_SIZE(m) == 3); PyObject* name = PyTuple_GET_ITEM(m, 0); // Member name. - assert(PyString_Check(name)); + assert(checkString(name)); PyObject* meta = PyTuple_GET_ITEM(m, 1); // Member metadata. assert(PyTuple_Check(meta)); PyObject* t = PyTuple_GET_ITEM(m, 2); // Member type. diff --git a/py/modules/IcePy/Util.cpp b/py/modules/IcePy/Util.cpp index ed611029b5c..24d0ab25354 100644 --- a/py/modules/IcePy/Util.cpp +++ b/py/modules/IcePy/Util.cpp @@ -24,12 +24,23 @@ using namespace Slice::Python; string IcePy::getString(PyObject* p) { - assert(p == Py_None || PyString_Check(p)); + assert(p == Py_None || checkString(p)); string str; if(p != Py_None) { +#if PY_VERSION_HEX >= 0x03000000 + PyObjectHandle bytes = PyUnicode_AsUTF8String(p); + if(bytes.get()) + { + char* s; + Py_ssize_t sz; + PyBytes_AsStringAndSize(bytes.get(), &s, &sz); + str.assign(s, sz); + } +#else str.assign(PyString_AS_STRING(p), PyString_GET_SIZE(p)); +#endif } return str; } @@ -37,7 +48,7 @@ IcePy::getString(PyObject* p) bool IcePy::getStringArg(PyObject* p, const string& arg, string& val) { - if(PyString_Check(p)) + if(checkString(p)) { val = getString(p); } @@ -185,9 +196,13 @@ IcePy::PyException::raise() ostr << getTypeName(); IcePy::PyObjectHandle msg = PyObject_Str(ex.get()); - if(msg.get() && strlen(PyString_AsString(msg.get())) > 0) + if(msg.get()) { - ostr << ": " << PyString_AsString(msg.get()); + string s = getString(msg.get()); + if(!s.empty()) + { + ostr << ": " << s; + } } e.unknown = ostr.str(); @@ -238,13 +253,12 @@ IcePy::PyException::raiseLocalException() IcePy::getIdentity(member.get(), e.id); } member = PyObject_GetAttrString(ex.get(), STRCAST("facet")); - if(member.get() && PyString_Check(member.get())) + if(member.get() && checkString(member.get())) { - // TODO: Support unicode for the facet name. e.facet = getString(member.get()); } member = PyObject_GetAttrString(ex.get(), STRCAST("operation")); - if(member.get() && PyString_Check(member.get())) + if(member.get() && checkString(member.get())) { e.operation = getString(member.get()); } @@ -270,7 +284,7 @@ IcePy::PyException::raiseLocalException() { IcePy::PyObjectHandle member; member = PyObject_GetAttrString(ex.get(), STRCAST("unknown")); - if(member.get() && PyString_Check(member.get())) + if(member.get() && checkString(member.get())) { e.unknown = getString(member.get()); } @@ -304,7 +318,7 @@ IcePy::PyException::getTraceback() // import traceback // list = traceback.format_exception(type, ex, tb) // - PyObjectHandle str = PyString_FromString("traceback"); + PyObjectHandle str = createString("traceback"); PyObjectHandle mod = PyImport_Import(str.get()); assert(mod.get()); // Unable to import traceback module - Python installation error? PyObject* d = PyModule_GetDict(mod.get()); @@ -316,7 +330,8 @@ IcePy::PyException::getTraceback() string result; for(Py_ssize_t i = 0; i < PyList_GET_SIZE(list.get()); ++i) { - result += PyString_AsString(PyList_GetItem(list.get(), i)); + string s = getString(PyList_GetItem(list.get(), i)); + result += s; } return result; @@ -334,9 +349,9 @@ IcePy::PyException::getTypeName() assert(name.get()); PyObjectHandle mod = PyObject_GetAttrString(cls, "__module__"); assert(mod.get()); - string result = PyString_AsString(mod.get()); + string result = getString(mod.get()); result += "."; - result += PyString_AsString(name.get()); + result += getString(name.get()); return result; } @@ -374,7 +389,7 @@ IcePy::listToStringSeq(PyObject* l, Ice::StringSeq& seq) return false; } string str; - if(PyString_Check(item)) + if(checkString(item)) { str = getString(item); } @@ -428,7 +443,7 @@ IcePy::tupleToStringSeq(PyObject* t, Ice::StringSeq& seq) return false; } string str; - if(PyString_Check(item)) + if(checkString(item)) { str = getString(item); } @@ -454,7 +469,7 @@ IcePy::dictionaryToContext(PyObject* dict, Ice::Context& context) while(PyDict_Next(dict, &pos, &key, &value)) { string keystr; - if(PyString_Check(key)) + if(checkString(key)) { keystr = getString(key); } @@ -465,7 +480,7 @@ IcePy::dictionaryToContext(PyObject* dict, Ice::Context& context) } string valuestr; - if(PyString_Check(value)) + if(checkString(value)) { valuestr = getString(value); } @@ -650,20 +665,20 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) } catch(const Ice::FileException& e) { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + IcePy::PyObjectHandle m = PyLong_FromLong(e.error); PyObject_SetAttrString(p, STRCAST("error"), m.get()); m = IcePy::createString(e.path); PyObject_SetAttrString(p, STRCAST("path"), m.get()); } catch(const Ice::SyscallException& e) // This must appear after all subclasses of SyscallException. { - IcePy::PyObjectHandle m = PyInt_FromLong(e.error); + IcePy::PyObjectHandle m = PyLong_FromLong(e.error); PyObject_SetAttrString(p, STRCAST("error"), m.get()); } catch(const Ice::DNSException& e) { IcePy::PyObjectHandle m; - m = PyInt_FromLong(e.error); + m = PyLong_FromLong(e.error); PyObject_SetAttrString(p, STRCAST("error"), m.get()); m = IcePy::createString(e.host); PyObject_SetAttrString(p, STRCAST("host"), m.get()); @@ -671,25 +686,25 @@ convertLocalException(const Ice::LocalException& ex, PyObject* p) catch(const Ice::UnsupportedProtocolException& e) { IcePy::PyObjectHandle m; - m = PyInt_FromLong(e.badMajor); + m = PyLong_FromLong(e.badMajor); PyObject_SetAttrString(p, STRCAST("badMajor"), m.get()); - m = PyInt_FromLong(e.badMinor); + m = PyLong_FromLong(e.badMinor); PyObject_SetAttrString(p, STRCAST("badMinor"), m.get()); - m = PyInt_FromLong(e.major); + m = PyLong_FromLong(e.major); PyObject_SetAttrString(p, STRCAST("major"), m.get()); - m = PyInt_FromLong(e.minor); + m = PyLong_FromLong(e.minor); PyObject_SetAttrString(p, STRCAST("minor"), m.get()); } catch(const Ice::UnsupportedEncodingException& e) { IcePy::PyObjectHandle m; - m = PyInt_FromLong(e.badMajor); + m = PyLong_FromLong(e.badMajor); PyObject_SetAttrString(p, STRCAST("badMajor"), m.get()); - m = PyInt_FromLong(e.badMinor); + m = PyLong_FromLong(e.badMinor); PyObject_SetAttrString(p, STRCAST("badMinor"), m.get()); - m = PyInt_FromLong(e.major); + m = PyLong_FromLong(e.major); PyObject_SetAttrString(p, STRCAST("major"), m.get()); - m = PyInt_FromLong(e.minor); + m = PyLong_FromLong(e.minor); PyObject_SetAttrString(p, STRCAST("minor"), m.get()); } catch(const Ice::NoObjectFactoryException& e) @@ -852,9 +867,9 @@ IcePy::handleSystemExit(PyObject* ex) } int status; - if(PyInt_Check(code.get())) + if(PyLong_Check(code.get())) { - status = static_cast<int>(PyInt_AsLong(code.get())); + status = static_cast<int>(PyLong_AsLong(code.get())); } else { @@ -919,23 +934,21 @@ IcePy::getIdentity(PyObject* p, Ice::Identity& ident) PyObjectHandle category = PyObject_GetAttrString(p, STRCAST("category")); if(name.get()) { - char* s = PyString_AsString(name.get()); - if(!s) + if(!checkString(name.get())) { PyErr_Format(PyExc_ValueError, STRCAST("identity name must be a string")); return false; } - ident.name = s; + ident.name = getString(name.get()); } if(category.get()) { - char* s = PyString_AsString(category.get()); - if(!s) + if(!checkString(category.get())) { PyErr_Format(PyExc_ValueError, STRCAST("identity category must be a string")); return false; } - ident.category = s; + ident.category = getString(category.get()); } return true; } @@ -952,7 +965,7 @@ extern "C" PyObject* IcePy_intVersion(PyObject* /*self*/) { - return PyInt_FromLong(ICE_INT_VERSION); + return PyLong_FromLong(ICE_INT_VERSION); } extern "C" diff --git a/py/modules/IcePy/Util.h b/py/modules/IcePy/Util.h index 5520c1f07d9..5d390ccf88c 100644 --- a/py/modules/IcePy/Util.h +++ b/py/modules/IcePy/Util.h @@ -36,8 +36,13 @@ namespace IcePy // inline PyObject* getFalse() { +#if PY_VERSION_HEX >= 0x03000000 + PyLongObject* i = &_Py_FalseStruct; + return reinterpret_cast<PyObject*>(i); +#else PyIntObject* i = &_Py_ZeroStruct; return reinterpret_cast<PyObject*>(i); +#endif } // @@ -45,13 +50,28 @@ inline PyObject* getFalse() // inline PyObject* getTrue() { +#if PY_VERSION_HEX >= 0x03000000 + PyLongObject* i = &_Py_TrueStruct; + return reinterpret_cast<PyObject*>(i); +#else PyIntObject* i = &_Py_TrueStruct; return reinterpret_cast<PyObject*>(i); +#endif } +// +// Create a string object. +// inline PyObject* createString(const std::string& str) { +#if PY_VERSION_HEX >= 0x03000000 + // + // PyUnicode_FromStringAndSize interprets the argument as UTF-8. + // + return PyUnicode_FromStringAndSize(str.c_str(), static_cast<Py_ssize_t>(str.size())); +#else return PyString_FromStringAndSize(str.c_str(), static_cast<Py_ssize_t>(str.size())); +#endif } // @@ -60,6 +80,18 @@ inline PyObject* createString(const std::string& str) std::string getString(PyObject*); // +// Verify that the object is a string; None is NOT legal. +// +inline bool checkString(PyObject* p) +{ +#if PY_VERSION_HEX >= 0x03000000 + return PyUnicode_Check(p) ? true : false; +#else + return PyString_Check(p) ? true : false; +#endif +} + +// // Validate and retrieve a string argument; None is also legal. // bool getStringArg(PyObject*, const std::string&, std::string&); diff --git a/py/python/Ice.py b/py/python/Ice.py index 2bfb3123004..95f1e4c16f4 100644 --- a/py/python/Ice.py +++ b/py/python/Ice.py @@ -11,7 +11,7 @@ Ice module """ -import sys, exceptions, string, imp, os, threading, warnings, datetime +import sys, string, imp, os, threading, warnings, datetime # # RTTI problems can occur in C++ code unless we modify Python's dlopen flags. @@ -157,7 +157,7 @@ object. # # Exceptions. # -class Exception(exceptions.Exception): +class Exception(Exception): # Derives from built-in base 'Exception' class. '''The base class for all Ice exceptions.''' def __str__(self): return self.__class__.__name__ @@ -218,9 +218,10 @@ def getSliceDir(): _pendingModules = {} def openModule(name): - if sys.modules.has_key(name): + global _pendingModules + if name in sys.modules: result = sys.modules[name] - elif _pendingModules.has_key(name): + elif name in _pendingModules: result = _pendingModules[name] else: result = createModule(name) @@ -228,16 +229,17 @@ def openModule(name): return result def createModule(name): - l = string.split(name, ".") + global _pendingModules + l = name.split(".") curr = '' mod = None for s in l: curr = curr + s - if sys.modules.has_key(curr): + if curr in sys.modules: mod = sys.modules[curr] - elif _pendingModules.has_key(curr): + elif curr in _pendingModules: mod = _pendingModules[curr] else: nmod = imp.new_module(curr) @@ -249,19 +251,21 @@ def createModule(name): return mod def updateModule(name): - if _pendingModules.has_key(name): + global _pendingModules + if name in _pendingModules: pendingModule = _pendingModules[name] mod = sys.modules[name] mod.__dict__.update(pendingModule.__dict__) del _pendingModules[name] def updateModules(): + global _pendingModules for name in _pendingModules.keys(): - if sys.modules.has_key(name): + if name in sys.modules: sys.modules[name].__dict__.update(_pendingModules[name].__dict__) else: sys.modules[name] = _pendingModules[name] - del _pendingModules[name] + _pendingModules = {} def createTempClass(): class __temp: pass @@ -795,9 +799,9 @@ class CtrlCHandler(threading.Thread): # # Setup and install signal handlers # - if signal.__dict__.has_key('SIGHUP'): + if 'SIGHUP' in signal.__dict__: signal.signal(signal.SIGHUP, CtrlCHandler.signalHandler) - if signal.__dict__.has_key('SIGBREAK'): + if 'SIGBREAK' in signal.__dict__: signal.signal(signal.SIGBREAK, CtrlCHandler.signalHandler) signal.signal(signal.SIGINT, CtrlCHandler.signalHandler) signal.signal(signal.SIGTERM, CtrlCHandler.signalHandler) @@ -832,9 +836,9 @@ class CtrlCHandler(threading.Thread): # # Cleanup any state set by the CtrlCHandler. # - if signal.__dict__.has_key('SIGHUP'): + if 'SIGHUP' in signal.__dict__: signal.signal(signal.SIGHUP, signal.SIG_DFL) - if signal.__dict__.has_key('SIGBREAK'): + if 'SIGBREAK' in signal.__dict__: signal.signal(signal.SIGBREAK, signal.SIG_DFL) signal.signal(signal.SIGINT, signal.SIG_DFL) signal.signal(signal.SIGTERM, signal.SIG_DFL) @@ -1326,13 +1330,15 @@ def proxyIdentityCompare(lhs, rhs): if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): raise ValueError('argument is not a proxy') if not lhs and not rhs: - return True + return 0 elif not lhs and rhs: return -1 elif lhs and not rhs: return 1 else: - return cmp(lhs.ice_getIdentity(), rhs.ice_getIdentity()) + lid = lhs.ice_getIdentity() + rid = rhs.ice_getIdentity() + return (lid > rid) - (lid < rid) def proxyIdentityAndFacetEqual(lhs, rhs): '''Determines whether the identities and facets of two @@ -1344,12 +1350,34 @@ def proxyIdentityAndFacetCompare(lhs, rhs): if (lhs and not isinstance(lhs, ObjectPrx)) or (rhs and not isinstance(rhs, ObjectPrx)): raise ValueError('argument is not a proxy') if not lhs and not rhs: - return True + return 0 elif not lhs and rhs: return -1 elif lhs and not rhs: return 1 elif lhs.ice_getIdentity() != rhs.ice_getIdentity(): - return cmp(lhs.ice_getIdentity(), rhs.ice_getIdentity()) + lid = lhs.ice_getIdentity() + rid = rhs.ice_getIdentity() + return (lid > rid) - (lid < rid) else: - return cmp(lhs.ice_getFacet(), rhs.ice_getFacet()) + lf = lhs.ice_getFacet() + rf = rhs.ice_getFacet() + return (lf > rf) - (lf < rf) + +# +# Used by generated code. Defining these in the Ice module means the generated code +# can avoid the need to qualify the type() and hash() functions with their module +# names. Since the functions are in the __builtin__ module (for Python 2.x) and the +# builtins module (for Python 3.x), it's easier to define them here. +# +def getType(o): + return type(o) + +# +# Used by generated code. Defining this in the Ice module means the generated code +# can avoid the need to qualify the hash() function with its module name. Since +# the function is in the __builtin__ module (for Python 2.x) and the builtins +# module (for Python 3.x), it's easier to define it here. +# +def getHash(o): + return hash(o) diff --git a/py/test/Ice/adapterDeactivation/AllTests.py b/py/test/Ice/adapterDeactivation/AllTests.py index b422f6784d8..978db730867 100644 --- a/py/test/Ice/adapterDeactivation/AllTests.py +++ b/py/test/Ice/adapterDeactivation/AllTests.py @@ -14,20 +14,20 @@ def test(b): raise RuntimeError('test assertion failed') def allTests(communicator): - print "testing stringToProxy... ", + sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() base = communicator.stringToProxy("test:default -p 12010") test(base) - print "ok" + print("ok") - print "testing checked cast... ", + sys.stdout.write("testing checked cast... ") sys.stdout.flush() obj = Test.TestIntfPrx.checkedCast(base) test(obj) test(obj == base) - print "ok" + print("ok") - print "creating/destroying/recreating object adapter... ", + sys.stdout.write("creating/destroying/recreating object adapter... ") sys.stdout.flush() adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default") try: @@ -39,24 +39,24 @@ def allTests(communicator): adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default") adapter.destroy() - print "ok" + print("ok") - print "creating/activating/deactivating object adapter in one operation... ", + sys.stdout.write("creating/activating/deactivating object adapter in one operation... ") sys.stdout.flush() obj.transient() - print "ok" + print("ok") - print "deactivating object adapter in the server... ", + sys.stdout.write("deactivating object adapter in the server... ") sys.stdout.flush() obj.deactivate() - print "ok" + print("ok") - print "testing whether server is gone... ", + sys.stdout.write("testing whether server is gone... ") sys.stdout.flush() try: obj.ice_ping() test(False) except Ice.LocalException: - print "ok" + print("ok") return obj diff --git a/py/test/Ice/adapterDeactivation/run.py b/py/test/Ice/adapterDeactivation/run.py index 099ce110107..db68ff30b9a 100755 --- a/py/test/Ice/adapterDeactivation/run.py +++ b/py/test/Ice/adapterDeactivation/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/py/test/Ice/ami/AllTests.py b/py/test/Ice/ami/AllTests.py index ae4dd376760..6c6bf83840c 100644 --- a/py/test/Ice/ami/AllTests.py +++ b/py/test/Ice/ami/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, threading, random +import Ice, Test, sys, threading, random def test(b): if not b: @@ -300,7 +300,8 @@ def allTests(communicator): testController = Test.TestIntfControllerPrx.uncheckedCast(obj) - print "testing begin/end invocation...", + sys.stdout.write("testing begin/end invocation... ") + sys.stdout.flush() ctx = {} result = p.begin_ice_isA("::Test::TestIntf") @@ -346,9 +347,10 @@ def allTests(communicator): except Test.TestIntfException: pass - print "ok" + print("ok") - print "testing response callback...", + sys.stdout.write("testing response callback... ") + sys.stdout.flush() ctx = {} cb = ResponseCallback() @@ -419,9 +421,10 @@ def allTests(communicator): p.begin_opWithUE(lambda: cbWC.op(cookie), lambda ex: cbWC.opWithUE(ex, cookie), _ctx=ctx) cbWC.check() - print "ok" + print("ok") - print "testing local exceptions...", + sys.stdout.write("testing local exceptions... ") + sys.stdout.flush() indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) @@ -454,9 +457,10 @@ def allTests(communicator): except Ice.CommunicatorDestroyedException: pass - print "ok" + print("ok") - print "testing local exceptions with response callback...", + sys.stdout.write("testing local exceptions with response callback... ") + sys.stdout.flush() i = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) cb = ExceptionCallback() @@ -488,9 +492,10 @@ def allTests(communicator): i.begin_op(lambda: cbWC.response(cookie), lambda ex: cbWC.ex(ex, cookie)) cbWC.check() - print "ok" + print("ok") - print "testing exception callback...", + sys.stdout.write("testing exception callback... ") + sys.stdout.flush() cb = ExceptionCallback() cookie = 5 @@ -509,9 +514,10 @@ def allTests(communicator): p.begin_opWithUE(lambda: cbWC.nullResponse(cookie), lambda ex: cbWC.opWithUE(ex, cookie)) cbWC.check() - print "ok" + print("ok") - print "testing sent callback...", + sys.stdout.write("testing sent callback... ") + sys.stdout.flush() cb = SentCallback() cookie = 5 @@ -546,26 +552,29 @@ def allTests(communicator): cbWC.check() cbs = [] - bytes = [] - bytes[0:1024] = range(0, 1024) - bytes = [chr(random.randint(0, 255)) for x in bytes] # Make sure the request doesn't compress too well. - seq = ''.join(bytes) + if sys.version_info[0] == 2: + b = [chr(random.randint(0, 255)) for x in range(0, 1024)] # Make sure the request doesn't compress too well. + seq = ''.join(b) + else: + b = [random.randint(0, 255) for x in range(0, 1024)] # Make sure the request doesn't compress too well. + seq = bytes(b) testController.holdAdapter() try: cb = SentCallback() while(p.begin_opWithPayload(seq, None, cb.ex, cb.sent).sentSynchronously()): cbs.append(cb) cb = SentCallback() - except ex: + except Exception as ex: testController.resumeAdapter() raise ex testController.resumeAdapter() for r in cbs: r.check() - print "ok" + print("ok") - print "testing illegal arguments...", + sys.stdout.write("testing illegal arguments... ") + sys.stdout.flush() result = p.begin_op() p.end_op(result) @@ -582,9 +591,10 @@ def allTests(communicator): except RuntimeError: pass - print "ok" + print("ok") - print "testing unexpected exceptions from callback...", + sys.stdout.write("testing unexpected exceptions from callback... ") + sys.stdout.flush() q = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) throwTypes = [ LocalException, UserException, OtherException ] @@ -617,9 +627,10 @@ def allTests(communicator): q.begin_op(None, lambda ex: cb.exWC(ex, cookie)) cb.check() - print "ok" + print("ok") - print "testing batch requests with proxy...", + sys.stdout.write("testing batch requests with proxy... ") + sys.stdout.flush() cookie = 5 @@ -675,9 +686,10 @@ def allTests(communicator): cb.check() test(p.opBatchCount() == 0) - print "ok" + print("ok") - print "testing batch requests with connection...", + sys.stdout.write("testing batch requests with connection... ") + sys.stdout.flush() cookie = 5 @@ -735,9 +747,10 @@ def allTests(communicator): cb.check() test(p.opBatchCount() == 0) - print "ok" + print("ok") - print "testing batch requests with communicator...", + sys.stdout.write("testing batch requests with communicator... ") + sys.stdout.flush() # # 1 connection. @@ -825,9 +838,10 @@ def allTests(communicator): test(r.isCompleted()) test(p.opBatchCount() == 0) - print "ok" + print("ok") - print "testing AsyncResult operations...", + sys.stdout.write("testing AsyncResult operations... ") + sys.stdout.flush() indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy")) r = indirect.begin_op() @@ -843,10 +857,12 @@ def allTests(communicator): r2 = None try: r1 = p.begin_op() - bytes = [] - bytes[0:1024] = range(0, 1024) - bytes = [chr(random.randint(0, 255)) for x in bytes] # Make sure the request doesn't compress too well. - seq = ''.join(bytes) + if sys.version_info[0] == 2: + b = [chr(random.randint(0, 255)) for x in range(0, 1024)] # Make sure the request doesn't compress too well. + seq = ''.join(b) + else: + b = [random.randint(0, 255) for x in range(0, 1024)] # Make sure the request doesn't compress too well. + seq = bytes(b) while(True): r2 = p.begin_opWithPayload(seq) if not r2.sentSynchronously(): @@ -859,7 +875,7 @@ def allTests(communicator): (not r1.sentSynchronously() and not r1.isCompleted())); test(not r2.sentSynchronously() and not r2.isCompleted()); - except ex: + except Exception as ex: testController.resumeAdapter() raise ex testController.resumeAdapter() @@ -933,6 +949,6 @@ def allTests(communicator): test(r.getProxy() == None) # Expected communicator.end_flushBatchRequests(r) - print "ok" + print("ok") p.shutdown() diff --git a/py/test/Ice/ami/Client.py b/py/test/Ice/ami/Client.py index d1325816e78..97383d6b389 100755 --- a/py/test/Ice/ami/Client.py +++ b/py/test/Ice/ami/Client.py @@ -14,7 +14,7 @@ import Ice import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/ami/Server.py b/py/test/Ice/ami/Server.py index deaa5356aa5..f231c277cb9 100755 --- a/py/test/Ice/ami/Server.py +++ b/py/test/Ice/ami/Server.py @@ -12,7 +12,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice('"-I' + slice_dir + '" Test.ice') diff --git a/py/test/Ice/ami/run.py b/py/test/Ice/ami/run.py index 645839990d4..2265a40ca12 100755 --- a/py/test/Ice/ami/run.py +++ b/py/test/Ice/ami/run.py @@ -16,8 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/py/test/Ice/application/Client.py b/py/test/Ice/application/Client.py index be9d4dc9ea6..0641a7ddf0b 100755 --- a/py/test/Ice/application/Client.py +++ b/py/test/Ice/application/Client.py @@ -12,7 +12,7 @@ import sys, Ice, time class Client(Ice.Application): def interruptCallback(self, sig): - print "handling signal " + str(sig) + print("handling signal " + str(sig)) # SIGINT interrupts time.sleep so a custom method is needed to # sleep for a given interval. @@ -26,32 +26,32 @@ class Client(Ice.Application): def run(self, args): self.ignoreInterrupt() - print "Ignore CTRL+C and the like for 5 seconds (try it!)" + print("Ignore CTRL+C and the like for 5 seconds (try it!)") self.sleep(5) self.callbackOnInterrupt() self.holdInterrupt() - print "Hold CTRL+C and the like for 5 seconds (try it!)" + print("Hold CTRL+C and the like for 5 seconds (try it!)") self.sleep(5) self.releaseInterrupt() - print "Release CTRL+C (any held signals should be released)" + print("Release CTRL+C (any held signals should be released)") self.sleep(5) self.holdInterrupt() - print "Hold CTRL+C and the like for 5 seconds (try it!)" + print("Hold CTRL+C and the like for 5 seconds (try it!)") self.sleep(5) self.callbackOnInterrupt() - print "Release CTRL+C (any held signals should be released)" + print("Release CTRL+C (any held signals should be released)") self.sleep(5) self.shutdownOnInterrupt() - print "Test shutdown on destroy. Press CTRL+C to shutdown & terminate" + print("Test shutdown on destroy. Press CTRL+C to shutdown & terminate") self.communicator().waitForShutdown() - print "ok" + print("ok") return False app = Client() diff --git a/py/test/Ice/binding/AllTests.py b/py/test/Ice/binding/AllTests.py index 902926bca0b..b289818c88a 100644 --- a/py/test/Ice/binding/AllTests.py +++ b/py/test/Ice/binding/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, random, threading +import Ice, Test, sys, random, threading def test(b): if not b: @@ -61,7 +61,8 @@ def allTests(communicator): ref = "communicator:default -p 12010" com = Test.RemoteCommunicatorPrx.uncheckedCast(communicator.stringToProxy(ref)) - print "testing binding with single endpoint...", + sys.stdout.write("testing binding with single endpoint... ") + sys.stdout.flush() adapter = com.createObjectAdapter("Adapter", "default") @@ -84,9 +85,10 @@ def allTests(communicator): except Ice.ConnectionRefusedException: pass - print "ok" + print("ok") - print "testing binding with multiple endpoints...", + sys.stdout.write("testing binding with multiple endpoints... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter11", "default")) @@ -167,9 +169,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing binding with multiple endpoints and AMI...", + sys.stdout.write("testing binding with multiple endpoints and AMI... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("AdapterAMI11", "default")) @@ -250,9 +253,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing random endpoint selection...", + sys.stdout.write("testing random endpoint selection... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter21", "default")) @@ -283,9 +287,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing ordered endpoint selection...", + sys.stdout.write("testing ordered endpoint selection... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter31", "default")) @@ -350,9 +355,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing per request binding with single endpoint...", + sys.stdout.write("testing per request binding with single endpoint... ") + sys.stdout.flush() adapter = com.createObjectAdapter("Adapter41", "default") @@ -373,9 +379,10 @@ def allTests(communicator): except Ice.ConnectionRefusedException: pass - print "ok" + print("ok") - print "testing per request binding with multiple endpoints...", + sys.stdout.write("testing per request binding with multiple endpoints... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter51", "default")) @@ -406,9 +413,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing per request binding with multiple endpoints and AMI...", + sys.stdout.write("testing per request binding with multiple endpoints and AMI... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("AdapterAMI51", "default")) @@ -439,9 +447,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing per request binding and ordered endpoint selection...", + sys.stdout.write("testing per request binding and ordered endpoint selection... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter61", "default")) @@ -506,9 +515,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing per request binding and ordered endpoint selection and AMI...", + sys.stdout.write("testing per request binding and ordered endpoint selection and AMI... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("AdapterAMI61", "default")) @@ -573,9 +583,10 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") - print "testing endpoint mode filtering...", + sys.stdout.write("testing endpoint mode filtering... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter71", "default")) @@ -591,10 +602,11 @@ def allTests(communicator): except Ice.TwowayOnlyException: pass - print "ok" + print("ok") if(len(communicator.getProperties().getProperty("Ice.Plugin.IceSSL")) > 0): - print "testing unsecure vs. secure endpoints...", + sys.stdout.write("testing unsecure vs. secure endpoints... ") + sys.stdout.flush() adapters = [] adapters.append(com.createObjectAdapter("Adapter81", "ssl")) @@ -634,6 +646,6 @@ def allTests(communicator): deactivate(com, adapters) - print "ok" + print("ok") com.shutdown() diff --git a/py/test/Ice/binding/run.py b/py/test/Ice/binding/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/binding/run.py +++ b/py/test/Ice/binding/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/blobject/Client.py b/py/test/Ice/blobject/Client.py index 24829f54511..14dd311f16b 100755 --- a/py/test/Ice/blobject/Client.py +++ b/py/test/Ice/blobject/Client.py @@ -40,7 +40,7 @@ def run(args, communicator, sync): try: Test.HelloPrx.checkedCast(communicator.stringToProxy("missing:default -p 12000 -t 10000")) test(False) - except Ice.UnknownLocalException, e: + except Ice.UnknownLocalException as e: test(e.unknown.find('ConnectionRefusedException')) if sync: hello.shutdown() @@ -54,10 +54,10 @@ try: initData.properties.setProperty('Ice.Warn.Dispatch', '0') communicator = Ice.initialize(argv, initData) router = RouterI.RouterI(communicator, False) - print "testing async blobject...", + sys.stdout.write("testing async blobject... ") sys.stdout.flush() status = run(sys.argv, communicator, False) - print "ok" + print("ok") router.destroy() except: traceback.print_exc() @@ -77,10 +77,10 @@ if status: initData.properties.setProperty('Ice.Warn.Dispatch', '0') communicator = Ice.initialize(sys.argv, initData) router = RouterI.RouterI(communicator, True) - print "testing sync blobject...", + sys.stdout.write("testing sync blobject... ") sys.stdout.flush() status = run(sys.argv, communicator, True) - print "ok" + print("ok") router.destroy() except: traceback.print_exc() diff --git a/py/test/Ice/blobject/RouterI.py b/py/test/Ice/blobject/RouterI.py index 7942a286fb8..fdf6c7eba39 100644 --- a/py/test/Ice/blobject/RouterI.py +++ b/py/test/Ice/blobject/RouterI.py @@ -62,12 +62,12 @@ class BlobjectCall(object): if len(self._curr.facet) > 0: proxy = self._proxy.ice_facet(self._curr.facet) - if self._curr.ctx.has_key("_fwd") and self._curr.ctx["_fwd"] == "o": + if "_fwd" in self._curr.ctx and self._curr.ctx["_fwd"] == "o": proxy = proxy.ice_oneway() try: ok, out = proxy.ice_invoke(self._curr.operation, self._curr.mode, self._inParams, self._curr.ctx) self._amdCallback.ice_response(ok, out) - except Ice.Exception, e: + except Ice.Exception as e: self._amdCallback.ice_exception(e) else: cb = AsyncCallback(self._amdCallback) @@ -113,12 +113,12 @@ class BlobjectI(Ice.Blobject): proxy = proxy.ice_facet(curr.facet) try: - if curr.ctx.has_key("_fwd") and curr.ctx["_fwd"] == "o": + if "_fwd" in curr.ctx and curr.ctx["_fwd"] == "o": proxy = proxy.ice_oneway() return proxy.ice_invoke(curr.operation, curr.mode, inParams, curr.ctx) else: return proxy.ice_invoke(curr.operation, curr.mode, inParams, curr.ctx) - except Ice.Exception, e: + except Ice.Exception as e: raise def add(self, proxy): diff --git a/py/test/Ice/blobject/run.py b/py/test/Ice/blobject/run.py index c80260ad967..2265a40ca12 100755 --- a/py/test/Ice/blobject/run.py +++ b/py/test/Ice/blobject/run.py @@ -10,20 +10,14 @@ import os, sys -# Skip the test if we're using python 2.3 and we're not on Mac. -if sys.version_info[1] == 3 and sys.platform != 'darwin': - print "Test skipped due to python 2.3" - sys.exit(0) - path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/checksum/AllTests.py b/py/test/Ice/checksum/AllTests.py index 506191bb131..8e349a604b1 100644 --- a/py/test/Ice/checksum/AllTests.py +++ b/py/test/Ice/checksum/AllTests.py @@ -24,10 +24,11 @@ def allTests(communicator): # # Verify that no checksums are present for local types. # - print "testing checksums... ", + sys.stdout.write("testing checksums... ") + sys.stdout.flush() test(len(Ice.sliceChecksums) > 0) for i in Ice.sliceChecksums: - test(string.find(i, "Local") == -1) + test(i.find("Local") == -1) # # Get server's Slice checksums. @@ -46,13 +47,13 @@ def allTests(communicator): if m: n = int(i[m.start():]) - test(Ice.sliceChecksums.has_key(i)) + test(i in Ice.sliceChecksums) if n <= 1: test(Ice.sliceChecksums[i] == d[i]) else: test(Ice.sliceChecksums[i] != d[i]) - print "ok" + print("ok") return checksum diff --git a/py/test/Ice/checksum/Client.py b/py/test/Ice/checksum/Client.py index 60c6f0a35f5..25d6f7dcee8 100755 --- a/py/test/Ice/checksum/Client.py +++ b/py/test/Ice/checksum/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice CTypes.ice") diff --git a/py/test/Ice/checksum/Server.py b/py/test/Ice/checksum/Server.py index 4c2659bcb7a..b61b4c55697 100755 --- a/py/test/Ice/checksum/Server.py +++ b/py/test/Ice/checksum/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' --checksum Test.ice STypes.ice") diff --git a/py/test/Ice/checksum/run.py b/py/test/Ice/checksum/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/checksum/run.py +++ b/py/test/Ice/checksum/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/custom/AllTests.py b/py/test/Ice/custom/AllTests.py index fe407a26122..03046ab56f6 100644 --- a/py/test/Ice/custom/AllTests.py +++ b/py/test/Ice/custom/AllTests.py @@ -22,14 +22,22 @@ def allTests(communicator): test(custom) byteList = [1, 2, 3, 4, 5] - byteString = ''.join(map(chr, byteList)) + if sys.version_info[0] == 2: + byteString = ''.join(map(chr, byteList)) + else: + byteString = bytes(byteList) stringList = ['s1', 's2', 's3'] - print "testing custom sequences...", + sys.stdout.write("testing custom sequences... ") + sys.stdout.flush() (r, b2) = custom.opByteString1(byteString) - test(isinstance(r, str)) - test(isinstance(b2, str)) + if sys.version_info[0] == 2: + test(isinstance(r, str)) + test(isinstance(b2, str)) + else: + test(isinstance(r, bytes)) + test(isinstance(b2, bytes)) test(r == byteString) test(b2 == byteString) @@ -48,7 +56,10 @@ def allTests(communicator): test(b2[i] == byteList[i]) (r, b2) = custom.opByteList2(byteList) - test(isinstance(r, str)) + if sys.version_info[0] == 2: + test(isinstance(r, str)) + else: + test(isinstance(r, bytes)) test(isinstance(b2, tuple)) test(r == byteString) for i in range(0, len(byteList)): @@ -102,6 +113,6 @@ def allTests(communicator): c.s4 = stringList; custom.sendC(c) - print "ok" + print("ok") return custom diff --git a/py/test/Ice/custom/Server.py b/py/test/Ice/custom/Server.py index 22664625afa..65ef09e80d0 100755 --- a/py/test/Ice/custom/Server.py +++ b/py/test/Ice/custom/Server.py @@ -20,7 +20,10 @@ def test(b): class CustomI(Test.Custom): def opByteString1(self, b1, current=None): - test(isinstance(b1, str)) + if sys.version_info[0] == 2: + test(isinstance(b1, str)) + else: + test(isinstance(b1, bytes)) return (b1, b1) def opByteString2(self, b1, current=None): @@ -52,9 +55,15 @@ class CustomI(Test.Custom): return (s1, s1) def sendS(self, val, current=None): - test(isinstance(val.b1, str)) + if sys.version_info[0] == 2: + test(isinstance(val.b1, str)) + else: + test(isinstance(val.b1, bytes)) test(isinstance(val.b2, list)) - test(isinstance(val.b3, str)) + if sys.version_info[0] == 2: + test(isinstance(val.b3, str)) + else: + test(isinstance(val.b3, bytes)) test(isinstance(val.b4, list)) test(isinstance(val.s1, list)) test(isinstance(val.s2, tuple)) @@ -62,9 +71,15 @@ class CustomI(Test.Custom): test(isinstance(val.s4, list)) def sendC(self, val, current=None): - test(isinstance(val.b1, str)) + if sys.version_info[0] == 2: + test(isinstance(val.b1, str)) + else: + test(isinstance(val.b1, bytes)) test(isinstance(val.b2, list)) - test(isinstance(val.b3, str)) + if sys.version_info[0] == 2: + test(isinstance(val.b3, str)) + else: + test(isinstance(val.b3, bytes)) test(isinstance(val.b4, list)) test(isinstance(val.s1, list)) test(isinstance(val.s2, tuple)) diff --git a/py/test/Ice/custom/run.py b/py/test/Ice/custom/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/custom/run.py +++ b/py/test/Ice/custom/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/defaultServant/AllTests.py b/py/test/Ice/defaultServant/AllTests.py index cfa82a9048a..8dfde7db6c4 100644 --- a/py/test/Ice/defaultServant/AllTests.py +++ b/py/test/Ice/defaultServant/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, MyObjectI +import Ice, Test, MyObjectI, sys def test(b): if not b: @@ -24,7 +24,8 @@ def allTests(communicator): oa.addDefaultServant(servant, "foo") # Start test - print "testing single category... ", + sys.stdout.write("testing single category... ") + sys.stdout.flush() r = oa.findDefaultServant("foo") test(r == servant) @@ -103,9 +104,10 @@ def allTests(communicator): # Expected pass - print "ok" + print("ok") - print "testing default category... ", + sys.stdout.write("testing default category... ") + sys.stdout.flush() oa.addDefaultServant(servant, "") @@ -121,4 +123,4 @@ def allTests(communicator): prx.ice_ping() test(prx.getName() == names[idx]) - print "ok" + print("ok") diff --git a/py/test/Ice/defaultServant/run.py b/py/test/Ice/defaultServant/run.py index 08d8d6cd828..f75ac017c4d 100755 --- a/py/test/Ice/defaultServant/run.py +++ b/py/test/Ice/defaultServant/run.py @@ -16,14 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.py", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/py/test/Ice/defaultValue/AllTests.py b/py/test/Ice/defaultValue/AllTests.py index eb9c6eefca7..64967566cdb 100644 --- a/py/test/Ice/defaultValue/AllTests.py +++ b/py/test/Ice/defaultValue/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, sys def test(b): if not b: @@ -15,7 +15,8 @@ def test(b): def allTests(): - print "testing default values...", + sys.stdout.write("testing default values... ") + sys.stdout.flush() v = Test.Struct1() test(not v.boolFalse) @@ -147,4 +148,4 @@ def allTests(): test(v.zeroD == 0) test(v.zeroDotD == 0) - print "ok" + print("ok") diff --git a/py/test/Ice/defaultValue/run.py b/py/test/Ice/defaultValue/run.py index 16a6b09aaa5..f75ac017c4d 100755 --- a/py/test/Ice/defaultValue/run.py +++ b/py/test/Ice/defaultValue/run.py @@ -16,13 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.py", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/py/test/Ice/exceptions/AllTests.py b/py/test/Ice/exceptions/AllTests.py index c89c4b27851..7b373f1c105 100644 --- a/py/test/Ice/exceptions/AllTests.py +++ b/py/test/Ice/exceptions/AllTests.py @@ -60,7 +60,7 @@ class AMI_Thrower_throwAasAI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) except: test(False) @@ -77,7 +77,7 @@ class AMI_Thrower_throwAasAObjectNotExistI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Ice.ObjectNotExistException, ex: + except Ice.ObjectNotExistException as ex: id = self._communicator.stringToIdentity("does not exist") test(ex.id == id) except: @@ -91,7 +91,7 @@ class AMI_Thrower_throwAasAFacetNotExistI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Ice.FacetNotExistException, ex: + except Ice.FacetNotExistException as ex: test(ex.facet == "no such facet") except: test(False) @@ -104,9 +104,9 @@ class AMI_Thrower_throwAorDasAorDI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) - except Test.D, ex: + except Test.D as ex: test(ex.dMem == -1) except: test(False) @@ -119,7 +119,7 @@ class AMI_Thrower_throwBasAI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: @@ -133,7 +133,7 @@ class AMI_Thrower_throwCasAI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -148,7 +148,7 @@ class AMI_Thrower_throwBasBI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: @@ -162,7 +162,7 @@ class AMI_Thrower_throwCasBI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -177,7 +177,7 @@ class AMI_Thrower_throwCasCI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -192,7 +192,7 @@ class AMI_Thrower_throwModAI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Test.Mod.A, ex: + except Test.Mod.A as ex: test(ex.aMem == 1) test(ex.a2Mem == 2) except Ice.OperationNotExistException: @@ -276,7 +276,7 @@ class AMI_WrongOperation_noSuchOperationI(CallbackBase): def ice_exception(self, ex): try: raise ex - except Ice.OperationNotExistException, ex: + except Ice.OperationNotExistException as ex: test(ex.operation == "noSuchOperation") except: test(False) @@ -298,9 +298,9 @@ class Callback(CallbackBase): def exception_AorDasAorD(self, ex): try: raise ex - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) - except Test.D, ex: + except Test.D as ex: test(ex.dMem == -1) except: test(False) @@ -309,7 +309,7 @@ class Callback(CallbackBase): def exception_BasB(self, ex): try: raise ex - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: @@ -319,7 +319,7 @@ class Callback(CallbackBase): def exception_CasC(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -330,7 +330,7 @@ class Callback(CallbackBase): def exception_ModA(self, ex): try: raise ex - except Test.Mod.A, ex: + except Test.Mod.A as ex: test(ex.aMem == 1) test(ex.a2Mem == 2) except Ice.OperationNotExistException: @@ -345,7 +345,7 @@ class Callback(CallbackBase): def exception_BasA(self, ex): try: raise ex - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: @@ -355,7 +355,7 @@ class Callback(CallbackBase): def exception_CasA(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -366,7 +366,7 @@ class Callback(CallbackBase): def exception_CasB(self, ex): try: raise ex - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) @@ -404,7 +404,7 @@ class Callback(CallbackBase): def exception_AasAObjectNotExist(self, ex): try: raise ex - except Ice.ObjectNotExistException, ex: + except Ice.ObjectNotExistException as ex: id = self._communicator.stringToIdentity("does not exist") test(ex.id == id) except: @@ -414,7 +414,7 @@ class Callback(CallbackBase): def exception_AasAFacetNotExist(self, ex): try: raise ex - except Ice.FacetNotExistException, ex: + except Ice.FacetNotExistException as ex: test(ex.facet == "no such facet") except: test(False) @@ -423,7 +423,7 @@ class Callback(CallbackBase): def exception_noSuchOperation(self, ex): try: raise ex - except Ice.OperationNotExistException, ex: + except Ice.OperationNotExistException as ex: test(ex.operation == "noSuchOperation") except: test(False) @@ -432,7 +432,7 @@ class Callback(CallbackBase): def exception_LocalException(self, ex): try: raise ex - except Ice.UnknownLocalException, ex: + except Ice.UnknownLocalException as ex: pass except: test(False) @@ -441,14 +441,15 @@ class Callback(CallbackBase): def exception_NonIceException(self, ex): try: raise ex - except Ice.UnknownException, ex: + except Ice.UnknownException as ex: pass except: test(False) self.called() def allTests(communicator): - print "testing servant registration exceptions...", + sys.stdout.write("testing servant registration exceptions... ") + sys.stdout.flush() communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default") adapter = communicator.createObjectAdapter("TestAdapter1") obj = EmptyI() @@ -467,9 +468,10 @@ def allTests(communicator): pass adapter.deactivate() - print "ok" + print("ok") - print "testing servant locator registrations exceptions...", + sys.stdout.write("testing servant locator registrations exceptions... ") + sys.stdout.flush() communicator.getProperties().setProperty("TestAdapter2.Endpoints", "default") adapter = communicator.createObjectAdapter("TestAdapter2") loc = ServantLocatorI() @@ -481,9 +483,10 @@ def allTests(communicator): pass adapter.deactivate() - print "ok" + print("ok") - print "testing object factory registration exception...", + sys.stdout.write("testing object factory registration exception... ") + sys.stdout.flush() of = ObjectFactoryI() communicator.addObjectFactory(of, "x") try: @@ -491,74 +494,77 @@ def allTests(communicator): test(false) except Ice.AlreadyRegisteredException: pass - print "ok" + print("ok") - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "thrower:default -p 12010" base = communicator.stringToProxy(ref) test(base) - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() thrower = Test.ThrowerPrx.checkedCast(base) test(thrower) test(thrower == base) - print "ok" + print("ok") - print "catching exact types...", + sys.stdout.write("catching exact types... ") + sys.stdout.flush() try: thrower.throwAasA(1) test(False) - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwAorDasAorD(1) test(False) - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwAorDasAorD(-1) test(False) - except Test.D, ex: + except Test.D as ex: test(ex.dMem == -1) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwBasB(1, 2) test(False) - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwCasC(1, 2, 3) test(False) - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwModA(1, 2) test(False) - except Test.Mod.A, ex: + except Test.Mod.A as ex: test(ex.aMem == 1) test(ex.a2Mem == 2) except Ice.OperationNotExistException: @@ -567,36 +573,37 @@ def allTests(communicator): # pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching base types...", + sys.stdout.write("catching base types... ") + sys.stdout.flush() try: thrower.throwBasB(1, 2) test(False) - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwCasC(1, 2, 3) test(False) - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwModA(1, 2) test(False) - except Test.A, ex: + except Test.A as ex: test(ex.aMem == 1) except Ice.OperationNotExistException: # @@ -604,49 +611,51 @@ def allTests(communicator): # pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching derived types...", + sys.stdout.write("catching derived types... ") + sys.stdout.flush() try: thrower.throwBasA(1, 2) test(False) - except Test.B, ex: + except Test.B as ex: test(ex.aMem == 1) test(ex.bMem == 2) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwCasA(1, 2, 3) test(False) - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: thrower.throwCasB(1, 2, 3) test(False) - except Test.C, ex: + except Test.C as ex: test(ex.aMem == 1) test(ex.bMem == 2) test(ex.cMem == 3) except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") if thrower.supportsUndeclaredExceptions(): - print "catching unknown user exception...", + sys.stdout.write("catching unknown user exception... ") + sys.stdout.flush() try: thrower.throwUndeclaredA(1) @@ -654,7 +663,7 @@ def allTests(communicator): except Ice.UnknownUserException: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: @@ -663,7 +672,7 @@ def allTests(communicator): except Ice.UnknownUserException: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: @@ -672,12 +681,13 @@ def allTests(communicator): except Ice.UnknownUserException: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching object not exist exception...", + sys.stdout.write("catching object not exist exception... ") + sys.stdout.flush() id = communicator.stringToIdentity("does not exist") try: @@ -685,44 +695,47 @@ def allTests(communicator): thrower2.throwAasA(1) # thrower2.ice_ping() test(False) - except Ice.ObjectNotExistException, ex: + except Ice.ObjectNotExistException as ex: test(ex.id == id) except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching facet not exist exception...", + sys.stdout.write("catching facet not exist exception... ") + sys.stdout.flush() try: thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet") try: thrower2.ice_ping() test(False) - except Ice.FacetNotExistException, ex: + except Ice.FacetNotExistException as ex: test(ex.facet == "no such facet") except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching operation not exist exception...", + sys.stdout.write("catching operation not exist exception... ") + sys.stdout.flush() try: thrower2 = Test.WrongOperationPrx.uncheckedCast(thrower) thrower2.noSuchOperation() test(False) - except Ice.OperationNotExistException, ex: + except Ice.OperationNotExistException as ex: test(ex.operation == "noSuchOperation") except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching unknown local exception...", + sys.stdout.write("catching unknown local exception... ") + sys.stdout.flush() try: thrower.throwLocalException() @@ -730,12 +743,13 @@ def allTests(communicator): except Ice.UnknownLocalException: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching unknown non-Ice exception...", + sys.stdout.write("catching unknown non-Ice exception... ") + sys.stdout.flush() try: thrower.throwNonIceException() @@ -743,17 +757,18 @@ def allTests(communicator): except Ice.UnknownException: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "testing asynchronous exceptions...", + sys.stdout.write("testing asynchronous exceptions... ") + sys.stdout.flush() try: thrower.throwAfterResponse() except: - print sys.exc_info() + print(sys.exc_info()) test(False) try: @@ -761,12 +776,13 @@ def allTests(communicator): except Test.A: pass except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") - print "catching exact types with AMI...", + sys.stdout.write("catching exact types with AMI... ") + sys.stdout.flush() cb = AMI_Thrower_throwAasAI() thrower.throwAasA_async(cb, 1) @@ -798,9 +814,10 @@ def allTests(communicator): thrower.throwModA_async(cb, 1, 2) cb.check() - print "ok" + print("ok") - print "catching derived types...", + sys.stdout.write("catching derived types... ") + sys.stdout.flush() cb = AMI_Thrower_throwBasAI() thrower.throwBasA_async(cb, 1, 2) @@ -814,10 +831,11 @@ def allTests(communicator): thrower.throwCasB_async(cb, 1, 2, 3) cb.check() - print "ok" + print("ok") if thrower.supportsUndeclaredExceptions(): - print "catching unknown user exception with AMI...", + sys.stdout.write("catching unknown user exception with AMI... ") + sys.stdout.flush() cb = AMI_Thrower_throwUndeclaredAI() thrower.throwUndeclaredA_async(cb, 1) @@ -831,9 +849,10 @@ def allTests(communicator): thrower.throwUndeclaredC_async(cb, 1, 2, 3) cb.check() - print "ok" + print("ok") - print "catching object not exist exception with AMI...", + sys.stdout.write("catching object not exist exception with AMI... ") + sys.stdout.flush() id = communicator.stringToIdentity("does not exist") thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id)) @@ -841,43 +860,48 @@ def allTests(communicator): thrower2.throwAasA_async(cb, 1) cb.check() - print "ok" + print("ok") - print "catching facet not exist exception with AMI...", + sys.stdout.write("catching facet not exist exception with AMI... ") + sys.stdout.flush() thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet") cb = AMI_Thrower_throwAasAFacetNotExistI() thrower2.throwAasA_async(cb, 1) cb.check() - print "ok" + print("ok") - print "catching operation not exist exception with AMI...", + sys.stdout.write("catching operation not exist exception with AMI... ") + sys.stdout.flush() cb = AMI_WrongOperation_noSuchOperationI() thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower) thrower4.noSuchOperation_async(cb) cb.check() - print "ok" + print("ok") - print "catching unknown local exception with AMI...", + sys.stdout.write("catching unknown local exception with AMI... ") + sys.stdout.flush() cb = AMI_Thrower_throwLocalExceptionI() thrower.throwLocalException_async(cb) cb.check() - print "ok" + print("ok") - print "catching unknown non-Ice exception with AMI...", + sys.stdout.write("catching unknown non-Ice exception with AMI... ") + sys.stdout.flush() cb = AMI_Thrower_throwNonIceExceptionI() thrower.throwNonIceException_async(cb) cb.check() - print "ok" + print("ok") - print "catching exact types with new AMI mapping...", + sys.stdout.write("catching exact types with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower.begin_throwAasA(1, cb.response, cb.exception_AasA) @@ -903,9 +927,10 @@ def allTests(communicator): thrower.begin_throwModA(1, 2, cb.response, cb.exception_ModA) cb.check() - print "ok" + print("ok") - print "catching derived types with new AMI mapping...", + sys.stdout.write("catching derived types with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower.begin_throwBasA(1, 2, cb.response, cb.exception_BasA) @@ -919,10 +944,11 @@ def allTests(communicator): thrower.begin_throwCasB(1, 2, 3, cb.response, cb.exception_CasB) cb.check() - print "ok" + print("ok") if thrower.supportsUndeclaredExceptions(): - print "catching unknown user exception with new AMI mapping...", + sys.stdout.write("catching unknown user exception with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower.begin_throwUndeclaredA(1, cb.response, cb.exception_UndeclaredA) @@ -936,9 +962,10 @@ def allTests(communicator): thrower.begin_throwUndeclaredC(1, 2, 3, cb.response, cb.exception_UndeclaredC) cb.check() - print "ok" + print("ok") - print "catching object not exist exception with new AMI mapping...", + sys.stdout.write("catching object not exist exception with new AMI mapping... ") + sys.stdout.flush() id = communicator.stringToIdentity("does not exist") thrower2 = Test.ThrowerPrx.uncheckedCast(thrower.ice_identity(id)) @@ -946,40 +973,44 @@ def allTests(communicator): thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAObjectNotExist) cb.check() - print "ok" + print("ok") - print "catching facet not exist exception with new AMI mapping...", + sys.stdout.write("catching facet not exist exception with new AMI mapping... ") + sys.stdout.flush() thrower2 = Test.ThrowerPrx.uncheckedCast(thrower, "no such facet") cb = Callback() thrower2.begin_throwAasA(1, cb.response, cb.exception_AasAFacetNotExist) cb.check() - print "ok" + print("ok") - print "catching operation not exist exception with new AMI mapping...", + sys.stdout.write("catching operation not exist exception with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower4 = Test.WrongOperationPrx.uncheckedCast(thrower) thrower4.begin_noSuchOperation(cb.response, cb.exception_noSuchOperation) cb.check() - print "ok" + print("ok") - print "catching unknown local exception with new AMI mapping...", + sys.stdout.write("catching unknown local exception with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower.begin_throwLocalException(cb.response, cb.exception_LocalException) cb.check() - print "ok" + print("ok") - print "catching unknown non-Ice exception with new AMI mapping...", + sys.stdout.write("catching unknown non-Ice exception with new AMI mapping... ") + sys.stdout.flush() cb = Callback() thrower.begin_throwNonIceException(cb.response, cb.exception_NonIceException) cb.check() - print "ok" + print("ok") return thrower diff --git a/py/test/Ice/exceptions/run.py b/py/test/Ice/exceptions/run.py index 83bb6d46a7e..8cc11dcb39f 100755 --- a/py/test/Ice/exceptions/run.py +++ b/py/test/Ice/exceptions/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest() - diff --git a/py/test/Ice/facets/AllTests.py b/py/test/Ice/facets/AllTests.py index 88a6a73ee92..263d7883186 100644 --- a/py/test/Ice/facets/AllTests.py +++ b/py/test/Ice/facets/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, sys def test(b): if not b: @@ -18,7 +18,8 @@ class EmptyI(Test.Empty): def allTests(communicator): - print "testing Ice.Admin.Facets property... ", + sys.stdout.write("testing Ice.Admin.Facets property... ") + sys.stdout.flush() test(len(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")) == 0) communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar"); facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); @@ -37,9 +38,10 @@ def allTests(communicator): # facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); # test(len(facetFilter) == 0); communicator.getProperties().setProperty("Ice.Admin.Facets", ""); - print "ok" + print("ok") - print "testing facet registration exceptions... ", + sys.stdout.write("testing facet registration exceptions... ") + sys.stdout.flush() communicator.getProperties().setProperty("FacetExceptionTestAdapter.Endpoints", "default") adapter = communicator.createObjectAdapter("FacetExceptionTestAdapter") obj = EmptyI() @@ -56,9 +58,10 @@ def allTests(communicator): test(false) except Ice.NotRegisteredException: pass - print "ok" + print("ok") - print "testing removeAllFacets... ", + sys.stdout.write("testing removeAllFacets... ") + sys.stdout.flush() obj1 = EmptyI() obj2 = EmptyI() adapter.addFacet(obj1, communicator.stringToIdentity("id1"), "f1") @@ -81,17 +84,19 @@ def allTests(communicator): test(fm["f1"] == obj1) test(fm["f2"] == obj2) test(fm[""] == obj3) - print "ok" + print("ok") adapter.deactivate() - print "testing stringToProxy... ", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "d:default -p 12010" db = communicator.stringToProxy(ref) test(db) - print "ok" + print("ok") - print "testing unchecked cast... ", + sys.stdout.write("testing unchecked cast... ") + sys.stdout.flush() obj = Ice.ObjectPrx.uncheckedCast(db) test(obj.ice_getFacet() == "") obj = Ice.ObjectPrx.uncheckedCast(db, "facetABCD") @@ -108,9 +113,10 @@ def allTests(communicator): test(df2.ice_getFacet() == "facetABCD") df3 = Test.DPrx.uncheckedCast(df, "") test(df3.ice_getFacet() == "") - print "ok" + print("ok") - print "testing checked cast... ", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() obj = Ice.ObjectPrx.checkedCast(db) test(obj.ice_getFacet() == "") obj = Ice.ObjectPrx.checkedCast(db, "facetABCD") @@ -127,9 +133,10 @@ def allTests(communicator): test(df2.ice_getFacet() == "facetABCD") df3 = Test.DPrx.checkedCast(df, "") test(df3.ice_getFacet() == "") - print "ok" + print("ok") - print "testing non-facets A, B, C, and D... ", + sys.stdout.write("testing non-facets A, B, C, and D... ") + sys.stdout.flush() d = Test.DPrx.checkedCast(db) test(d) test(d == db) @@ -137,35 +144,39 @@ def allTests(communicator): test(d.callB() == "B") test(d.callC() == "C") test(d.callD() == "D") - print "ok" + print("ok") - print "testing facets A, B, C, and D... ", + sys.stdout.write("testing facets A, B, C, and D... ") + sys.stdout.flush() df = Test.DPrx.checkedCast(d, "facetABCD") test(df) test(df.callA() == "A") test(df.callB() == "B") test(df.callC() == "C") test(df.callD() == "D") - print "ok" + print("ok") - print "testing facets E and F... ", + sys.stdout.write("testing facets E and F... ") + sys.stdout.flush() ff = Test.FPrx.checkedCast(d, "facetEF") test(ff) test(ff.callE() == "E") test(ff.callF() == "F") - print "ok" + print("ok") - print "testing facet G... ", + sys.stdout.write("testing facet G... ") + sys.stdout.flush() gf = Test.GPrx.checkedCast(ff, "facetGH") test(gf) test(gf.callG() == "G") - print "ok" + print("ok") - print "testing whether casting preserves the facet... ", + sys.stdout.write("testing whether casting preserves the facet... ") + sys.stdout.flush() hf = Test.HPrx.checkedCast(gf) test(hf) test(hf.callG() == "G") test(hf.callH() == "H") - print "ok" + print("ok") return gf diff --git a/py/test/Ice/facets/run.py b/py/test/Ice/facets/run.py index 099ce110107..db68ff30b9a 100755 --- a/py/test/Ice/facets/run.py +++ b/py/test/Ice/facets/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/py/test/Ice/faultTolerance/AllTests.py b/py/test/Ice/faultTolerance/AllTests.py index 040e99a7540..e82f326051e 100644 --- a/py/test/Ice/faultTolerance/AllTests.py +++ b/py/test/Ice/faultTolerance/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, threading +import Ice, sys, threading Ice.loadSlice('Test.ice') import Test @@ -57,8 +57,8 @@ class Callback(CallbackBase): pass except Ice.ConnectFailedException: pass - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) test(False) self.called() @@ -66,19 +66,21 @@ class Callback(CallbackBase): return self._pid def allTests(communicator, ports): - print "testing stringToProxy... ", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "test" for p in ports: ref = ref + ":default -p " + str(p) base = communicator.stringToProxy(ref) test(base) - print "ok" + print("ok") - print "testing checked cast... ", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() obj = Test.TestIntfPrx.checkedCast(base) test(obj) test(obj == base) - print "ok" + print("ok") oldPid = 0 ami = False @@ -90,64 +92,72 @@ def allTests(communicator, ports): ami = not ami if not ami: - print "testing server #%d... " % i, + sys.stdout.write("testing server #%d... " % i) + sys.stdout.flush() pid = obj.pid() test(pid != oldPid) - print "ok" + print("ok") oldPid = pid else: - print "testing server #%d with AMI... " % i, + sys.stdout.write("testing server #%d with AMI... " % i) + sys.stdout.flush() cb = Callback() obj.begin_pid(cb.opPidI, cb.exception) cb.check() pid = cb.pid() test(pid != oldPid) - print "ok" + print("ok") oldPid = pid if j == 0: if not ami: - print "shutting down server #%d... " % i, + sys.stdout.write("shutting down server #%d... " % i) + sys.stdout.flush() obj.shutdown() - print "ok" + print("ok") else: - print "shutting down server #%d with AMI... " % i, + sys.stdout.write("shutting down server #%d with AMI... " % i) + sys.stdout.flush() cb = Callback() obj.begin_shutdown(cb.opShutdownI, cb.exception) cb.check() - print "ok" + print("ok") elif j == 1 or i + 1 > len(ports): if not ami: - print "aborting server #%d... " % i, + sys.stdout.write("aborting server #%d... " % i) + sys.stdout.flush() try: obj.abort() test(False) except Ice.ConnectionLostException: - print "ok" + print("ok") except Ice.ConnectFailedException: - print "ok" + print("ok") else: - print "aborting server #%d with AMI... " % i, + sys.stdout.write("aborting server #%d with AMI... " % i) + sys.stdout.flush() cb = Callback() obj.begin_abort(cb.response, cb.exceptAbortI) cb.check() - print "ok" + print("ok") elif j == 2 or j == 3: if not ami: - print "aborting server #%d and #%d with idempotent call... " % (i, i + 1), + sys.stdout.write("aborting server #%d and #%d with idempotent call... " % (i, i + 1)) + sys.stdout.flush() try: obj.idempotentAbort() test(False) except Ice.ConnectionLostException: - print "ok" + print("ok") except Ice.ConnectFailedException: - print "ok" + print("ok") else: - print "aborting server #%d and #%d with idempotent AMI call... " % (i, i + 1), + sys.stdout.write("aborting server #%d and #%d with idempotent AMI call... " % (i, i + 1)) + sys.stdout.flush() cb = Callback() obj.begin_idempotentAbort(cb.response, cb.exceptAbortI) cb.check() - print "ok" + print("ok") i = i + 1 else: @@ -156,9 +166,10 @@ def allTests(communicator, ports): i = i + 1 j = j + 1 - print "testing whether all servers are gone... ", + sys.stdout.write("testing whether all servers are gone... ") + sys.stdout.flush() try: obj.ice_ping() test(False) except Ice.LocalException: - print "ok" + print("ok") diff --git a/py/test/Ice/faultTolerance/Server.py b/py/test/Ice/faultTolerance/Server.py index dbc69708beb..b1b6b277d3f 100755 --- a/py/test/Ice/faultTolerance/Server.py +++ b/py/test/Ice/faultTolerance/Server.py @@ -22,7 +22,7 @@ class TestI(Test.TestIntf): current.adapter.getCommunicator().shutdown() def abort(self, current=None): - print "aborting..." + sys.stdout.write("aborting...") os._exit(0) def idempotentAbort(self, current=None): @@ -35,18 +35,18 @@ def run(args, communicator): port = 0 for arg in args[1:]: if arg[0] == '-': - print >> sys.stderr, args[0] + ": unknown option `" + arg + "'" + sys.stderr.write(args[0] + ": unknown option `" + arg + "'\n") usage(args[0]) return False if port > 0: - print >> sys.stderr, args[0] + ": only one port can be specified" + sys.stderr.write(args[0] + ": only one port can be specified\n") usage(args[0]) return False port = int(arg) if port <= 0: - print >> sys.stderr, args[0] + ": no port specified" + sys.stderr.write(args[0] + ": no port specified\n") usage(args[0]) return False diff --git a/py/test/Ice/faultTolerance/run.py b/py/test/Ice/faultTolerance/run.py index 44cf4fde9f3..b59bb43dae9 100755 --- a/py/test/Ice/faultTolerance/run.py +++ b/py/test/Ice/faultTolerance/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil server = os.path.join(os.getcwd(), "Server.py") client = os.path.join(os.getcwd(), "Client.py") @@ -28,20 +28,20 @@ base = 12340 serverProc = [] for i in range(0, num): - print "starting server #%d..." % (i + 1), + sys.stdout.write("starting server #%d... " % (i + 1)) sys.stdout.flush() serverProc.append(TestUtil.startServer(server, "%d" % (base + i))) - print "ok" + print("ok") ports = "" for i in range(0, num): ports = "%s %d" % (ports, base + i) -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient(client, ports, startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() for p in serverProc: p.waitTestSuccess() - diff --git a/py/test/Ice/info/AllTests.py b/py/test/Ice/info/AllTests.py index 9820a1e83a4..b9d81645899 100644 --- a/py/test/Ice/info/AllTests.py +++ b/py/test/Ice/info/AllTests.py @@ -7,14 +7,15 @@ # # ********************************************************************** -import Ice, Test, threading +import Ice, Test, sys, threading def test(b): if not b: raise RuntimeError('test assertion failed') def allTests(communicator, collocated): - print "testing proxy endpoint information...", + sys.stdout.write("testing proxy endpoint information... ") + sys.stdout.flush() p1 = communicator.stringToProxy("test -t:default -h tcphost -p 10000 -t 1200 -z:" + \ "udp -h udphost -p 10001 --interface eth0 --ttl 5:" + \ @@ -49,11 +50,12 @@ def allTests(communicator, collocated): opaqueEndpoint = endps[2].getInfo() test(isinstance(opaqueEndpoint, Ice.OpaqueEndpointInfo)) - print "ok" + print("ok") defaultHost = communicator.getProperties().getProperty("Ice.Default.Host") - print "test object adapter endpoint information...", + sys.stdout.write("test object adapter endpoint information... ") + sys.stdout.flush() communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -t 15000:udp") adapter = communicator.createObjectAdapter("TestAdapter") @@ -94,12 +96,13 @@ def allTests(communicator, collocated): adapter.destroy() - print "ok" + print("ok") base = communicator.stringToProxy("test:default -p 12010:udp -p 12010") testIntf = Test.TestIntfPrx.checkedCast(base) - print "test connection endpoint information...", + sys.stdout.write("test connection endpoint information... ") + sys.stdout.flush() ipinfo = base.ice_getConnection().getEndpoint().getInfo() test(ipinfo.port == 12010) @@ -116,9 +119,10 @@ def allTests(communicator, collocated): test(udp.port == 12010) test(udp.host == defaultHost) - print "ok" + print("ok") - print "testing connection information...", + sys.stdout.write("testing connection information... ") + sys.stdout.flush() info = base.ice_getConnection().getInfo() test(not info.incoming) @@ -135,7 +139,7 @@ def allTests(communicator, collocated): test(ctx["remotePort"] == str(info.localPort)) test(ctx["localPort"] == str(info.remotePort)) - print "ok" + print("ok") testIntf.shutdown() diff --git a/py/test/Ice/info/Client.py b/py/test/Ice/info/Client.py index 5cd19058441..42d97e921b9 100755 --- a/py/test/Ice/info/Client.py +++ b/py/test/Ice/info/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/info/Server.py b/py/test/Ice/info/Server.py index 25d50c3f5b4..e48d8c894de 100755 --- a/py/test/Ice/info/Server.py +++ b/py/test/Ice/info/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/info/run.py b/py/test/Ice/info/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/info/run.py +++ b/py/test/Ice/info/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/inheritance/AllTests.py b/py/test/Ice/inheritance/AllTests.py index 3a2f243b1f3..acd585bb835 100644 --- a/py/test/Ice/inheritance/AllTests.py +++ b/py/test/Ice/inheritance/AllTests.py @@ -7,26 +7,29 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, sys def test(b): if not b: raise RuntimeError('test assertion failed') def allTests(communicator): - print "testing stringToProxy... ", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "initial:default -p 12010" base = communicator.stringToProxy(ref) test(base) - print "ok" + print("ok") - print "testing checked cast... ", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() initial = Test.InitialPrx.checkedCast(base) test(initial) test(initial == base) - print "ok" + print("ok") - print "getting proxies for class hierarchy... ", + sys.stdout.write("getting proxies for class hierarchy... ") + sys.stdout.flush() ca = initial.caop() cb = initial.cbop() cc = initial.ccop() @@ -37,9 +40,10 @@ def allTests(communicator): test(cb != cc) test(cb != cd) test(cc != cd) - print "ok" + print("ok") - print "getting proxies for interface hierarchy... ", + sys.stdout.write("getting proxies for interface hierarchy... ") + sys.stdout.flush() ia = initial.iaop() ib1 = initial.ib1op() ib2 = initial.ib2op() @@ -49,9 +53,10 @@ def allTests(communicator): test(ia != ic) test(ib1 != ic) test(ib2 != ic) - print "ok" + print("ok") - print "invoking proxy operations on class hierarchy... ", + sys.stdout.write("invoking proxy operations on class hierarchy... ") + sys.stdout.flush() cao = ca.caop(ca) test(cao == ca) cao = ca.caop(cb) @@ -94,9 +99,10 @@ def allTests(communicator): test(cbo == cc) cco = cc.ccop(cc) test(cco == cc) - print "ok" + print("ok") - print "ditto, but for interface hierarchy... ", + sys.stdout.write("ditto, but for interface hierarchy... ") + sys.stdout.flush() iao = ia.iaop(ia) test(iao == ia) iao = ia.iaop(ib1) @@ -173,9 +179,10 @@ def allTests(communicator): ico = ic.icop(ic) test(ico == ic) - print "ok" + print("ok") - print "ditto, but for class implementing interfaces... ", + sys.stdout.write("ditto, but for class implementing interfaces... ") + sys.stdout.flush() cao = cd.caop(cd) test(cao == cd) cbo = cd.cbop(cd) @@ -204,6 +211,6 @@ def allTests(communicator): ib2o = cd.cdop(cd) test(ib2o == cd) - print "ok" + print("ok") return initial diff --git a/py/test/Ice/inheritance/run.py b/py/test/Ice/inheritance/run.py index 099ce110107..db68ff30b9a 100755 --- a/py/test/Ice/inheritance/run.py +++ b/py/test/Ice/inheritance/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/py/test/Ice/location/AllTests.py b/py/test/Ice/location/AllTests.py index da702bb1cfd..c0a37c2b2fd 100644 --- a/py/test/Ice/location/AllTests.py +++ b/py/test/Ice/location/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, sys def test(b): if not b: @@ -18,15 +18,17 @@ def allTests(communicator, ref): locator = communicator.getDefaultLocator() test(manager) - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() base = communicator.stringToProxy("test @ TestAdapter") base2 = communicator.stringToProxy("test @ TestAdapter") base3 = communicator.stringToProxy("test") base4 = communicator.stringToProxy("ServerManager") base5 = communicator.stringToProxy("test2") - print "ok" + print("ok") - print "testing ice_locator and ice_getLocator... ", + sys.stdout.write("testing ice_locator and ice_getLocator... ") + sys.stdout.flush() test(Ice.proxyIdentityEqual(base.ice_getLocator(), communicator.getDefaultLocator())); anotherLocator = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("anotherLocator")); base = base.ice_locator(anotherLocator); @@ -55,13 +57,15 @@ def allTests(communicator, ref): communicator.setDefaultRouter(None); base = communicator.stringToProxy("test @ TestAdapter"); test(not base.ice_getRouter()); - print "ok" + print("ok") - print "starting server...", + sys.stdout.write("starting server... ") + sys.stdout.flush() manager.startServer() - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() obj = Test.TestIntfPrx.checkedCast(base) obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test@TestAdapter")) obj = Test.TestIntfPrx.checkedCast(communicator.stringToProxy("test @TestAdapter")) @@ -75,9 +79,10 @@ def allTests(communicator, ref): test(obj4) obj5 = Test.TestIntfPrx.checkedCast(base5) test(obj5) - print "ok" + print("ok") - print "testing id@AdapterId indirect proxy...", + sys.stdout.write("testing id@AdapterId indirect proxy... ") + sys.stdout.flush() obj.shutdown() manager.startServer() try: @@ -85,9 +90,10 @@ def allTests(communicator, ref): obj2.ice_ping() except Ice.LocalException: test(False) - print "ok" + print("ok") - print "testing identity indirect proxy...", + sys.stdout.write("testing identity indirect proxy... ") + sys.stdout.flush() obj.shutdown() manager.startServer() try: @@ -142,40 +148,45 @@ def allTests(communicator, ref): obj5.ice_ping() except Ice.LocalException: test(False) - print "ok" + print("ok") - print "testing reference with unknown identity...", + sys.stdout.write("testing reference with unknown identity... ") + sys.stdout.flush() try: base = communicator.stringToProxy("unknown/unknown") base.ice_ping() test(False) - except Ice.NotRegisteredException, ex: + except Ice.NotRegisteredException as ex: test(ex.kindOfObject == "object") test(ex.id == "unknown/unknown") - print "ok" + print("ok") - print "testing reference with unknown adapter...", + sys.stdout.write("testing reference with unknown adapter... ") + sys.stdout.flush() try: base = communicator.stringToProxy("test @ TestAdapterUnknown") base.ice_ping() test(False) - except Ice.NotRegisteredException, ex: + except Ice.NotRegisteredException as ex: test(ex.kindOfObject == "object adapter") test(ex.id == "TestAdapterUnknown") - print "ok" + print("ok") - print "testing object reference from server...", + sys.stdout.write("testing object reference from server... ") + sys.stdout.flush() hello = obj.getHello() hello.sayHello() - print "ok" + print("ok") - print "testing object reference from server after shutdown...", + sys.stdout.write("testing object reference from server after shutdown... ") + sys.stdout.flush() obj.shutdown() manager.startServer() hello.sayHello() - print "ok" + print("ok") - print "testing object migration...", + sys.stdout.write("testing object migration... ") + sys.stdout.flush() hello = Test.HelloPrx.checkedCast(communicator.stringToProxy("hello")) obj.migrateHello() hello.sayHello() @@ -183,13 +194,15 @@ def allTests(communicator, ref): hello.sayHello() obj.migrateHello() hello.sayHello() - print "ok" + print("ok") - print "shutdown server...", + sys.stdout.write("shutdown server... ") + sys.stdout.flush() obj.shutdown() - print "ok" + print("ok") - print "testing whether server is gone...", + sys.stdout.write("testing whether server is gone... ") + sys.stdout.flush() try: obj2.ice_ping() test(False) @@ -205,13 +218,14 @@ def allTests(communicator, ref): test(False) except Ice.LocalException: pass - print "ok" + print("ok") # # Collocated invocations are not supported in Python. # - #print "testing indirect references to collocated objects...", + #sys.stdout.write("testing indirect references to collocated objects... ") - print "shutdown server manager...", + sys.stdout.write("shutdown server manager... ") + sys.stdout.flush() manager.shutdown() - print "ok" + print("ok") diff --git a/py/test/Ice/location/Client.py b/py/test/Ice/location/Client.py index bde025692ff..f69df0e42d9 100755 --- a/py/test/Ice/location/Client.py +++ b/py/test/Ice/location/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/location/Server.py b/py/test/Ice/location/Server.py index af53260c213..c10cdd3a64b 100755 --- a/py/test/Ice/location/Server.py +++ b/py/test/Ice/location/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") @@ -47,12 +47,12 @@ class ServerLocatorRegistry(Test.TestLocatorRegistry): self._objects[obj.ice_getIdentity()] = obj def getAdapter(self, adapter): - if not self._adapters.has_key(adapter): + if adapter not in self._adapters: raise Ice.AdapterNotFoundException() return self._adapters[adapter] def getObject(self, id): - if not self._objects.has_key(id): + if id not in self._objects: raise Ice.ObjectNotFoundException() return self._objects[id] diff --git a/py/test/Ice/location/run.py b/py/test/Ice/location/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/location/run.py +++ b/py/test/Ice/location/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/objects/AllTests.py b/py/test/Ice/objects/AllTests.py index ae6fa28ea6a..73025afd2a2 100644 --- a/py/test/Ice/objects/AllTests.py +++ b/py/test/Ice/objects/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, TestI +import Ice, Test, TestI, sys # # Ice for Python behaves differently than Ice for C++, because @@ -54,39 +54,46 @@ def allTests(communicator, collocated): communicator.addObjectFactory(factory, '::Test::J') communicator.addObjectFactory(factory, '::Test::H') - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "initial:default -p 12010" base = communicator.stringToProxy(ref) test(base) - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() initial = Test.InitialPrx.checkedCast(base) test(initial) test(initial == base) - print "ok" + print("ok") - print "getting B1...", + sys.stdout.write("getting B1... ") + sys.stdout.flush() b1 = initial.getB1() test(b1) - print "ok" + print("ok") - print "getting B2...", + sys.stdout.write("getting B2... ") + sys.stdout.flush() b2 = initial.getB2() test(b2) - print "ok" + print("ok") - print "getting C...", + sys.stdout.write("getting C... ") + sys.stdout.flush() c = initial.getC() test(c) - print "ok" + print("ok") - print "getting D...", + sys.stdout.write("getting D... ") + sys.stdout.flush() d = initial.getD() test(d) - print "ok" + print("ok") - print "testing protected members...", + sys.stdout.write("testing protected members... ") + sys.stdout.flush() e = initial.getE() test(e.checkValues()) test(e._i == 1) @@ -95,24 +102,27 @@ def allTests(communicator, collocated): test(f.checkValues()) test(f.e2.checkValues()) test(f._e1.checkValues()) - print "ok" + print("ok") - print "getting I, J, H...", + sys.stdout.write("getting I, J, H... ") + sys.stdout.flush() i = initial.getI() test(i) j = initial.getJ() test(isinstance(j, Test.J)) h = initial.getH() test(isinstance(h, Test.H)) - print "ok" + print("ok") - print "setting I...", + sys.stdout.write("setting I... ") + sys.stdout.flush() initial.setI(TestI.II()) initial.setI(TestI.JI()) initial.setI(TestI.HI()) - print "ok" + print("ok") - print "checking consistency...", + sys.stdout.write("checking consistency... ") + sys.stdout.flush() test(b1 != b2) test(b1 != c) test(b1 != d) @@ -135,17 +145,19 @@ def allTests(communicator, collocated): # More tests possible for b2 and d, but I think this is already sufficient. test(b2.theA == b2) test(d.theC == None) - print "ok" + print("ok") - print "getting B1, B2, C, and D all at once...", + sys.stdout.write("getting B1, B2, C, and D all at once... ") + sys.stdout.flush() b1, b2, c, d = initial.getAll() test(b1) test(b2) test(c) test(d) - print "ok" + print("ok") - print "checking consistency...", + sys.stdout.write("checking consistency... ") + sys.stdout.flush() test(b1 != b2) test(b1 != c) test(b1 != d) @@ -170,10 +182,11 @@ def allTests(communicator, collocated): test(d.theB.postUnmarshalInvoked()) test(d.theB.theC.preMarshalInvoked) test(d.theB.theC.postUnmarshalInvoked()) - print "ok" + print("ok") if not collocated: - print "testing UnexpectedObjectException...", + sys.stdout.write("testing UnexpectedObjectException... ") + sys.stdout.flush() ref = "uoet:default -p 12010" base = communicator.stringToProxy(ref) test(base) @@ -182,15 +195,15 @@ def allTests(communicator, collocated): try: uoet.op() test(False) - except Ice.UnexpectedObjectException, ex: + except Ice.UnexpectedObjectException as ex: test(ex.type == "::Test::AlsoEmpty") test(ex.expectedType == "::Test::Empty") - except Ice.Exception, ex: - print ex + except Ice.Exception as ex: + print(ex) test(False) except: - print sys.exc_info() + print(sys.exc_info()) test(False) - print "ok" + print("ok") return initial diff --git a/py/test/Ice/objects/run.py b/py/test/Ice/objects/run.py index 099ce110107..db68ff30b9a 100755 --- a/py/test/Ice/objects/run.py +++ b/py/test/Ice/objects/run.py @@ -16,10 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() TestUtil.collocatedTest() - diff --git a/py/test/Ice/operations/AllTests.py b/py/test/Ice/operations/AllTests.py index ee7ee230e9b..13debf12e8b 100644 --- a/py/test/Ice/operations/AllTests.py +++ b/py/test/Ice/operations/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, Twoways, TwowaysAMI, TwowaysNewAMI, Oneways, OnewaysAMI, OnewaysNewAMI, BatchOneways +import Ice, Test, Twoways, TwowaysAMI, TwowaysNewAMI, Oneways, OnewaysAMI, OnewaysNewAMI, BatchOneways, sys def test(b): if not b: @@ -19,36 +19,43 @@ def allTests(communicator, collocated): cl = Test.MyClassPrx.checkedCast(base) derived = Test.MyDerivedClassPrx.checkedCast(cl) - print "testing twoway operations...", + sys.stdout.write("testing twoway operations... ") + sys.stdout.flush() Twoways.twoways(communicator, cl) Twoways.twoways(communicator, derived) derived.opDerived() - print "ok" + print("ok") - print "testing oneway operations...", + sys.stdout.write("testing oneway operations... ") + sys.stdout.flush() Oneways.oneways(communicator, cl) - print "ok" + print("ok") if not collocated: - print "testing twoway operations with AMI...", + sys.stdout.write("testing twoway operations with AMI... ") + sys.stdout.flush() TwowaysAMI.twowaysAMI(communicator, cl) - print "ok" + print("ok") - print "testing twoway operations with new AMI mapping...", + sys.stdout.write("testing twoway operations with new AMI mapping... ") + sys.stdout.flush() TwowaysNewAMI.twowaysNewAMI(communicator, cl) - print "ok" + print("ok") - print "testing oneway operations with AMI...", + sys.stdout.write("testing oneway operations with AMI... ") + sys.stdout.flush() OnewaysAMI.onewaysAMI(communicator, cl) - print "ok" + print("ok") - print "testing oneway operations with new AMI mapping...", + sys.stdout.write("testing oneway operations with new AMI mapping... ") + sys.stdout.flush() OnewaysNewAMI.onewaysNewAMI(communicator, cl) - print "ok" + print("ok") - print "testing batch oneway operations... ", + sys.stdout.write("testing batch oneway operations... ") + sys.stdout.flush() BatchOneways.batchOneways(cl) BatchOneways.batchOneways(derived) - print "ok" + print("ok") return cl diff --git a/py/test/Ice/operations/BatchOneways.py b/py/test/Ice/operations/BatchOneways.py index a263d190d07..97d8eec9c04 100644 --- a/py/test/Ice/operations/BatchOneways.py +++ b/py/test/Ice/operations/BatchOneways.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, array +import Ice, Test, array, sys def test(b): if not b: @@ -15,20 +15,25 @@ def test(b): def batchOneways(p): - bs1 = [] - bs1[0:10 * 1024] = range(0, 10 * 1024) # add 100,000 entries. - bs1 = ['\x00' for x in bs1] # set them all to \x00 - bs1 = ''.join(bs1) # make into a byte array - - bs2 = [] - bs2[0:99 * 1024] = range(0, 99 * 1024) # add 100,000 entries. - bs2 = ['\x00' for x in bs2] # set them all to \x00 - bs2 = ''.join(bs2) # make into a byte array - - bs3 = [] - bs3[0:100 * 1024] = range(0, 100 * 1024) # add 100,000 entries. - bs3 = ['\x00' for x in bs3] # set them all to \x00 - bs3 = ''.join(bs3) # make into a byte array + if sys.version_info[0] == 2: + bs1 = [] + bs1[0:10 * 1024] = range(0, 10 * 1024) # add 100,000 entries. + bs1 = ['\x00' for x in bs1] # set them all to \x00 + bs1 = ''.join(bs1) # make into a byte array + + bs2 = [] + bs2[0:99 * 1024] = range(0, 99 * 1024) # add 100,000 entries. + bs2 = ['\x00' for x in bs2] # set them all to \x00 + bs2 = ''.join(bs2) # make into a byte array + + bs3 = [] + bs3[0:100 * 1024] = range(0, 100 * 1024) # add 100,000 entries. + bs3 = ['\x00' for x in bs3] # set them all to \x00 + bs3 = ''.join(bs3) # make into a byte array + else: + bs1 = bytes([0 for x in range(0, 10 * 1024)]) + bs2 = bytes([0 for x in range(0, 99 * 1024)]) + bs3 = bytes([0 for x in range(0, 100 * 1024)]) try: p.opByteSOneway(bs1) diff --git a/py/test/Ice/operations/Client.py b/py/test/Ice/operations/Client.py index 67c8ae96bf9..57450e3f8ac 100755 --- a/py/test/Ice/operations/Client.py +++ b/py/test/Ice/operations/Client.py @@ -14,7 +14,7 @@ import Ice import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") @@ -27,13 +27,14 @@ def test(b): def run(args, communicator): myClass = AllTests.allTests(communicator, False) - print "testing server shutdown...", + sys.stdout.write("testing server shutdown... ") + sys.stdout.flush() myClass.shutdown() try: myClass.opVoid() test(False) except Ice.LocalException: - print "ok" + print("ok") return True diff --git a/py/test/Ice/operations/Collocated.py b/py/test/Ice/operations/Collocated.py index 975b0d90b83..c4665b05f5f 100755 --- a/py/test/Ice/operations/Collocated.py +++ b/py/test/Ice/operations/Collocated.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice('"-I' + slice_dir + '" Test.ice') diff --git a/py/test/Ice/operations/Oneways.py b/py/test/Ice/operations/Oneways.py index a541a78eca8..800cfcd69a0 100644 --- a/py/test/Ice/operations/Oneways.py +++ b/py/test/Ice/operations/Oneways.py @@ -44,4 +44,3 @@ def oneways(communicator, p): p.opByte(0xff, 0x0f) except Ice.TwowayOnlyException: pass - diff --git a/py/test/Ice/operations/Server.py b/py/test/Ice/operations/Server.py index bc8fefe5e93..55d8b2f6304 100755 --- a/py/test/Ice/operations/Server.py +++ b/py/test/Ice/operations/Server.py @@ -12,7 +12,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice('"-I' + slice_dir + '" Test.ice') diff --git a/py/test/Ice/operations/ServerAMD.py b/py/test/Ice/operations/ServerAMD.py index 4a4b1182a68..0ff9afd957a 100755 --- a/py/test/Ice/operations/ServerAMD.py +++ b/py/test/Ice/operations/ServerAMD.py @@ -13,7 +13,7 @@ import os, sys, traceback, threading import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' TestAMD.ice") @@ -102,11 +102,15 @@ class MyDerivedClassI(Test.MyDerivedClass): cb.ice_response(p2, p1) def opByteS_async(self, cb, p1, p2, current=None): - # By default sequence<byte> maps to a string. - p3 = map(ord, p1) - p3.reverse() - r = map(ord, p1) - r.extend(map(ord, p2)) + if sys.version_info[0] == 2: + # By default sequence<byte> maps to a string. + p3 = map(ord, p1) + p3.reverse() + r = map(ord, p1) + r.extend(map(ord, p2)) + else: + p3 = bytes(reversed(p1)) + r = p1 + p2 cb.ice_response(r, p3) def opBoolS_async(self, cb, p1, p2, current=None): diff --git a/py/test/Ice/operations/TestI.py b/py/test/Ice/operations/TestI.py index 58505a9d0b4..c03292e1a10 100644 --- a/py/test/Ice/operations/TestI.py +++ b/py/test/Ice/operations/TestI.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test +import Ice, Test, sys def test(b): if not b: @@ -63,11 +63,15 @@ class MyDerivedClassI(Test.MyDerivedClass): return (p2, p1) def opByteS(self, p1, p2, current=None): - # By default sequence<byte> maps to a string. - p3 = map(ord, p1) - p3.reverse() - r = map(ord, p1) - r.extend(map(ord, p2)) + if sys.version_info[0] == 2: + # By default sequence<byte> maps to a string. + p3 = map(ord, p1) + p3.reverse() + r = map(ord, p1) + r.extend(map(ord, p2)) + else: + p3 = bytes(reversed(p1)) + r = p1 + p2 return (r, p3) def opBoolS(self, p1, p2, current=None): diff --git a/py/test/Ice/operations/Twoways.py b/py/test/Ice/operations/Twoways.py index fcd33454529..117a406628b 100644 --- a/py/test/Ice/operations/Twoways.py +++ b/py/test/Ice/operations/Twoways.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, math, Test, array +import Ice, math, Test, array, sys def test(b): if not b: @@ -92,9 +92,10 @@ def twoways(communicator, p): r, s = p.opString("hello", "world") test(s == "world hello") test(r == "hello world") - r, s = p.opString(u"hello", u"world") - test(s == "world hello") - test(r == "hello world") + if sys.version_info[0] == 2: + r, s = p.opString(unicode("hello"), unicode("world")) + test(s == "world hello") + test(r == "hello world") # # opMyEnum @@ -158,19 +159,33 @@ def twoways(communicator, p): rso, bso = p.opByteS(bsi1, bsi2) test(len(bso) == 4) - test(bso[0] == '\x22') - test(bso[1] == '\x12') - test(bso[2] == '\x11') - test(bso[3] == '\x01') test(len(rso) == 8) - test(rso[0] == '\x01') - test(rso[1] == '\x11') - test(rso[2] == '\x12') - test(rso[3] == '\x22') - test(rso[4] == '\xf1') - test(rso[5] == '\xf2') - test(rso[6] == '\xf3') - test(rso[7] == '\xf4') + if sys.version_info[0] == 2: + test(bso[0] == '\x22') + test(bso[1] == '\x12') + test(bso[2] == '\x11') + test(bso[3] == '\x01') + test(rso[0] == '\x01') + test(rso[1] == '\x11') + test(rso[2] == '\x12') + test(rso[3] == '\x22') + test(rso[4] == '\xf1') + test(rso[5] == '\xf2') + test(rso[6] == '\xf3') + test(rso[7] == '\xf4') + else: + test(bso[0] == 0x22) + test(bso[1] == 0x12) + test(bso[2] == 0x11) + test(bso[3] == 0x01) + test(rso[0] == 0x01) + test(rso[1] == 0x11) + test(rso[2] == 0x12) + test(rso[3] == 0x22) + test(rso[4] == 0xf1) + test(rso[5] == 0xf2) + test(rso[6] == 0xf3) + test(rso[7] == 0xf4) # # opByteS (array) @@ -182,19 +197,33 @@ def twoways(communicator, p): rso, bso = p.opByteS(bsi1, bsi2) test(len(bso) == 4) - test(bso[0] == '\x22') - test(bso[1] == '\x12') - test(bso[2] == '\x11') - test(bso[3] == '\x01') test(len(rso) == 8) - test(rso[0] == '\x01') - test(rso[1] == '\x11') - test(rso[2] == '\x12') - test(rso[3] == '\x22') - test(rso[4] == '\xf1') - test(rso[5] == '\xf2') - test(rso[6] == '\xf3') - test(rso[7] == '\xf4') + if sys.version_info[0] == 2: + test(bso[0] == '\x22') + test(bso[1] == '\x12') + test(bso[2] == '\x11') + test(bso[3] == '\x01') + test(rso[0] == '\x01') + test(rso[1] == '\x11') + test(rso[2] == '\x12') + test(rso[3] == '\x22') + test(rso[4] == '\xf1') + test(rso[5] == '\xf2') + test(rso[6] == '\xf3') + test(rso[7] == '\xf4') + else: + test(bso[0] == 0x22) + test(bso[1] == 0x12) + test(bso[2] == 0x11) + test(bso[3] == 0x01) + test(rso[0] == 0x01) + test(rso[1] == 0x11) + test(rso[2] == 0x12) + test(rso[3] == 0x22) + test(rso[4] == 0xf1) + test(rso[5] == 0xf2) + test(rso[6] == 0xf3) + test(rso[7] == 0xf4) # # opBoolS @@ -362,23 +391,36 @@ def twoways(communicator, p): rso, bso = p.opByteSS(bsi1, bsi2) test(len(bso) == 2) test(len(bso[0]) == 1) - test(bso[0][0] == '\xff') test(len(bso[1]) == 3) - test(bso[1][0] == '\x01') - test(bso[1][1] == '\x11') - test(bso[1][2] == '\x12') test(len(rso) == 4) test(len(rso[0]) == 3) - test(rso[0][0] == '\x01') - test(rso[0][1] == '\x11') - test(rso[0][2] == '\x12') test(len(rso[1]) == 1) - test(rso[1][0] == '\xff') test(len(rso[2]) == 1) - test(rso[2][0] == '\x0e') test(len(rso[3]) == 2) - test(rso[3][0] == '\xf2') - test(rso[3][1] == '\xf1') + if sys.version_info[0] == 2: + test(bso[0][0] == '\xff') + test(bso[1][0] == '\x01') + test(bso[1][1] == '\x11') + test(bso[1][2] == '\x12') + test(rso[0][0] == '\x01') + test(rso[0][1] == '\x11') + test(rso[0][2] == '\x12') + test(rso[1][0] == '\xff') + test(rso[2][0] == '\x0e') + test(rso[3][0] == '\xf2') + test(rso[3][1] == '\xf1') + else: + test(bso[0][0] == 0xff) + test(bso[1][0] == 0x01) + test(bso[1][1] == 0x11) + test(bso[1][2] == 0x12) + test(rso[0][0] == 0x01) + test(rso[0][1] == 0x11) + test(rso[0][2] == 0x12) + test(rso[1][0] == 0xff) + test(rso[2][0] == 0x0e) + test(rso[3][0] == 0xf2) + test(rso[3][1] == 0xf1) # # opFloatDoubleSS diff --git a/py/test/Ice/operations/TwowaysAMI.py b/py/test/Ice/operations/TwowaysAMI.py index 5a231a52eb8..834f19748bd 100644 --- a/py/test/Ice/operations/TwowaysAMI.py +++ b/py/test/Ice/operations/TwowaysAMI.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, math, threading +import Ice, Test, math, sys, threading def test(b): if not b: @@ -189,19 +189,33 @@ class AMI_MyClass_opByteSI(CallbackBase): def ice_response(self, rso, bso): test(len(bso) == 4) - test(bso[0] == '\x22') - test(bso[1] == '\x12') - test(bso[2] == '\x11') - test(bso[3] == '\x01') test(len(rso) == 8) - test(rso[0] == '\x01') - test(rso[1] == '\x11') - test(rso[2] == '\x12') - test(rso[3] == '\x22') - test(rso[4] == '\xf1') - test(rso[5] == '\xf2') - test(rso[6] == '\xf3') - test(rso[7] == '\xf4') + if sys.version_info[0] == 2: + test(bso[0] == '\x22') + test(bso[1] == '\x12') + test(bso[2] == '\x11') + test(bso[3] == '\x01') + test(rso[0] == '\x01') + test(rso[1] == '\x11') + test(rso[2] == '\x12') + test(rso[3] == '\x22') + test(rso[4] == '\xf1') + test(rso[5] == '\xf2') + test(rso[6] == '\xf3') + test(rso[7] == '\xf4') + else: + test(bso[0] == 0x22) + test(bso[1] == 0x12) + test(bso[2] == 0x11) + test(bso[3] == 0x01) + test(rso[0] == 0x01) + test(rso[1] == 0x11) + test(rso[2] == 0x12) + test(rso[3] == 0x22) + test(rso[4] == 0xf1) + test(rso[5] == 0xf2) + test(rso[6] == 0xf3) + test(rso[7] == 0xf4) self.called() def ice_exception(self, ex): @@ -305,23 +319,36 @@ class AMI_MyClass_opByteSSI(CallbackBase): def ice_response(self, rso, bso): test(len(bso) == 2) test(len(bso[0]) == 1) - test(bso[0][0] == '\xff') test(len(bso[1]) == 3) - test(bso[1][0] == '\x01') - test(bso[1][1] == '\x11') - test(bso[1][2] == '\x12') test(len(rso) == 4) test(len(rso[0]) == 3) - test(rso[0][0] == '\x01') - test(rso[0][1] == '\x11') - test(rso[0][2] == '\x12') test(len(rso[1]) == 1) - test(rso[1][0] == '\xff') test(len(rso[2]) == 1) - test(rso[2][0] == '\x0e') test(len(rso[3]) == 2) - test(rso[3][0] == '\xf2') - test(rso[3][1] == '\xf1') + if sys.version_info[0] == 2: + test(bso[0][0] == '\xff') + test(bso[1][0] == '\x01') + test(bso[1][1] == '\x11') + test(bso[1][2] == '\x12') + test(rso[0][0] == '\x01') + test(rso[0][1] == '\x11') + test(rso[0][2] == '\x12') + test(rso[1][0] == '\xff') + test(rso[2][0] == '\x0e') + test(rso[3][0] == '\xf2') + test(rso[3][1] == '\xf1') + else: + test(bso[0][0] == 0xff) + test(bso[1][0] == 0x01) + test(bso[1][1] == 0x11) + test(bso[1][2] == 0x12) + test(rso[0][0] == 0x01) + test(rso[0][1] == 0x11) + test(rso[0][2] == 0x12) + test(rso[1][0] == 0xff) + test(rso[2][0] == 0x0e) + test(rso[3][0] == 0xf2) + test(rso[3][1] == 0xf1) self.called() def ice_exception(self, ex): diff --git a/py/test/Ice/operations/TwowaysNewAMI.py b/py/test/Ice/operations/TwowaysNewAMI.py index ec510969a54..9ab205f238f 100644 --- a/py/test/Ice/operations/TwowaysNewAMI.py +++ b/py/test/Ice/operations/TwowaysNewAMI.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, math, threading +import Ice, Test, math, sys, threading def test(b): if not b: @@ -117,19 +117,33 @@ class Callback(CallbackBase): def opByteS(self, rso, bso): test(len(bso) == 4) - test(bso[0] == '\x22') - test(bso[1] == '\x12') - test(bso[2] == '\x11') - test(bso[3] == '\x01') test(len(rso) == 8) - test(rso[0] == '\x01') - test(rso[1] == '\x11') - test(rso[2] == '\x12') - test(rso[3] == '\x22') - test(rso[4] == '\xf1') - test(rso[5] == '\xf2') - test(rso[6] == '\xf3') - test(rso[7] == '\xf4') + if sys.version_info[0] == 2: + test(bso[0] == '\x22') + test(bso[1] == '\x12') + test(bso[2] == '\x11') + test(bso[3] == '\x01') + test(rso[0] == '\x01') + test(rso[1] == '\x11') + test(rso[2] == '\x12') + test(rso[3] == '\x22') + test(rso[4] == '\xf1') + test(rso[5] == '\xf2') + test(rso[6] == '\xf3') + test(rso[7] == '\xf4') + else: + test(bso[0] == 0x22) + test(bso[1] == 0x12) + test(bso[2] == 0x11) + test(bso[3] == 0x01) + test(rso[0] == 0x01) + test(rso[1] == 0x11) + test(rso[2] == 0x12) + test(rso[3] == 0x22) + test(rso[4] == 0xf1) + test(rso[5] == 0xf2) + test(rso[6] == 0xf3) + test(rso[7] == 0xf4) self.called() def opBoolS(self, rso, bso): @@ -198,23 +212,36 @@ class Callback(CallbackBase): def opByteSS(self, rso, bso): test(len(bso) == 2) test(len(bso[0]) == 1) - test(bso[0][0] == '\xff') test(len(bso[1]) == 3) - test(bso[1][0] == '\x01') - test(bso[1][1] == '\x11') - test(bso[1][2] == '\x12') test(len(rso) == 4) test(len(rso[0]) == 3) - test(rso[0][0] == '\x01') - test(rso[0][1] == '\x11') - test(rso[0][2] == '\x12') test(len(rso[1]) == 1) - test(rso[1][0] == '\xff') test(len(rso[2]) == 1) - test(rso[2][0] == '\x0e') test(len(rso[3]) == 2) - test(rso[3][0] == '\xf2') - test(rso[3][1] == '\xf1') + if sys.version_info[0] == 2: + test(bso[0][0] == '\xff') + test(bso[1][0] == '\x01') + test(bso[1][1] == '\x11') + test(bso[1][2] == '\x12') + test(rso[0][0] == '\x01') + test(rso[0][1] == '\x11') + test(rso[0][2] == '\x12') + test(rso[1][0] == '\xff') + test(rso[2][0] == '\x0e') + test(rso[3][0] == '\xf2') + test(rso[3][1] == '\xf1') + else: + test(bso[0][0] == 0xff) + test(bso[1][0] == 0x01) + test(bso[1][1] == 0x11) + test(bso[1][2] == 0x12) + test(rso[0][0] == 0x01) + test(rso[0][1] == 0x11) + test(rso[0][2] == 0x12) + test(rso[1][0] == 0xff) + test(rso[2][0] == 0x0e) + test(rso[3][0] == 0xf2) + test(rso[3][1] == 0xf1) self.called() def opFloatDoubleSS(self, rso, fso, dso): diff --git a/py/test/Ice/operations/run.py b/py/test/Ice/operations/run.py index 8101d1c0729..29e1062ae3f 100755 --- a/py/test/Ice/operations/run.py +++ b/py/test/Ice/operations/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0") - diff --git a/py/test/Ice/properties/Client.py b/py/test/Ice/properties/Client.py index 517c3b14205..49b2bde3982 100644 --- a/py/test/Ice/properties/Client.py +++ b/py/test/Ice/properties/Client.py @@ -27,7 +27,8 @@ class Client(Ice.Application): test(self.appName() == properties.getProperty("Ice.ProgramName")) -print "testing load properties from UTF-8 path... ", +sys.stdout.write("testing load properties from UTF-8 path... ") +sys.stdout.flush() id = Ice.InitializationData() id.properties = Ice.createProperties() id.properties.load("./config/ä¸å›½_client.config") @@ -35,10 +36,11 @@ test(id.properties.getProperty("Ice.Trace.Network") == "1") test(id.properties.getProperty("Ice.Trace.Protocol") == "1") test(id.properties.getProperty("Config.Path") == "./config/ä¸å›½_client.config") test(id.properties.getProperty("Ice.ProgramName") == "PropertiesClient") -print "ok" -print "testing load properties from UTF-8 path using Ice::Application... ", +print("ok") +sys.stdout.write("testing load properties from UTF-8 path using Ice::Application... ") +sys.stdout.flush() c = Client() c.main(sys.argv, "./config/ä¸å›½_client.config") -print "ok" +print("ok") -sys.exit(0)
\ No newline at end of file +sys.exit(0) diff --git a/py/test/Ice/properties/run.py b/py/test/Ice/properties/run.py index cd59de5b863..bd4e789bd08 100755 --- a/py/test/Ice/properties/run.py +++ b/py/test/Ice/properties/run.py @@ -17,21 +17,30 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # Write config # -configPath = u"./config/ä¸å›½_client.config" - -TestUtil.createConfig(configPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=./config/ä¸å›½_client.config"]) +if sys.version_info[0] == 2: + configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config".decode("utf-8") + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=./config/ä¸å›½_client.config"]) +else: + configPath = "./config/\u4e2d\u56fd_client.config" + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") TestUtil.simpleTest() diff --git a/py/test/Ice/proxy/AllTests.py b/py/test/Ice/proxy/AllTests.py index 84817d1cbd9..4880e4d6b98 100644 --- a/py/test/Ice/proxy/AllTests.py +++ b/py/test/Ice/proxy/AllTests.py @@ -7,14 +7,15 @@ # # ********************************************************************** -import Ice, Test, threading +import Ice, Test, sys, threading def test(b): if not b: raise RuntimeError('test assertion failed') def allTests(communicator, collocated): - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() # # Test nil proxies. @@ -192,9 +193,10 @@ def allTests(communicator, collocated): test(False) except Ice.EndpointParseException: pass - print "ok" + print("ok") - print "testing propertyToProxy... ", + sys.stdout.write("testing propertyToProxy... ") + sys.stdout.flush() prop = communicator.getProperties() propertyPrefix = "Foo.Proxy" prop.setProperty(propertyPrefix, "test:default -p 12010") @@ -283,9 +285,10 @@ def allTests(communicator, collocated): #test(not b1.ice_isCollocationOptimized()) #prop.setProperty(property, "") - print "ok" + print("ok") - print "testing proxyToProperty... ", + sys.stdout.write("testing proxyToProperty... ") + sys.stdout.flush() b1 = communicator.stringToProxy("test") #b1 = b1.ice_collocationOptimized(true) @@ -335,14 +338,17 @@ def allTests(communicator, collocated): test(proxyProps["Test.Locator.Router.EndpointSelection"] == "Random") test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"] == "200") - print "ok" + print("ok") - print "testing ice_getCommunicator...", + sys.stdout.write("testing ice_getCommunicator... ") + sys.stdout.flush() test(base.ice_getCommunicator() == communicator) - print "ok" - print "testing proxy methods... ", + print("ok") + + sys.stdout.write("testing proxy methods... ") + sys.stdout.flush() test(communicator.identityToString(base.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()) \ == "other") test(base.ice_facet("facet").ice_getFacet() == "facet") @@ -358,9 +364,10 @@ def allTests(communicator, collocated): #test(!base.ice_collocationOptimized(false)->ice_isCollocationOptimized()) test(base.ice_preferSecure(True).ice_isPreferSecure()) test(not base.ice_preferSecure(False).ice_isPreferSecure()) - print "ok" + print("ok") - print "testing proxy comparison... ", + sys.stdout.write("testing proxy comparison... ") + sys.stdout.flush() test(communicator.stringToProxy("foo") == communicator.stringToProxy("foo")) test(communicator.stringToProxy("foo") != communicator.stringToProxy("foo2")) @@ -495,9 +502,10 @@ def allTests(communicator, collocated): # TODO: Ideally we should also test comparison of fixed proxies. # - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() cl = Test.MyClassPrx.checkedCast(base) test(cl) @@ -520,9 +528,10 @@ def allTests(communicator, collocated): test(cl2 == obj) test(cl2 == derived) - print "ok" + print("ok") - print "testing checked cast with context...", + sys.stdout.write("testing checked cast with context... ") + sys.stdout.flush() tccp = Test.MyClassPrx.checkedCast(base) c = tccp.getContext() test(c == None or len(c) == 0) @@ -533,9 +542,10 @@ def allTests(communicator, collocated): tccp = Test.MyClassPrx.checkedCast(base, c) c2 = tccp.getContext() test(c == c2) - print "ok" + print("ok") - print "testing opaque endpoints... ", + sys.stdout.write("testing opaque endpoints... ") + sys.stdout.flush() try: # Invalid -x option @@ -667,6 +677,6 @@ def allTests(communicator, collocated): else: test(pstr == "test -t:ssl -h 127.0.0.1 -p 10001:opaque -t 99 -v abch") - print "ok" + print("ok") return cl diff --git a/py/test/Ice/proxy/Client.py b/py/test/Ice/proxy/Client.py index 8dfe00d4e4a..422e2ed912d 100755 --- a/py/test/Ice/proxy/Client.py +++ b/py/test/Ice/proxy/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/proxy/Collocated.py b/py/test/Ice/proxy/Collocated.py index 729f2358d5f..48edb3fb70a 100755 --- a/py/test/Ice/proxy/Collocated.py +++ b/py/test/Ice/proxy/Collocated.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/proxy/Server.py b/py/test/Ice/proxy/Server.py index a36a70e19b7..2629cae1e33 100755 --- a/py/test/Ice/proxy/Server.py +++ b/py/test/Ice/proxy/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/proxy/ServerAMD.py b/py/test/Ice/proxy/ServerAMD.py index 6723275d074..a7641fe6fbf 100755 --- a/py/test/Ice/proxy/ServerAMD.py +++ b/py/test/Ice/proxy/ServerAMD.py @@ -13,7 +13,7 @@ import os, sys, traceback, time import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' TestAMD.ice") diff --git a/py/test/Ice/proxy/run.py b/py/test/Ice/proxy/run.py index 8101d1c0729..29e1062ae3f 100755 --- a/py/test/Ice/proxy/run.py +++ b/py/test/Ice/proxy/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0") - diff --git a/py/test/Ice/retry/AllTests.py b/py/test/Ice/retry/AllTests.py index d97ac2197b5..dfd1098b344 100644 --- a/py/test/Ice/retry/AllTests.py +++ b/py/test/Ice/retry/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, threading +import Ice, Test, sys, threading def test(b): if not b: @@ -49,54 +49,62 @@ class CallbackFail(CallbackBase): self.called() def allTests(communicator): - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") + sys.stdout.flush() ref = "retry:default -p 12010" base1 = communicator.stringToProxy(ref) test(base1) base2 = communicator.stringToProxy(ref) test(base2) - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") + sys.stdout.flush() retry1 = Test.RetryPrx.checkedCast(base1) test(retry1) test(retry1 == base1) retry2 = Test.RetryPrx.checkedCast(base2) test(retry2) test(retry2 == base2) - print "ok" + print("ok") - print "calling regular operation with first proxy...", + sys.stdout.write("calling regular operation with first proxy... ") + sys.stdout.flush() retry1.op(False) - print "ok" + print("ok") - print "calling operation to kill connection with second proxy...", + sys.stdout.write("calling operation to kill connection with second proxy... ") + sys.stdout.flush() try: retry2.op(True) test(False) except Ice.ConnectionLostException: - print "ok" + print("ok") - print "calling regular operation with first proxy again...", + sys.stdout.write("calling regular operation with first proxy again... ") + sys.stdout.flush() retry1.op(False) - print "ok" + print("ok") cb1 = CallbackSuccess() cb2 = CallbackFail() - print "calling regular AMI operation with first proxy...", + sys.stdout.write("calling regular AMI operation with first proxy... ") + sys.stdout.flush() retry1.begin_op(False, cb1.response, cb1.exception) cb1.check() - print "ok" + print("ok") - print "calling AMI operation to kill connection with second proxy...", + sys.stdout.write("calling AMI operation to kill connection with second proxy... ") + sys.stdout.flush() retry2.begin_op(True, cb2.response, cb2.exception) cb2.check() - print "ok" + print("ok") - print "calling regular AMI operation with first proxy again...", + sys.stdout.write("calling regular AMI operation with first proxy again... ") + sys.stdout.flush() retry1.begin_op(False, cb1.response, cb1.exception) cb1.check() - print "ok" + print("ok") return retry1 diff --git a/py/test/Ice/retry/Client.py b/py/test/Ice/retry/Client.py index 1408a08ae86..a51c1fc414a 100755 --- a/py/test/Ice/retry/Client.py +++ b/py/test/Ice/retry/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/retry/Server.py b/py/test/Ice/retry/Server.py index a0d3abbb809..16acd4af64c 100755 --- a/py/test/Ice/retry/Server.py +++ b/py/test/Ice/retry/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/retry/run.py b/py/test/Ice/retry/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/retry/run.py +++ b/py/test/Ice/retry/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Ice/servantLocator/AllTests.py b/py/test/Ice/servantLocator/AllTests.py index b21325b6eea..c4553cbca94 100644 --- a/py/test/Ice/servantLocator/AllTests.py +++ b/py/test/Ice/servantLocator/AllTests.py @@ -18,7 +18,7 @@ def testExceptions(obj, collocated): try: obj.requestFailedException() test(False) - except Ice.ObjectNotExistException, ex: + except Ice.ObjectNotExistException as ex: if not collocated: test(ex.id == obj.ice_getIdentity()) test(ex.facet == obj.ice_getFacet()) @@ -29,7 +29,7 @@ def testExceptions(obj, collocated): try: obj.unknownUserException() test(False) - except Ice.UnknownUserException, ex: + except Ice.UnknownUserException as ex: test(ex.unknown == "reason") except: test(False) @@ -37,7 +37,7 @@ def testExceptions(obj, collocated): try: obj.unknownLocalException() test(False) - except Ice.UnknownLocalException, ex: + except Ice.UnknownLocalException as ex: test(ex.unknown == "reason") except: test(False) @@ -45,14 +45,14 @@ def testExceptions(obj, collocated): try: obj.unknownException() test(False) - except Ice.UnknownException, ex: + except Ice.UnknownException as ex: test(ex.unknown == "reason") pass try: obj.userException() test(False) - except Ice.UnknownUserException, ex: + except Ice.UnknownUserException as ex: test(ex.unknown.find("Test::TestIntfUserException") >= 0) except: test(False) @@ -60,7 +60,7 @@ def testExceptions(obj, collocated): try: obj.localException() test(False) - except Ice.UnknownLocalException, ex: + except Ice.UnknownLocalException as ex: test(not collocated) test(ex.unknown.find("Ice.SocketException") >= 0) except SocketException: @@ -71,7 +71,7 @@ def testExceptions(obj, collocated): try: obj.pythonException() test(False) - except Ice.UnknownException, ex: + except Ice.UnknownException as ex: test(ex.unknown.find("RuntimeError: message") >= 0) except: test(False) @@ -79,7 +79,7 @@ def testExceptions(obj, collocated): try: obj.unknownExceptionWithServantException() test(False) - except Ice.UnknownException, ex: + except Ice.UnknownException as ex: test(ex.unknown == "reason") except: test(False) @@ -121,26 +121,26 @@ def testExceptions(obj, collocated): test(False) def allTests(communicator, collocated): - print "testing stringToProxy...", + sys.stdout.write("testing stringToProxy... ") sys.stdout.flush() base = communicator.stringToProxy("asm:default -p 12010") test(base) - print "ok" + print("ok") - print "testing checked cast...", + sys.stdout.write("testing checked cast... ") sys.stdout.flush() obj = Test.TestIntfPrx.checkedCast(base) test(obj) test(obj == base) - print "ok" + print("ok") - print "testing ice_ids...", + sys.stdout.write("testing ice_ids... ") sys.stdout.flush() try: obj = communicator.stringToProxy("category/locate:default -p 12010") obj.ice_ids() test(False) - except Ice.UnknownUserException, ex: + except Ice.UnknownUserException as ex: test(ex.unknown == "Test::TestIntfUserException") except: test(False) @@ -149,13 +149,13 @@ def allTests(communicator, collocated): obj = communicator.stringToProxy("category/finished:default -p 12010") obj.ice_ids() test(False) - except Ice.UnknownUserException, ex: + except Ice.UnknownUserException as ex: test(ex.unknown == "Test::TestIntfUserException") except: test(False) - print "ok" + print("ok") - print "testing servant locator...", + sys.stdout.write("testing servant locator... ") sys.stdout.flush() base = communicator.stringToProxy("category/locate:default -p 12010") obj = Test.TestIntfPrx.checkedCast(base) @@ -163,9 +163,9 @@ def allTests(communicator, collocated): Test.TestIntfPrx.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010")) except Ice.ObjectNotExistException: pass - print "ok" + print("ok") - print "testing default servant locator...", + sys.stdout.write("testing default servant locator... ") sys.stdout.flush() base = communicator.stringToProxy("anothercat/locate:default -p 12010") obj = Test.TestIntfPrx.checkedCast(base) @@ -179,23 +179,23 @@ def allTests(communicator, collocated): Test.TestIntfPrx.checkedCast(communicator.stringToProxy("unknown:default -p 12010")) except Ice.ObjectNotExistException: pass - print "ok" + print("ok") - print "testing locate exceptions...", + sys.stdout.write("testing locate exceptions... ") sys.stdout.flush() base = communicator.stringToProxy("category/locate:default -p 12010") obj = Test.TestIntfPrx.checkedCast(base) testExceptions(obj, collocated) - print "ok" + print("ok") - print "testing finished exceptions...", + sys.stdout.write("testing finished exceptions... ") sys.stdout.flush() base = communicator.stringToProxy("category/finished:default -p 12010") obj = Test.TestIntfPrx.checkedCast(base) testExceptions(obj, collocated) - print "ok" + print("ok") - print "testing servant locator removal...", + sys.stdout.write("testing servant locator removal... ") sys.stdout.flush() base = communicator.stringToProxy("test/activation:default -p 12010") activation = Test.TestActivationPrx.checkedCast(base) @@ -205,15 +205,15 @@ def allTests(communicator, collocated): test(False) except Ice.ObjectNotExistException: pass - print "ok" + print("ok") - print "testing servant locator addition...", + sys.stdout.write("testing servant locator addition... ") sys.stdout.flush() activation.activateServantLocator(True) try: obj.ice_ping() except: test(False) - print "ok" + print("ok") return obj diff --git a/py/test/Ice/servantLocator/run.py b/py/test/Ice/servantLocator/run.py index 8101d1c0729..29e1062ae3f 100755 --- a/py/test/Ice/servantLocator/run.py +++ b/py/test/Ice/servantLocator/run.py @@ -16,14 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") -print "tests with collocated server." +print("tests with collocated server.") TestUtil.collocatedTest(" --Ice.ThreadPool.Client.SizeMax=2 --Ice.ThreadPool.Client.SizeWarn=0") - diff --git a/py/test/Ice/slicing/exceptions/AllTests.py b/py/test/Ice/slicing/exceptions/AllTests.py index 9e44f294a3a..5bedb5d4f71 100644 --- a/py/test/Ice/slicing/exceptions/AllTests.py +++ b/py/test/Ice/slicing/exceptions/AllTests.py @@ -44,7 +44,7 @@ class Callback(CallbackBase): def exception_baseAsBase(self, exc): try: raise exc - except Test.Base, b: + except Test.Base as b: test(b.b == "Base.b") test(b.ice_name() =="Test::Base") except: @@ -54,7 +54,7 @@ class Callback(CallbackBase): def exception_unknownDerivedAsBase(self, exc): try: raise exc - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownDerived.b") test(b.ice_name() =="Test::Base") except: @@ -64,7 +64,7 @@ class Callback(CallbackBase): def exception_knownDerivedAsBase(self, exc): try: raise exc - except Test.KnownDerived, k: + except Test.KnownDerived as k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") test(k.ice_name() =="Test::KnownDerived") @@ -75,7 +75,7 @@ class Callback(CallbackBase): def exception_knownDerivedAsKnownDerived(self, exc): try: raise exc - except Test.KnownDerived, k: + except Test.KnownDerived as k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") test(k.ice_name() =="Test::KnownDerived") @@ -86,7 +86,7 @@ class Callback(CallbackBase): def exception_unknownIntermediateAsBase(self, exc): try: raise exc - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownIntermediate.b") test(b.ice_name() =="Test::Base") except: @@ -96,7 +96,7 @@ class Callback(CallbackBase): def exception_knownIntermediateAsBase(self, exc): try: raise exc - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") test(ki.ice_name() =="Test::KnownIntermediate") @@ -107,7 +107,7 @@ class Callback(CallbackBase): def exception_knownMostDerivedAsBase(self, exc): try: raise exc - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") @@ -119,7 +119,7 @@ class Callback(CallbackBase): def exception_knownIntermediateAsKnownIntermediate(self, exc): try: raise exc - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") test(ki.ice_name() =="Test::KnownIntermediate") @@ -130,7 +130,7 @@ class Callback(CallbackBase): def exception_knownMostDerivedAsKnownMostDerived(self, exc): try: raise exc - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") @@ -142,7 +142,7 @@ class Callback(CallbackBase): def exception_knownMostDerivedAsKnownIntermediate(self, exc): try: raise exc - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") @@ -154,7 +154,7 @@ class Callback(CallbackBase): def exception_unknownMostDerived1AsBase(self, exc): try: raise exc - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") test(ki.ice_name() =="Test::KnownIntermediate") @@ -165,7 +165,7 @@ class Callback(CallbackBase): def exception_unknownMostDerived1AsKnownIntermediate(self, exc): try: raise exc - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") test(ki.ice_name() =="Test::KnownIntermediate") @@ -176,7 +176,7 @@ class Callback(CallbackBase): def exception_unknownMostDerived2AsBase(self, exc): try: raise exc - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownMostDerived2.b") test(b.ice_name() =="Test::Base") except: @@ -187,237 +187,263 @@ def allTests(communicator): obj = communicator.stringToProxy("Test:default -p 12010") t = Test.TestIntfPrx.checkedCast(obj) - print "base... ", + sys.stdout.write("base... ") + sys.stdout.flush() try: t.baseAsBase() test(false) - except Test.Base, b: + except Test.Base as b: test(b.b == "Base.b") test(b.ice_name() == "Test::Base") except: test(False) - print "ok" + print("ok") - print "base (AMI)... ", + sys.stdout.write("base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_baseAsBase(cb.response, cb.exception_baseAsBase) cb.check() - print "ok" + print("ok") - print "slicing of unknown derived... ", + sys.stdout.write("slicing of unknown derived... ") + sys.stdout.flush() try: t.unknownDerivedAsBase() test(false) - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownDerived.b") test(b.ice_name() == "Test::Base") except: test(False) - print "ok" + print("ok") - print "slicing of unknown derived (AMI)... ", + sys.stdout.write("slicing of unknown derived (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_unknownDerivedAsBase(cb.response, cb.exception_unknownDerivedAsBase) cb.check() - print "ok" + print("ok") - print "non-slicing of known derived as base... ", + sys.stdout.write("non-slicing of known derived as base... ") + sys.stdout.flush() try: t.knownDerivedAsBase() test(false) - except Test.KnownDerived, k: + except Test.KnownDerived as k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") test(k.ice_name() == "Test::KnownDerived") except: test(False) - print "ok" + print("ok") - print "non-slicing of known derived as base (AMI)... ", + sys.stdout.write("non-slicing of known derived as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownDerivedAsBase(cb.response, cb.exception_knownDerivedAsBase) cb.check() - print "ok" + print("ok") - print "non-slicing of known derived as derived... ", + sys.stdout.write("non-slicing of known derived as derived... ") + sys.stdout.flush() try: t.knownDerivedAsKnownDerived() test(false) - except Test.KnownDerived, k: + except Test.KnownDerived as k: test(k.b == "KnownDerived.b") test(k.kd == "KnownDerived.kd") test(k.ice_name() == "Test::KnownDerived") except: test(False) - print "ok" + print("ok") - print "non-slicing of known derived as derived (AMI)... ", + sys.stdout.write("non-slicing of known derived as derived (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownDerivedAsKnownDerived(cb.response, cb.exception_knownDerivedAsKnownDerived) cb.check() - print "ok" + print("ok") - print "slicing of unknown intermediate as base... ", + sys.stdout.write("slicing of unknown intermediate as base... ") + sys.stdout.flush() try: t.unknownIntermediateAsBase() test(false) - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownIntermediate.b") test(b.ice_name() == "Test::Base") except: test(False) - print "ok" + print("ok") - print "slicing of unknown intermediate as base (AMI)... ", + sys.stdout.write("slicing of unknown intermediate as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_unknownIntermediateAsBase(cb.response, cb.exception_unknownIntermediateAsBase) cb.check() - print "ok" + print("ok") - print "slicing of known intermediate as base... ", + sys.stdout.write("slicing of known intermediate as base... ") + sys.stdout.flush() try: t.knownIntermediateAsBase() test(false) - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") test(ki.ice_name() == "Test::KnownIntermediate") except: test(False) - print "ok" + print("ok") - print "slicing of known intermediate as base (AMI)... ", + sys.stdout.write("slicing of known intermediate as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownIntermediateAsBase(cb.response, cb.exception_knownIntermediateAsBase) cb.check() - print "ok" + print("ok") - print "slicing of known most derived as base... ", + sys.stdout.write("slicing of known most derived as base... ") + sys.stdout.flush() try: t.knownMostDerivedAsBase() test(false) - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") test(kmd.ice_name() == "Test::KnownMostDerived") except: test(False) - print "ok" + print("ok") - print "slicing of known most derived as base (AMI)... ", + sys.stdout.write("slicing of known most derived as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownMostDerivedAsBase(cb.response, cb.exception_knownMostDerivedAsBase) cb.check() - print "ok" + print("ok") - print "non-slicing of known intermediate as intermediate... ", + sys.stdout.write("non-slicing of known intermediate as intermediate... ") + sys.stdout.flush() try: t.knownIntermediateAsKnownIntermediate() test(false) - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "KnownIntermediate.b") test(ki.ki == "KnownIntermediate.ki") test(ki.ice_name() == "Test::KnownIntermediate") except: test(False) - print "ok" + print("ok") - print "non-slicing of known intermediate as intermediate (AMI)... ", + sys.stdout.write("non-slicing of known intermediate as intermediate (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownIntermediateAsKnownIntermediate(cb.response, cb.exception_knownIntermediateAsKnownIntermediate) cb.check() - print "ok" + print("ok") - print "non-slicing of known most derived exception as intermediate... ", + sys.stdout.write("non-slicing of known most derived exception as intermediate... ") + sys.stdout.flush() try: t.knownMostDerivedAsKnownIntermediate() test(false) - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") test(kmd.ice_name() == "Test::KnownMostDerived") except: test(False) - print "ok" + print("ok") - print "non-slicing of known most derived as intermediate (AMI)... ", + sys.stdout.write("non-slicing of known most derived as intermediate (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownMostDerivedAsKnownIntermediate(cb.response, cb.exception_knownMostDerivedAsKnownIntermediate) cb.check() - print "ok" + print("ok") - print "non-slicing of known most derived as most derived... ", + sys.stdout.write("non-slicing of known most derived as most derived... ") + sys.stdout.flush() try: t.knownMostDerivedAsKnownMostDerived() test(false) - except Test.KnownMostDerived, kmd: + except Test.KnownMostDerived as kmd: test(kmd.b == "KnownMostDerived.b") test(kmd.ki == "KnownMostDerived.ki") test(kmd.kmd == "KnownMostDerived.kmd") test(kmd.ice_name() == "Test::KnownMostDerived") except: test(False) - print "ok" + print("ok") - print "non-slicing of known most derived as most derived (AMI)... ", + sys.stdout.write("non-slicing of known most derived as most derived (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_knownMostDerivedAsKnownMostDerived(cb.response, cb.exception_knownMostDerivedAsKnownMostDerived) cb.check() - print "ok" + print("ok") - print "slicing of unknown most derived, known intermediate as base... ", + sys.stdout.write("slicing of unknown most derived, known intermediate as base... ") + sys.stdout.flush() try: t.unknownMostDerived1AsBase() test(false) - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") test(ki.ice_name() == "Test::KnownIntermediate") except: test(False) - print "ok" + print("ok") - print "slicing of unknown most derived, known intermediate as base (AMI)... ", + sys.stdout.write("slicing of unknown most derived, known intermediate as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_unknownMostDerived1AsBase(cb.response, cb.exception_unknownMostDerived1AsBase) cb.check() - print "ok" + print("ok") - print "slicing of unknown most derived, known intermediate as intermediate... ", + sys.stdout.write("slicing of unknown most derived, known intermediate as intermediate... ") + sys.stdout.flush() try: t.unknownMostDerived1AsKnownIntermediate() test(false) - except Test.KnownIntermediate, ki: + except Test.KnownIntermediate as ki: test(ki.b == "UnknownMostDerived1.b") test(ki.ki == "UnknownMostDerived1.ki") test(ki.ice_name() == "Test::KnownIntermediate") except: test(False) - print "ok" + print("ok") - print "slicing of unknown most derived, known intermediate as intermediate (AMI)... ", + sys.stdout.write("slicing of unknown most derived, known intermediate as intermediate (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_unknownMostDerived1AsKnownIntermediate(cb.response, cb.exception_unknownMostDerived1AsKnownIntermediate) cb.check() - print "ok" + print("ok") - print "slicing of unknown most derived, unknown intermediate as base... ", + sys.stdout.write("slicing of unknown most derived, unknown intermediate as base... ") + sys.stdout.flush() try: t.unknownMostDerived2AsBase() test(false) - except Test.Base, b: + except Test.Base as b: test(b.b == "UnknownMostDerived2.b") test(b.ice_name() == "Test::Base") except: test(False) - print "ok" + print("ok") - print "slicing of unknown most derived, unknown intermediate as base (AMI)... ", + sys.stdout.write("slicing of unknown most derived, unknown intermediate as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_unknownMostDerived2AsBase(cb.response, cb.exception_unknownMostDerived2AsBase) cb.check() - print "ok" + print("ok") return t diff --git a/py/test/Ice/slicing/exceptions/run.py b/py/test/Ice/slicing/exceptions/run.py index 141e2be507d..6af6dc0cb43 100755 --- a/py/test/Ice/slicing/exceptions/run.py +++ b/py/test/Ice/slicing/exceptions/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") - diff --git a/py/test/Ice/slicing/objects/AllTests.py b/py/test/Ice/slicing/objects/AllTests.py index e510a4e52d1..db796665cf0 100644 --- a/py/test/Ice/slicing/objects/AllTests.py +++ b/py/test/Ice/slicing/objects/AllTests.py @@ -274,7 +274,8 @@ def allTests(communicator): obj = communicator.stringToProxy("Test:default -p 12010") t = Test.TestIntfPrx.checkedCast(obj) - print "base as Object... ", + sys.stdout.write("base as Object... ") + sys.stdout.flush() o = None try: o = t.SBaseAsObject() @@ -286,29 +287,33 @@ def allTests(communicator): test(isinstance(sb, Test.SBase)) test(sb) test(sb.sb == "SBase.sb") - print "ok" + print("ok") - print "base as Object (AMI)... ", + sys.stdout.write("base as Object (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_SBaseAsObject(cb.response_SBaseAsObject, cb.exception) cb.check() - print "ok" + print("ok") - print "base as base... ", + sys.stdout.write("base as base... ") + sys.stdout.flush() try: sb = t.SBaseAsSBase() test(sb.sb == "SBase.sb") except Ice.Exception: test(False) - print "ok" + print("ok") - print "base as base (AMI)... ", + sys.stdout.write("base as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_SBaseAsSBase(cb.response_SBaseAsSBase, cb.exception) cb.check() - print "ok" + print("ok") - print "base with known derived as base... ", + sys.stdout.write("base with known derived as base... ") + sys.stdout.flush() try: sb = t.SBSKnownDerivedAsSBase() test(sb.sb == "SBSKnownDerived.sb") @@ -318,43 +323,49 @@ def allTests(communicator): test(isinstance(sbskd, Test.SBSKnownDerived)) test(sbskd) test(sbskd.sbskd == "SBSKnownDerived.sbskd") - print "ok" + print("ok") - print "base with known derived as base (AMI)... ", + sys.stdout.write("base with known derived as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_SBSKnownDerivedAsSBase(cb.response_SBSKnownDerivedAsSBase, cb.exception) cb.check() - print "ok" + print("ok") - print "base with known derived as known derived... ", + sys.stdout.write("base with known derived as known derived... ") + sys.stdout.flush() try: sbskd = t.SBSKnownDerivedAsSBSKnownDerived() test(sbskd.sbskd == "SBSKnownDerived.sbskd") except Ice.Exception: test(False) - print "ok" + print("ok") - print "base with known derived as known derived (AMI)... ", + sys.stdout.write("base with known derived as known derived (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_SBSKnownDerivedAsSBSKnownDerived(cb.response_SBSKnownDerivedAsSBSKnownDerived, cb.exception) cb.check() - print "ok" + print("ok") - print "base with unknown derived as base... ", + sys.stdout.write("base with unknown derived as base... ") + sys.stdout.flush() try: sb = t.SBSUnknownDerivedAsSBase() test(sb.sb == "SBSUnknownDerived.sb") except Ice.Exception: test(False) - print "ok" + print("ok") - print "base with unknown derived as base (AMI)... ", + sys.stdout.write("base with unknown derived as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_SBSUnknownDerivedAsSBase(cb.response_SBSUnknownDerivedAsSBase, cb.exception) cb.check() - print "ok" + print("ok") - print "unknown with Object as Object... ", + sys.stdout.write("unknown with Object as Object... ") + sys.stdout.flush() try: o = t.SUnknownAsObject() test(False) @@ -362,9 +373,10 @@ def allTests(communicator): pass except Ice.Exception: test(False) - print "ok" + print("ok") - print "unknown with Object as Object (AMI)... ", + sys.stdout.write("unknown with Object as Object (AMI)... ") + sys.stdout.flush() try: cb = Callback() t.begin_SUnknownAsObject(cb.response_SUnknownAsObject, cb.exception_SUnknownAsObject) @@ -373,9 +385,10 @@ def allTests(communicator): pass except Ice.Exception: test(False) - print "ok" + print("ok") - print "one-element cycle... ", + sys.stdout.write("one-element cycle... ") + sys.stdout.flush() try: b = t.oneElementCycle() test(b) @@ -384,15 +397,17 @@ def allTests(communicator): test(b.pb == b) except Ice.Exception: test(False) - print "ok" + print("ok") - print "one-element cycle (AMI)... ", + sys.stdout.write("one-element cycle (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_oneElementCycle(cb.response_oneElementCycle, cb.exception) cb.check() - print "ok" + print("ok") - print "two-element cycle... ", + sys.stdout.write("two-element cycle... ") + sys.stdout.flush() try: b1 = t.twoElementCycle() test(b1) @@ -406,15 +421,17 @@ def allTests(communicator): test(b2.pb == b1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "two-element cycle (AMI)... ", + sys.stdout.write("two-element cycle (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_twoElementCycle(cb.response_twoElementCycle, cb.exception) cb.check() - print "ok" + print("ok") - print "known derived pointer slicing as base... ", + sys.stdout.write("known derived pointer slicing as base... ") + sys.stdout.flush() try: b1 = t.D1AsB() test(b1) @@ -436,15 +453,17 @@ def allTests(communicator): test(b2.ice_id() == "::Test::B") except Ice.Exception: test(False) - print "ok" + print("ok") - print "known derived pointer slicing as base (AMI)... ", + sys.stdout.write("known derived pointer slicing as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_D1AsB(cb.response_D1AsB, cb.exception) cb.check() - print "ok" + print("ok") - print "known derived pointer slicing as derived... ", + sys.stdout.write("known derived pointer slicing as derived... ") + sys.stdout.flush() try: d1 = t.D1AsD1() test(d1) @@ -460,15 +479,17 @@ def allTests(communicator): test(b2.pb == d1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "known derived pointer slicing as derived (AMI)... ", + sys.stdout.write("known derived pointer slicing as derived (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_D1AsD1(cb.response_D1AsD1, cb.exception) cb.check() - print "ok" + print("ok") - print "unknown derived pointer slicing as base... ", + sys.stdout.write("unknown derived pointer slicing as base... ") + sys.stdout.flush() try: b2 = t.D2AsB() test(b2) @@ -488,15 +509,17 @@ def allTests(communicator): test(d1.pd1 == b2) except Ice.Exception: test(False) - print "ok" + print("ok") - print "unknown derived pointer slicing as base (AMI)... ", + sys.stdout.write("unknown derived pointer slicing as base (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_D2AsB(cb.response_D2AsB, cb.exception) cb.check() - print "ok" + print("ok") - print "param ptr slicing with known first... ", + sys.stdout.write("param ptr slicing with known first... ") + sys.stdout.flush() try: b1, b2 = t.paramTest1() @@ -515,15 +538,17 @@ def allTests(communicator): test(b2.pb == b1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "param ptr slicing with known first (AMI)... ", + sys.stdout.write("param ptr slicing with known first (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_paramTest1(cb.response_paramTest1, cb.exception) cb.check() - print "ok" + print("ok") - print "param ptr slicing with unknown first... ", + sys.stdout.write("param ptr slicing with unknown first... ") + sys.stdout.flush() try: b2, b1 = t.paramTest2() @@ -544,37 +569,42 @@ def allTests(communicator): import traceback traceback.print_exc() test(False) - print "ok" + print("ok") - print "return value identity with known first... ", + sys.stdout.write("return value identity with known first... ") + sys.stdout.flush() try: r, p1, p2 = t.returnTest1() test(r == p1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "return value identity with known first (AMI)... ", + sys.stdout.write("return value identity with known first (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_returnTest1(cb.response_returnTest1, cb.exception) cb.check() - print "ok" + print("ok") - print "return value identity with unknown first... ", + sys.stdout.write("return value identity with unknown first... ") + sys.stdout.flush() try: r, p1, p2 = t.returnTest2() test(r == p1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "return value identity with unknown first (AMI)... ", + sys.stdout.write("return value identity with unknown first (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_returnTest2(cb.response_returnTest2, cb.exception) cb.check() - print "ok" + print("ok") - print "return value identity for input params known first... ", + sys.stdout.write("return value identity for input params known first... ") + sys.stdout.flush() try: d1 = Test.D1() d1.sb = "D1.sb" @@ -611,9 +641,10 @@ def allTests(communicator): test(b2 != d3) except Ice.Exception: test(False) - print "ok" + print("ok") - print "return value identity for input params known first (AMI)... ", + sys.stdout.write("return value identity for input params known first (AMI)... ") + sys.stdout.flush() try: d1 = Test.D1() d1.sb = "D1.sb" @@ -653,9 +684,10 @@ def allTests(communicator): test(b2 != d3) except Ice.Exception: test(False) - print "ok" + print("ok") - print "return value identity for input params unknown first... ", + sys.stdout.write("return value identity for input params unknown first... ") + sys.stdout.flush() try: d1 = Test.D1() d1.sb = "D1.sb" @@ -692,9 +724,10 @@ def allTests(communicator): test(b2 != d3) except Ice.Exception: test(False) - print "ok" + print("ok") - print "return value identity for input params unknown first (AMI)... ", + sys.stdout.write("return value identity for input params unknown first (AMI)... ") + sys.stdout.flush() try: d1 = Test.D1() d1.sb = "D1.sb" @@ -734,9 +767,10 @@ def allTests(communicator): test(b2 != d3) except Ice.Exception: test(False) - print "ok" + print("ok") - print "remainder unmarshaling (3 instances)... ", + sys.stdout.write("remainder unmarshaling (3 instances)... ") + sys.stdout.flush() try: ret, p1, p2 = t.paramTest3() @@ -756,15 +790,17 @@ def allTests(communicator): test(ret.ice_id() == "::Test::D1") except Ice.Exception: test(False) - print "ok" + print("ok") - print "remainder unmarshaling (3 instances) (AMI)... ", + sys.stdout.write("remainder unmarshaling (3 instances) (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_paramTest3(cb.response_paramTest3, cb.exception) cb.check() - print "ok" + print("ok") - print "remainder unmarshaling (4 instances)... ", + sys.stdout.write("remainder unmarshaling (4 instances)... ") + sys.stdout.flush() try: ret, b = t.paramTest4() @@ -779,15 +815,17 @@ def allTests(communicator): test(ret.ice_id() == "::Test::B") except Ice.Exception: test(False) - print "ok" + print("ok") - print "remainder unmarshaling (4 instances) (AMI)... ", + sys.stdout.write("remainder unmarshaling (4 instances) (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_paramTest4(cb.response_paramTest4, cb.exception) cb.check() - print "ok" + print("ok") - print "param ptr slicing, instance marshaled in unknown derived as base... ", + sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base... ") + sys.stdout.flush() try: b1 = Test.B() b1.sb = "B.sb(1)" @@ -811,9 +849,10 @@ def allTests(communicator): test(r.pb == r) except Ice.Exception: test(False) - print "ok" + print("ok") - print "param ptr slicing, instance marshaled in unknown derived as base (AMI)... ", + sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as base (AMI)... ") + sys.stdout.flush() try: b1 = Test.B() b1.sb = "B.sb(1)" @@ -840,9 +879,10 @@ def allTests(communicator): test(r.pb == r) except Ice.Exception: test(False) - print "ok" + print("ok") - print "param ptr slicing, instance marshaled in unknown derived as derived... ", + sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived... ") + sys.stdout.flush() try: d11 = Test.D1() d11.sb = "D1.sb(1)" @@ -869,9 +909,10 @@ def allTests(communicator): test(r.pb == r) except Ice.Exception: test(False) - print "ok" + print("ok") - print "param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ", + sys.stdout.write("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ") + sys.stdout.flush() try: d11 = Test.D1() d11.sb = "D1.sb(1)" @@ -902,9 +943,10 @@ def allTests(communicator): test(r.pb == r) except Ice.Exception: test(False) - print "ok" + print("ok") - print "sequence slicing... ", + sys.stdout.write("sequence slicing... ") + sys.stdout.flush() try: ss = Test.SS() ss1b = Test.B() @@ -977,9 +1019,10 @@ def allTests(communicator): test(ss2d3.ice_id() == "::Test::B") except Ice.Exception: test(False) - print "ok" + print("ok") - print "sequence slicing (AMI)... ", + sys.stdout.write("sequence slicing (AMI)... ") + sys.stdout.flush() try: ss = Test.SS() ss1b = Test.B() @@ -1055,9 +1098,10 @@ def allTests(communicator): test(ss2d3.ice_id() == "::Test::B") except Ice.Exception: test(False) - print "ok" + print("ok") - print "dictionary slicing... ", + sys.stdout.write("dictionary slicing... ") + sys.stdout.flush() try: bin = {} for i in range(0, 10): @@ -1098,9 +1142,10 @@ def allTests(communicator): test(d1.pd1 == d1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "dictionary slicing (AMI)... ", + sys.stdout.write("dictionary slicing (AMI)... ") + sys.stdout.flush() try: bin = {} for i in range(0, 10): @@ -1145,13 +1190,14 @@ def allTests(communicator): test(d1.pd1 == d1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "base exception thrown as base exception... ", + sys.stdout.write("base exception thrown as base exception... ") + sys.stdout.flush() try: t.throwBaseAsBase() test(False) - except Test.BaseException, e: + except Test.BaseException as e: test(e.ice_name() == "Test::BaseException") test(e.sbe == "sbe") test(e.pb) @@ -1159,19 +1205,21 @@ def allTests(communicator): test(e.pb.pb == e.pb) except Ice.Exception: test(False) - print "ok" + print("ok") - print "base exception thrown as base exception (AMI)... ", + sys.stdout.write("base exception thrown as base exception (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_throwBaseAsBase(cb.response, cb.exception_throwBaseAsBase) cb.check() - print "ok" + print("ok") - print "derived exception thrown as base exception... ", + sys.stdout.write("derived exception thrown as base exception... ") + sys.stdout.flush() try: t.throwDerivedAsBase() test(False) - except Test.DerivedException, e: + except Test.DerivedException as e: test(e.ice_name() == "Test::DerivedException") test(e.sbe == "sbe") test(e.pb) @@ -1185,19 +1233,21 @@ def allTests(communicator): test(e.pd1.pd1 == e.pd1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "derived exception thrown as base exception (AMI)... ", + sys.stdout.write("derived exception thrown as base exception (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_throwDerivedAsBase(cb.response, cb.exception_throwDerivedAsBase) cb.check() - print "ok" + print("ok") - print "derived exception thrown as derived exception... ", + sys.stdout.write("derived exception thrown as derived exception... ") + sys.stdout.flush() try: t.throwDerivedAsDerived() test(False) - except Test.DerivedException, e: + except Test.DerivedException as e: test(e.ice_name() == "Test::DerivedException") test(e.sbe == "sbe") test(e.pb) @@ -1211,19 +1261,21 @@ def allTests(communicator): test(e.pd1.pd1 == e.pd1) except Ice.Exception: test(False) - print "ok" + print("ok") - print "derived exception thrown as derived exception (AMI)... ", + sys.stdout.write("derived exception thrown as derived exception (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_throwDerivedAsDerived(cb.response, cb.exception_throwDerivedAsDerived) cb.check() - print "ok" + print("ok") - print "unknown derived exception thrown as base exception... ", + sys.stdout.write("unknown derived exception thrown as base exception... ") + sys.stdout.flush() try: t.throwUnknownDerivedAsBase() test(False) - except Test.BaseException, e: + except Test.BaseException as e: test(e.ice_name() == "Test::BaseException") test(e.sbe == "sbe") test(e.pb) @@ -1231,26 +1283,29 @@ def allTests(communicator): test(e.pb.pb == e.pb) except Ice.Exception: test(False) - print "ok" + print("ok") - print "unknown derived exception thrown as base exception (AMI)... ", + sys.stdout.write("unknown derived exception thrown as base exception (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_throwUnknownDerivedAsBase(cb.response, cb.exception_throwUnknownDerivedAsBase) cb.check() - print "ok" + print("ok") - print "forward-declared class... ", + sys.stdout.write("forward-declared class... ") + sys.stdout.flush() try: f = t.useForward() test(f) except Ice.Exception: test(False) - print "ok" + print("ok") - print "forward-declared class (AMI)... ", + sys.stdout.write("forward-declared class (AMI)... ") + sys.stdout.flush() cb = Callback() t.begin_useForward(cb.response_useForward, cb.exception) cb.check() - print "ok" + print("ok") return t diff --git a/py/test/Ice/slicing/objects/run.py b/py/test/Ice/slicing/objects/run.py index 141e2be507d..6af6dc0cb43 100755 --- a/py/test/Ice/slicing/objects/run.py +++ b/py/test/Ice/slicing/objects/run.py @@ -16,12 +16,11 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="ServerAMD.py") - diff --git a/py/test/Ice/timeout/AllTests.py b/py/test/Ice/timeout/AllTests.py index 3ee89608261..0beb723a97b 100644 --- a/py/test/Ice/timeout/AllTests.py +++ b/py/test/Ice/timeout/AllTests.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import Ice, Test, threading +import Ice, Test, sys, threading def test(b): if not b: @@ -53,7 +53,8 @@ def allTests(communicator, collocated): timeout = Test.TimeoutPrx.checkedCast(obj) test(timeout != None) - print "testing connect timeout... ", + sys.stdout.write("testing connect timeout... ") + sys.stdout.flush() # # Expect ConnectTimeoutException. # @@ -76,9 +77,10 @@ def allTests(communicator, collocated): to.op() except Ice.ConnectTimeoutException: test(False) - print "ok" + print("ok") - print "testing read timeout... ", + sys.stdout.write("testing read timeout... ") + sys.stdout.flush() # # Expect TimeoutException. # @@ -97,18 +99,22 @@ def allTests(communicator, collocated): to.sleep(500) except Ice.TimeoutException: test(False) - print "ok" + print("ok") - print "testing write timeout... ", + sys.stdout.write("testing write timeout... ") + sys.stdout.flush() # # Expect TimeoutException. # to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(500)) to.holdAdapter(2000) - seq = [] - seq[0:100000] = range(0, 100000) # add 100,000 entries. - seq = ['\x00' for x in seq] # set them all to \x00 - seq = ''.join(seq) # make into a byte array + if sys.version_info[0] == 2: + seq = [] + seq[0:100000] = range(0, 100000) # add 100,000 entries. + seq = ['\x00' for x in seq] # set them all to \x00 + seq = ''.join(seq) # make into a byte array + else: + seq = bytes([0 for x in range(0, 100000)]) try: to.sendData(seq) test(False) @@ -124,9 +130,10 @@ def allTests(communicator, collocated): to.sendData(seq) except Ice.TimeoutException: test(False) - print "ok" + print("ok") - print "testing AMI read timeout... ", + sys.stdout.write("testing AMI read timeout... ") + sys.stdout.flush() # # Expect TimeoutException. # @@ -142,9 +149,10 @@ def allTests(communicator, collocated): cb = Callback() to.begin_sleep(500, cb.response, cb.exception) cb.check() - print "ok" + print("ok") - print "testing AMI write timeout... ", + sys.stdout.write("testing AMI write timeout... ") + sys.stdout.flush() # # Expect TimeoutException. # @@ -162,9 +170,10 @@ def allTests(communicator, collocated): cb = Callback() to.begin_sendData(seq, cb.response, cb.exception) cb.check() - print "ok" + print("ok") - print "testing timeout overrides... ", + sys.stdout.write("testing timeout overrides... ") + sys.stdout.flush() # # Test Ice.Override.Timeout. This property overrides all # endpoint timeouts. @@ -225,6 +234,6 @@ def allTests(communicator, collocated): except Ice.TimeoutException: pass # Expected. comm.destroy() - print "ok" + print("ok") return timeout diff --git a/py/test/Ice/timeout/Client.py b/py/test/Ice/timeout/Client.py index 1d4ace1a579..c891a54acec 100755 --- a/py/test/Ice/timeout/Client.py +++ b/py/test/Ice/timeout/Client.py @@ -13,7 +13,7 @@ import os, sys, traceback import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") import AllTests diff --git a/py/test/Ice/timeout/Server.py b/py/test/Ice/timeout/Server.py index 96c5ab449f4..80e9020b31c 100755 --- a/py/test/Ice/timeout/Server.py +++ b/py/test/Ice/timeout/Server.py @@ -13,7 +13,7 @@ import os, sys, traceback, time, threading import Ice slice_dir = Ice.getSliceDir() if not slice_dir: - print sys.argv[0] + ': Slice directory not found.' + print(sys.argv[0] + ': Slice directory not found.') sys.exit(1) Ice.loadSlice("'-I" + slice_dir + "' Test.ice") diff --git a/py/test/Ice/timeout/run.py b/py/test/Ice/timeout/run.py index 32ea526c3b4..2265a40ca12 100755 --- a/py/test/Ice/timeout/run.py +++ b/py/test/Ice/timeout/run.py @@ -16,9 +16,8 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() - diff --git a/py/test/Slice/keyword/Client.py b/py/test/Slice/keyword/Client.py index 2ce1dc42280..96c20d5b3f9 100755 --- a/py/test/Slice/keyword/Client.py +++ b/py/test/Slice/keyword/Client.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): break else: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") import Ice @@ -47,7 +47,8 @@ class printI(_and._print): pass def testtypes(): - print("Testing generated type names... "), + sys.stdout.write("Testing generated type names... ") + sys.stdout.flush() a = _and._assert._break b = _and._continue b._def = 0 @@ -74,7 +75,7 @@ def testtypes(): i = printI() j = _and._lambda; en = _and.EnumNone._None - print "ok" + print("ok") def run(args, communicator): communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp") @@ -82,11 +83,12 @@ def run(args, communicator): adapter.add(execI(), communicator.stringToIdentity("test")) adapter.activate() - print("Testing operation name... "), + sys.stdout.write("Testing operation name... ") + sys.stdout.flush() p = _and.execPrx.uncheckedCast( adapter.createProxy(communicator.stringToIdentity("test"))); p._finally(); - print "ok" + print("ok") testtypes() diff --git a/py/test/Slice/keyword/run.py b/py/test/Slice/keyword/run.py index 9e43cca975f..9408d16c691 100755 --- a/py/test/Slice/keyword/run.py +++ b/py/test/Slice/keyword/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/py/test/Slice/structure/Client.py b/py/test/Slice/structure/Client.py index 9d11ff5f1ea..5db17fbb946 100755 --- a/py/test/Slice/structure/Client.py +++ b/py/test/Slice/structure/Client.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "python", "Ice.py")): break else: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") import Ice @@ -27,7 +27,8 @@ def test(b): raise RuntimeError('test assertion failed') def allTests(communicator): - print("testing equals() for Slice structures..."), + sys.stdout.write("testing equals() for Slice structures... ") + sys.stdout.flush() # # Define some default values. @@ -210,7 +211,7 @@ def allTests(communicator): v2.prx = None test(v1 != v2) - print "ok" + print("ok") def run(args, communicator): allTests(communicator) diff --git a/py/test/Slice/structure/run.py b/py/test/Slice/structure/run.py index 9e43cca975f..9408d16c691 100755 --- a/py/test/Slice/structure/run.py +++ b/py/test/Slice/structure/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.py", "--Ice.Default.Host=127.0.0.1", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/rb/allDemos.py b/rb/allDemos.py index 93642832d0f..6fe5f857aa9 100755 --- a/rb/allDemos.py +++ b/rb/allDemos.py @@ -15,7 +15,7 @@ for toplevel in [".", "..", "../..", "../../..", "../../../.."]: if os.path.exists(os.path.join(toplevel, "demoscript")): break else: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(os.path.join(toplevel)) from demoscript import Util diff --git a/rb/allTests.py b/rb/allTests.py index a09dac0ea50..8a52f9393fd 100755 --- a/rb/allTests.py +++ b/rb/allTests.py @@ -10,15 +10,16 @@ import os, sys, re, getopt -for toplevel in [".", "..", "../..", "../../..", "../../../..", "../../../../.."]: - toplevel = os.path.abspath(toplevel) - if os.path.exists(os.path.join(toplevel, "scripts", "TestUtil.py")): - break -else: - raise "can't find toplevel directory!" +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(toplevel)) -from scripts import * +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # List of all basic tests. diff --git a/rb/demo/Ice/hello/expect.py b/rb/demo/Ice/hello/expect.py index df7798bc639..65b44da8ece 100755 --- a/rb/demo/Ice/hello/expect.py +++ b/rb/demo/Ice/hello/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import hello server = Util.spawn('./server --Ice.PrintAdapterReady --Ice.Warn.Connections=0', Util.getMirrorDir("cpp"), mapping="cpp") diff --git a/rb/demo/Ice/latency/expect.py b/rb/demo/Ice/latency/expect.py index 7426da64c6f..18a723997ea 100755 --- a/rb/demo/Ice/latency/expect.py +++ b/rb/demo/Ice/latency/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,22 +16,21 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") server.expect('.* ready') -print "testing ping... ", +sys.stdout.write("testing ping... ") sys.stdout.flush() client = Util.spawn('ruby Client.rb') client.waitTestSuccess(timeout=100) -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) server.waitTestSuccess() -print client.before +print(client.before) diff --git a/rb/demo/Ice/minimal/expect.py b/rb/demo/Ice/minimal/expect.py index 1a25c959de8..61f1cd216f1 100755 --- a/rb/demo/Ice/minimal/expect.py +++ b/rb/demo/Ice/minimal/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,21 +16,20 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('ruby Client.rb') client.waitTestSuccess() server.expect('Hello World!') -print "ok" +print("ok") -import signal server.kill(signal.SIGINT) -#server.waitTestSuccess() +server.waitTestFail() diff --git a/rb/demo/Ice/session/expect.py b/rb/demo/Ice/session/expect.py index 521c654a731..4ee6f7f8d90 100755 --- a/rb/demo/Ice/session/expect.py +++ b/rb/demo/Ice/session/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import session server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") diff --git a/rb/demo/Ice/throughput/expect.py b/rb/demo/Ice/throughput/expect.py index ef56e162bb6..5a99ea7f6dd 100755 --- a/rb/demo/Ice/throughput/expect.py +++ b/rb/demo/Ice/throughput/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import throughput server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") diff --git a/rb/demo/Ice/value/expect.py b/rb/demo/Ice/value/expect.py index fe6beca68d3..29d08359dd3 100755 --- a/rb/demo/Ice/value/expect.py +++ b/rb/demo/Ice/value/expect.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * +from demoscript import Util from demoscript.Ice import value server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") diff --git a/rb/demo/book/printer/expect.py b/rb/demo/book/printer/expect.py index 7a93b21ef92..e40ef3b77dd 100755 --- a/rb/demo/book/printer/expect.py +++ b/rb/demo/book/printer/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('ruby Client.rb') client.waitTestSuccess() @@ -34,4 +33,4 @@ server.expect('Hello World!') server.kill(signal.SIGTERM) server.waitTestSuccess(-signal.SIGTERM) -print "ok" +print("ok") diff --git a/rb/demo/book/simple_filesystem/expect.py b/rb/demo/book/simple_filesystem/expect.py index 87c466959f4..0b94f59f923 100755 --- a/rb/demo/book/simple_filesystem/expect.py +++ b/rb/demo/book/simple_filesystem/expect.py @@ -8,7 +8,7 @@ # # ********************************************************************** -import sys, os +import sys, os, signal path = [ ".", "..", "../..", "../../..", "../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -16,16 +16,15 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "demoscript")) ] if len(path) == 0: - raise "can't find toplevel directory!" + raise RuntimeError("can't find toplevel directory!") sys.path.append(path[0]) -from demoscript import * -import signal +from demoscript import Util server = Util.spawn('./server --Ice.PrintAdapterReady', Util.getMirrorDir("cpp"), mapping="cpp") server.expect('.* ready') -print "testing...", +sys.stdout.write("testing... ") sys.stdout.flush() client = Util.spawn('ruby Client.rb') client.expect('Contents of root directory:\n.*Down to a sunless sea.') @@ -34,4 +33,4 @@ client.waitTestSuccess() server.kill(signal.SIGINT) server.waitTestSuccess() -print "ok" +print("ok") diff --git a/rb/test/Ice/binding/run.py b/rb/test/Ice/binding/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/binding/run.py +++ b/rb/test/Ice/binding/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/checksum/run.py b/rb/test/Ice/checksum/run.py index bdd5c1a3b99..c0471aa4304 100755 --- a/rb/test/Ice/checksum/run.py +++ b/rb/test/Ice/checksum/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest(server='server/server') diff --git a/rb/test/Ice/defaultValue/run.py b/rb/test/Ice/defaultValue/run.py index 15730b2cbc8..5130a009530 100755 --- a/rb/test/Ice/defaultValue/run.py +++ b/rb/test/Ice/defaultValue/run.py @@ -16,12 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.rb", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/rb/test/Ice/exceptions/run.py b/rb/test/Ice/exceptions/run.py index 04460c84c2c..774e649a79f 100755 --- a/rb/test/Ice/exceptions/run.py +++ b/rb/test/Ice/exceptions/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") sys.exit(0) diff --git a/rb/test/Ice/facets/run.py b/rb/test/Ice/facets/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/facets/run.py +++ b/rb/test/Ice/facets/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/info/run.py b/rb/test/Ice/info/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/info/run.py +++ b/rb/test/Ice/info/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/inheritance/run.py b/rb/test/Ice/inheritance/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/inheritance/run.py +++ b/rb/test/Ice/inheritance/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/location/run.py b/rb/test/Ice/location/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/location/run.py +++ b/rb/test/Ice/location/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/objects/run.py b/rb/test/Ice/objects/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/objects/run.py +++ b/rb/test/Ice/objects/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/operations/run.py b/rb/test/Ice/operations/run.py index f8d6e35badc..93e916765b1 100755 --- a/rb/test/Ice/operations/run.py +++ b/rb/test/Ice/operations/run.py @@ -16,12 +16,12 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") diff --git a/rb/test/Ice/properties/run.py b/rb/test/Ice/properties/run.py index cd59de5b863..bd4e789bd08 100755 --- a/rb/test/Ice/properties/run.py +++ b/rb/test/Ice/properties/run.py @@ -17,21 +17,30 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil # # Write config # -configPath = u"./config/ä¸å›½_client.config" - -TestUtil.createConfig(configPath, - ["# Automatically generated by Ice test driver.", - "Ice.Trace.Protocol=1", - "Ice.Trace.Network=1", - "Ice.ProgramName=PropertiesClient", - "Config.Path=./config/ä¸å›½_client.config"]) +if sys.version_info[0] == 2: + configPath = "./config/\xe4\xb8\xad\xe5\x9b\xbd_client.config".decode("utf-8") + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=./config/ä¸å›½_client.config"]) +else: + configPath = "./config/\u4e2d\u56fd_client.config" + TestUtil.createConfig(configPath, + ["# Automatically generated by Ice test driver.", + "Ice.Trace.Protocol=1", + "Ice.Trace.Network=1", + "Ice.ProgramName=PropertiesClient", + "Config.Path=" + configPath], + "utf-8") TestUtil.simpleTest() diff --git a/rb/test/Ice/proxy/run.py b/rb/test/Ice/proxy/run.py index 04460c84c2c..774e649a79f 100755 --- a/rb/test/Ice/proxy/run.py +++ b/rb/test/Ice/proxy/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() -print "tests with AMD server." +print("tests with AMD server.") TestUtil.clientServerTest(server="serveramd") sys.exit(0) diff --git a/rb/test/Ice/retry/run.py b/rb/test/Ice/retry/run.py index 32ea526c3b4..9e6c8a749c0 100755 --- a/rb/test/Ice/retry/run.py +++ b/rb/test/Ice/retry/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/slicing/exceptions/run.py b/rb/test/Ice/slicing/exceptions/run.py index 04d6ba71ed6..20806fc306f 100755 --- a/rb/test/Ice/slicing/exceptions/run.py +++ b/rb/test/Ice/slicing/exceptions/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/slicing/objects/run.py b/rb/test/Ice/slicing/objects/run.py index 04d6ba71ed6..20806fc306f 100755 --- a/rb/test/Ice/slicing/objects/run.py +++ b/rb/test/Ice/slicing/objects/run.py @@ -16,9 +16,9 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil TestUtil.clientServerTest() diff --git a/rb/test/Ice/timeout/run.py b/rb/test/Ice/timeout/run.py index 17cfc7c7b27..ae28b8d66eb 100755 --- a/rb/test/Ice/timeout/run.py +++ b/rb/test/Ice/timeout/run.py @@ -16,10 +16,10 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "tests with regular server." +print("tests with regular server.") TestUtil.clientServerTest() diff --git a/rb/test/Slice/keyword/run.py b/rb/test/Slice/keyword/run.py index 523174300dc..a630b75d355 100755 --- a/rb/test/Slice/keyword/run.py +++ b/rb/test/Slice/keyword/run.py @@ -16,13 +16,13 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.rb", "--Ice.Default.Host=127.0.0.1", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() - diff --git a/rb/test/Slice/structure/run.py b/rb/test/Slice/structure/run.py index 523174300dc..cd490774640 100755 --- a/rb/test/Slice/structure/run.py +++ b/rb/test/Slice/structure/run.py @@ -16,13 +16,14 @@ if len(head) > 0: path = [os.path.join(head, p) for p in path] path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] if len(path) == 0: - raise "can't find toplevel directory!" -sys.path.append(os.path.join(path[0])) -from scripts import * + raise RuntimeError("can't find toplevel directory!") +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil -print "starting client...", +sys.stdout.write("starting client... ") +sys.stdout.flush() clientProc = TestUtil.startClient("Client.rb", "--Ice.Default.Host=127.0.0.1", startReader = False) -print "ok" +print("ok") clientProc.startReader() clientProc.waitTestSuccess() diff --git a/scripts/Expect.py b/scripts/Expect.py index f1d847d16ad..612099ec53c 100755 --- a/scripts/Expect.py +++ b/scripts/Expect.py @@ -9,7 +9,6 @@ import threading import subprocess -import StringIO import string import time import re @@ -39,7 +38,7 @@ class EOF: def __str__(self): return str(self.value) -class TIMEOUT: +class TIMEOUT(Exception): """Raised when a read time exceeds the timeout. """ def __init__(self, value): @@ -47,119 +46,132 @@ class TIMEOUT: def __str__(self): return str(self.value) +def getStringIO(): + if sys.version_info[0] == 2: + import StringIO + return StringIO.StringIO() + else: + import io + return io.StringIO() + def escape(s, escapeNewlines = True): if s == TIMEOUT: return "<TIMEOUT>" - o = StringIO.StringIO() + o = getStringIO() for c in s: - if c == '\\': - o.write('\\\\') - elif c == '\'': - o.write("\\'") - elif c == '\"': - o.write('\\"') - elif c == '\b': - o.write('\\b') - elif c == '\f': - o.write('\\f') - elif c == '\n': + if c == '\\': + o.write('\\\\') + elif c == '\'': + o.write("\\'") + elif c == '\"': + o.write('\\"') + elif c == '\b': + o.write('\\b') + elif c == '\f': + o.write('\\f') + elif c == '\n': if escapeNewlines: o.write('\\n') else: o.write('\n') - elif c == '\r': - o.write('\\r') - elif c == '\t': - o.write('\\t') - else: - if c in string.printable: - o.write(c) - else: - o.write('\\%03o' % ord(c)) + elif c == '\r': + o.write('\\r') + elif c == '\t': + o.write('\\t') + else: + if c in string.printable: + o.write(c) + else: + o.write('\\%03o' % ord(c)) return o.getvalue() class reader(threading.Thread): def __init__(self, desc, p, logfile): - self.desc = desc - self.buf = StringIO.StringIO() - self.cv = threading.Condition() - self.p = p + self.desc = desc + self.buf = getStringIO() + self.cv = threading.Condition() + self.p = p self._trace = False - self._tbuf = StringIO.StringIO() - self._tracesupress = None - self.logfile = logfile + self._tbuf = getStringIO() + self._tracesuppress = None + self.logfile = logfile threading.Thread.__init__(self) def run(self): try: - while True: - c = self.p.stdout.read(1) - if not c: break + while True: + c = self.p.stdout.read(1) + if not c: break if c == '\r': continue - self.cv.acquire() - try: + self.cv.acquire() + try: + # Depending on Python version and platform, the value c could be a + # string or a bytes object. + if type(c) != str: + c = c.decode() self.trace(c) - self.buf.write(c) - self.cv.notify() - finally: - self.cv.release() - except IOError, e: - print e + self.buf.write(c) + self.cv.notify() + finally: + self.cv.release() + except IOError as e: + print(e) def trace(self, c): if self._trace: - if self._tracesupress: - self._tbuf.write(c) - if c == '\n': - content = self._tbuf.getvalue() - supress = False - for p in self._tracesupress: - if p.search(content): - supress = True - break - if not supress: - sys.stdout.write(content) - self._tbuf.truncate(0) - else: - sys.stdout.write(c) - sys.stdout.flush() - - def enabletrace(self, supress = None): - self.cv.acquire() - try: + if self._tracesuppress: + self._tbuf.write(c) + if c == '\n': + content = self._tbuf.getvalue() + suppress = False + for p in self._tracesuppress: + if p.search(content): + suppress = True + break + if not suppress: + sys.stdout.write(content) + self._tbuf.truncate(0) + self._tbuf.seek(0) + else: + sys.stdout.write(c) + sys.stdout.flush() + + def enabletrace(self, suppress = None): + self.cv.acquire() + try: if not self._trace: self._trace = True - self._tracesupress = supress + self._tracesuppress = suppress for c in self.buf.getvalue(): self.trace(c) - finally: - self.cv.release() + finally: + self.cv.release() def getbuf(self): - self.cv.acquire() - try: - buf = self.buf.getvalue() - finally: - self.cv.release() - return buf + self.cv.acquire() + try: + buf = self.buf.getvalue() + finally: + self.cv.release() + return buf def match(self, pattern, timeout, matchall = False): - """pattern is a list of string, regexp duples. - """ + """pattern is a list of string, regexp duples. + """ - if timeout is not None: - end = time.time() + timeout - start = time.time() + if timeout is not None: + end = time.time() + timeout + start = time.time() - # Trace the match - if self.logfile: + # Trace the match + if self.logfile: if timeout is None: tdesc = "<infinite>" else: tdesc = "%.2fs" % timeout p = [ escape(s) for (s, r) in pattern ] - pdesc = StringIO.StringIO() + pdesc = getStringIO() if len(p) == 1: pdesc.write(escape(p[0])) else: @@ -169,81 +181,83 @@ class reader(threading.Thread): pdesc.write(','); pdesc.write(escape(pat)) pdesc.write(']'); - self.logfile.write('%s: expect: "%s" timeout: %s\n' % (self.desc, pdesc.getvalue(), tdesc)) - self.logfile.flush() + self.logfile.write('%s: expect: "%s" timeout: %s\n' % (self.desc, pdesc.getvalue(), tdesc)) + self.logfile.flush() maxend = None - self.cv.acquire() - try: - try: # This second try/except block is necessary because of python 2.3 - while True: - buf = self.buf.getvalue() - - # Try to match on the current buffer. - olen = len(pattern) - for index, p in enumerate(pattern): - s, regexp = p - if s == TIMEOUT: - continue - m = regexp.search(buf) - if m is not None: - before = buf[:m.start()] - matched = buf[m.start():m.end()] - after = buf[m.end():] - - if maxend is None or m.end() > maxend: - maxend = m.end() - - # Trace the match - if self.logfile: - if len(pattern) > 1: - self.logfile.write('%s: match found in %.2fs.\npattern: "%s"\nbuffer: "%s||%s||%s"\n'% - (self.desc, time.time() - start, escape(s), escape(before), - escape(matched), escape(after))) - else: - self.logfile.write('%s: match found in %.2fs.\nbuffer: "%s||%s||%s"\n' % - (self.desc, time.time() - start, escape(before), escape(matched), - escape(after))) - - if matchall: - del pattern[index] - # If all patterns have been found then - # truncate the buffer to the longest match, - # and then return. - if len(pattern) == 0: - self.buf.truncate(0) - self.buf.write(buf[maxend:]) - return buf - break - - # Consume matched portion of the buffer. - self.buf.truncate(0) - self.buf.write(after) - - return buf, before, after, m, index - - # If a single match was found then the match. - if len(pattern) != olen: - continue - - if timeout is None: - self.cv.wait() - else: - self.cv.wait(end - time.time()) - if time.time() >= end: - # Log the failure - if self.logfile: - self.logfile.write('%s: match failed.\npattern: "%s"\nbuffer: "%s"\n"' % - (self.desc, escape(s), escape(buf))) - self.logfile.flush() - raise TIMEOUT ('timeout exceeded in match\npattern: "%s"\nbuffer: "%s"\n' % - (escape(s), escape(buf, False))) - except TIMEOUT, e: - if (TIMEOUT, None) in pattern: - return buf, buf, TIMEOUT, None, pattern.index((TIMEOUT, None)) - raise e - finally: - self.cv.release() + self.cv.acquire() + try: + try: # This second try/except block is necessary because of python 2.3 + while True: + buf = self.buf.getvalue() + + # Try to match on the current buffer. + olen = len(pattern) + for index, p in enumerate(pattern): + s, regexp = p + if s == TIMEOUT: + continue + m = regexp.search(buf) + if m is not None: + before = buf[:m.start()] + matched = buf[m.start():m.end()] + after = buf[m.end():] + + if maxend is None or m.end() > maxend: + maxend = m.end() + + # Trace the match + if self.logfile: + if len(pattern) > 1: + self.logfile.write('%s: match found in %.2fs.\npattern: "%s"\nbuffer: "%s||%s||%s"\n'% + (self.desc, time.time() - start, escape(s), escape(before), + escape(matched), escape(after))) + else: + self.logfile.write('%s: match found in %.2fs.\nbuffer: "%s||%s||%s"\n' % + (self.desc, time.time() - start, escape(before), escape(matched), + escape(after))) + + if matchall: + del pattern[index] + # If all patterns have been found then + # truncate the buffer to the longest match, + # and then return. + if len(pattern) == 0: + self.buf.truncate(0) + self.buf.seek(0) + self.buf.write(buf[maxend:]) + return buf + break + + # Consume matched portion of the buffer. + self.buf.truncate(0) + self.buf.seek(0) + self.buf.write(after) + + return buf, before, after, m, index + + # If a single match was found then the match. + if len(pattern) != olen: + continue + + if timeout is None: + self.cv.wait() + else: + self.cv.wait(end - time.time()) + if time.time() >= end: + # Log the failure + if self.logfile: + self.logfile.write('%s: match failed.\npattern: "%s"\nbuffer: "%s"\n"' % + (self.desc, escape(s), escape(buf))) + self.logfile.flush() + raise TIMEOUT ('timeout exceeded in match\npattern: "%s"\nbuffer: "%s"\n' % + (escape(s), escape(buf, False))) + except TIMEOUT as e: + if (TIMEOUT, None) in pattern: + return buf, buf, TIMEOUT, None, pattern.index((TIMEOUT, None)) + raise e + finally: + self.cv.release() def splitCommand(command_line): arg_list = [] @@ -297,100 +311,103 @@ def splitCommand(command_line): class Expect (object): def __init__(self, command, startReader = True, timeout=30, logfile=None, mapping = None, desc = None, cwd = None, env = None): - self.buf = "" # The part before the match - self.before = "" # The part before the match - self.after = "" # The part after the match - self.matchindex = 0 # the index of the matched pattern - self.match = None # The last match + self.buf = "" # The part before the match + self.before = "" # The part before the match + self.after = "" # The part after the match + self.matchindex = 0 # the index of the matched pattern + self.match = None # The last match self.mapping = mapping # The mapping of the test. self.exitstatus = None # The exitstatus, either -signal or, if positive, the exit code. self.killed = None # If killed, the signal that was sent. - self.desc = desc - self.logfile = logfile - self.timeout = timeout - self.p = None + self.desc = desc + self.logfile = logfile + self.timeout = timeout + self.p = None - if self.logfile: - self.logfile.write('spawn: "%s"\n' % command) - self.logfile.flush() + if self.logfile: + self.logfile.write('spawn: "%s"\n' % command) + self.logfile.flush() if win32: # Don't rely on win32api #import win32process - #creationflags = win32process.CREATE_NEW_PROCESS_GROUP) + #creationflags = win32process.CREATE_NEW_PROCESS_GROUP) + # + # universal_newlines = True is necessary for Python 3 on Windows + # CREATE_NEW_PROCESS_GROUP = 512 self.p = subprocess.Popen(command, env = env, cwd = cwd, shell=False, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - creationflags = 512) # CREATE_NEW_PROCESS_GROUP + creationflags = CREATE_NEW_PROCESS_GROUP, universal_newlines=True) else: self.p = subprocess.Popen(splitCommand(command), env = env, cwd = cwd, shell=False, bufsize=0, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - self.r = reader(desc, self.p, logfile) + self.r = reader(desc, self.p, logfile) - # The thread is marked as a daemon thread. This is done so that if - # an expect script runs off the end of main without kill/wait on each - # spawned process the script will not hang tring to join with the - # reader thread. Instead __del__ (below) will be called which - # terminates and joins with the reader thread. - self.r.setDaemon(True) + # The thread is marked as a daemon thread. This is done so that if + # an expect script runs off the end of main without kill/wait on each + # spawned process the script will not hang tring to join with the + # reader thread. Instead __del__ (below) will be called which + # terminates and joins with the reader thread. + self.r.setDaemon(True) - if startReader: - self.startReader() + if startReader: + self.startReader() def startReader(self): - self.r.start() + self.r.start() def __del__(self): - # Terminate and clean up. - if self.p is not None: - self.terminate() + # Terminate and clean up. + if self.p is not None: + self.terminate() def expect(self, pattern, timeout = 20): - """pattern is either a string, or a list of string regexp patterns. + """pattern is either a string, or a list of string regexp patterns. - timeout == None expect can block indefinitely. + timeout == None expect can block indefinitely. - timeout == -1 then the default is used. - """ - if timeout == -1: - timeout = self.timeout + timeout == -1 then the default is used. + """ + if timeout == -1: + timeout = self.timeout - if type(pattern) != list: - pattern = [ pattern ] + if type(pattern) != list: + pattern = [ pattern ] def compile(s): if type(s) == str: return re.compile(s, re.S) return None - pattern = [ ( p, compile(p) ) for p in pattern ] + pattern = [ ( p, compile(p) ) for p in pattern ] try: self.buf, self.before, self.after, self.match, self.matchindex = self.r.match(pattern, timeout) - except TIMEOUT, e: + except TIMEOUT as e: self.buf = "" self.before = "" self.after = "" self.match = None self.matchindex = 0 raise e - return self.matchindex + return self.matchindex def expectall(self, pattern, timeout = 10): - """pattern is a list of string regexp patterns. + """pattern is a list of string regexp patterns. - timeout == None expect can block indefinitely. + timeout == None expect can block indefinitely. - timeout == -1 then the default is used. - """ - if timeout == -1: - timeout = self.timeout + timeout == -1 then the default is used. + """ + if timeout == -1: + timeout = self.timeout - pattern = [ ( p, re.compile(p, re.S) ) for p in pattern ] + pattern = [ ( p, re.compile(p, re.S) ) for p in pattern ] try: self.buf = self.r.match(pattern, timeout, matchall = True) self.before = "" self.after = "" self.matchindex = 0 self.match = None - except TIMEOUT, e: + except TIMEOUT as e: self.buf = "" self.before = "" self.after = "" @@ -399,22 +416,27 @@ class Expect (object): raise e def sendline(self, data): - """send data to the application. - """ - if self.logfile: - self.logfile.write('%s: sendline: "%s"\n' % (self.desc, escape(data))) - self.logfile.flush() - self.p.stdin.write("%s\n" % data) + """send data to the application. + """ + if self.logfile: + self.logfile.write('%s: sendline: "%s"\n' % (self.desc, escape(data))) + self.logfile.flush() + if win32 or sys.version_info[0] == 2: + self.p.stdin.write(data) + self.p.stdin.write("\n") + else: + self.p.stdin.write(data.encode("utf-8")) + self.p.stdin.write("\n".encode("utf-8")) def wait(self, timeout = None): - """Wait for the application to terminate for up to timeout seconds, or + """Wait for the application to terminate for up to timeout seconds, or raises a TIMEOUT exception. If timeout is None, the wait is indefinite. The exit status is returned. A negative exit status means the application was killed by a signal. - """ - if self.p is not None: + """ + if self.p is not None: # Unfortunately, with the subprocess module there is no # better method of doing a timed wait. @@ -425,23 +447,23 @@ class Expect (object): if self.p.poll() is None: raise TIMEOUT ('timedwait exceeded timeout') - self.exitstatus = self.p.wait() + self.exitstatus = self.p.wait() # A Windows application with a negative exit status means # killed by CTRL_BREAK. Fudge the exit status. if win32 and self.exitstatus < 0 and self.killed is not None: self.exitstatus = -self.killed - self.p = None - self.r.join() - # Simulate a match on EOF - self.buf = self.r.getbuf() - self.before = self.buf - self.after = "" - self.r = None - return self.exitstatus + self.p = None + self.r.join() + # Simulate a match on EOF + self.buf = self.r.getbuf() + self.before = self.buf + self.after = "" + self.r = None + return self.exitstatus def terminate(self): - """Terminate the process.""" + """Terminate the process.""" # First try to break the app. Don't bother if this is win32 # and we're using java. It won't break (BREAK causes a stack # trace). @@ -468,19 +490,19 @@ class Expect (object): try: self.wait(timeout = 5) return - except TIMEOUT, e: + except TIMEOUT as e: pass - try: + try: if win32: # Next kill the app. if self.hasInterruptSupport(): - print "%s: did not respond to break. terminating: %d" % (self.desc, self.p.pid) - subprocess.TerminateProcess(self.p._handle, -1) + print("%s: did not respond to break. terminating: %d" % (self.desc, self.p.pid)) + self.p.terminate() else: os.kill(self.p.pid, signal.SIGKILL) self.wait() - except: + except: traceback.print_exc(file=sys.stdout) def kill(self, sig): @@ -506,7 +528,7 @@ class Expect (object): except: traceback.print_exc(file=sys.stdout) else: - subprocess.TerminateProcess(self.p._handle, sig) + self.p.terminate() else: os.kill(self.p.pid, sig) @@ -517,18 +539,21 @@ class Expect (object): # def waitTestSuccess(self, exitstatus = 0, timeout = None): """Wait for the process to terminate for up to timeout seconds, and - validate the exit status is as expected.""" + validate the exit status is as expected.""" def test(result, expected): if expected != result: - print "unexpected exit status: expected: %d, got %d" % (expected, result) + print("unexpected exit status: expected: %d, got %d" % (expected, result)) assert False self.wait(timeout) if self.mapping == "java": if self.killed is not None: if win32: - test(self.exitstatus, self.killed) + if self.killed == signal.SIGINT: + test(self.exitstatus, 1) + else: + test(self.exitstatus, self.killed) else: if self.killed == signal.SIGINT: test(130, self.exitstatus) @@ -539,8 +564,17 @@ class Expect (object): else: test(self.exitstatus, exitstatus) - def trace(self, supress = None): - self.r.enabletrace(supress) + def waitTestFail(self, timeout = None): + """Wait for the process to terminate for up to timeout seconds, and + validate the exit status is as expected.""" + + self.wait(timeout) + if self.exitstatus == 0: + print("unexpected non-zero exit status") + assert False + + def trace(self, suppress = None): + self.r.enabletrace(suppress) def hasInterruptSupport(self): """Return True if the application gracefully terminated, False otherwise.""" diff --git a/scripts/IceGridAdmin.py b/scripts/IceGridAdmin.py index c560b9853ef..b173b1fce70 100644 --- a/scripts/IceGridAdmin.py +++ b/scripts/IceGridAdmin.py @@ -95,7 +95,8 @@ def startIceGridRegistry(testdir, dynamicRegistration = False): else: cleanDbDir(dataDir) - print "starting icegrid " + name + "...", + sys.stdout.write("starting icegrid " + name + "... ") + sys.stdout.flush() cmd = command + ' ' + TestUtil.getQtSqlOptions('IceGrid') + \ r' --Ice.ProgramName=' + name + \ r' --IceGrid.Registry.Client.Endpoints="default -p ' + str(iceGridPort + i) + '" ' + \ @@ -108,7 +109,7 @@ def startIceGridRegistry(testdir, dynamicRegistration = False): driverConfig.lang = "cpp" proc = TestUtil.startServer(iceGrid, cmd, driverConfig, count = 4) procs.append(proc) - print "ok" + print("ok") i = i + 1 return procs @@ -117,14 +118,16 @@ def shutdownIceGridRegistry(procs): i = nreplicas while i > 0: - print "shutting down icegrid replica-" + str(i) + "...", + sys.stdout.write("shutting down icegrid replica-" + str(i) + "... ") + sys.stdout.flush() iceGridAdmin("registry shutdown replica-" + str(i)) - print "ok" + print("ok") i = i - 1 - print "shutting down icegrid registry...", + sys.stdout.write("shutting down icegrid registry... ") + sys.stdout.flush() iceGridAdmin("registry shutdown") - print "ok" + print("ok") for p in procs: p.waitTestSuccess() @@ -166,7 +169,8 @@ def startIceGridNode(testdir): overrideOptions = '" ' + iceGridNodePropertiesOverride() overrideOptions += ' Ice.ServerIdleTime=0 Ice.PrintProcessId=0 Ice.PrintAdapterReady=0"' - print "starting icegrid node...", + sys.stdout.write("starting icegrid node... ") + sys.stdout.flush() command = r' --nowarn ' + nodeOptions + getDefaultLocatorProperty() + \ r' --IceGrid.Node.Data="' + dataDir + '"' \ r' --IceGrid.Node.Name=localnode' + \ @@ -176,7 +180,7 @@ def startIceGridNode(testdir): driverConfig.lang = "cpp" proc = TestUtil.startServer(iceGrid, command, driverConfig, adapter='node') - print "ok" + print("ok") return proc @@ -202,7 +206,7 @@ def iceGridAdmin(cmd, ignoreFailure = False): TestUtil.appVerifierAfterTestEnd([TestUtil.getIceGridAdmin()]) if not ignoreFailure and status: - print proc.buf + print(proc.buf) sys.exit(1) return proc.buf @@ -218,7 +222,7 @@ def iceGridTest(application, additionalOptions = "", applicationOptions = ""): testdir = os.getcwd() if not TestUtil.isWin32() and os.getuid() == 0: print - print "*** can't run test as root ***" + print("*** can't run test as root ***") print return @@ -240,26 +244,30 @@ def iceGridTest(application, additionalOptions = "", applicationOptions = ""): iceGridNodeProc = startIceGridNode(testdir) if application != "": - print "adding application...", + sys.stdout.write("adding application... ") + sys.stdout.flush() iceGridAdmin("application add -n '" + os.path.join(testdir, application) + "' " + \ "test.dir='" + testdir + "' ice.bindir='" + TestUtil.getCppBinDir() + "' " + applicationOptions) - print "ok" + print("ok") - print "starting client...", + sys.stdout.write("starting client... ") + sys.stdout.flush() clientProc = TestUtil.startClient(client, clientOptions, TestUtil.DriverConfig("client"), startReader = False) - print "ok" + print("ok") clientProc.startReader() clientProc.waitTestSuccess() if application != "": - print "remove application...", + sys.stdout.write("remove application... ") + sys.stdout.flush() iceGridAdmin("application remove Test") - print "ok" + print("ok") - print "shutting down icegrid node...", + sys.stdout.write("shutting down icegrid node... ") + sys.stdout.flush() iceGridAdmin("node shutdown localnode") - print "ok" + print("ok") shutdownIceGridRegistry(registryProcs) iceGridNodeProc.waitTestSuccess() @@ -288,13 +296,15 @@ def iceGridClientServerTest(additionalClientOptions, additionalServerOptions): registryProcs = startIceGridRegistry(testdir, True) - print "starting server...", + sys.stdout.write("starting server... ") + sys.stdout.flush() serverProc= TestUtil.startServer(server, serverOptions, TestUtil.DriverConfig("server")) - print "ok" + print("ok") - print "starting client...", + sys.stdout.write("starting client... ") + sys.stdout.flush() clientProc = TestUtil.startClient(client, clientOptions, TestUtil.DriverConfig("client")) - print "ok" + print("ok") clientProc.waitTestSuccess() serverProc.waitTestSuccess() diff --git a/scripts/IceStormUtil.py b/scripts/IceStormUtil.py index 98df09c17ed..eb3875efb65 100644 --- a/scripts/IceStormUtil.py +++ b/scripts/IceStormUtil.py @@ -150,20 +150,20 @@ class Replicated(IceStormUtil): def start(self, echo = True, **args): if echo: - print "starting icestorm replicas...", + sys.stdout.write("starting icestorm replicas... ") sys.stdout.flush() # Start replicas. for replica in range(0, 3): if echo: - print replica, + sys.stdout.write(str(replica) + " ") sys.stdout.flush() self.startReplica(replica, echo=False, **args) if echo: - print "ok" + print("ok") def startReplica(self, replica, echo = True, additionalOptions = ""): if echo: - print "starting icestorm replica %d..." % replica, + sys.stdout.write("starting icestorm replica %d..." % replica + " ") sys.stdout.flush() proc = TestUtil.startServer(self.iceBox, @@ -176,7 +176,7 @@ class Replicated(IceStormUtil): echo = False) self.procs[replica] = proc if echo: - print "ok" + print("ok") def stop(self): for replica in range(0, 3): @@ -239,9 +239,9 @@ class NonReplicated(IceStormUtil): def start(self, echo = True, additionalOptions = ""): if echo: if self.transient: - print "starting transient icestorm service...", + sys.stdout.write("starting transient icestorm service... ") else: - print "starting icestorm service...", + sys.stdout.write("starting icestorm service... ") sys.stdout.flush() self.proc = TestUtil.startServer(self.iceBox, @@ -251,7 +251,7 @@ class NonReplicated(IceStormUtil): additionalOptions, adapter = "IceStorm", echo = False) if echo: - print "ok" + print("ok") return self.proc def stop(self): diff --git a/scripts/TestUtil.py b/scripts/TestUtil.py index d04186e9923..9e505c93bf0 100755 --- a/scripts/TestUtil.py +++ b/scripts/TestUtil.py @@ -7,7 +7,7 @@ # # ********************************************************************** -import sys, os, re, getopt, time, StringIO, string, threading, atexit +import sys, os, re, getopt, time, string, threading, atexit # Global flags and their default values. protocol = "" # If unset, default to TCP. Valid values are "tcp" or "ssl". @@ -49,13 +49,13 @@ def isVista(): def isWin9x(): if isWin32(): - return not (os.environ.has_key("OS") and os.environ["OS"] == "Windows_NT") + return not ("OS" in os.environ and os.environ["OS"] == "Windows_NT") else: return 0 def isSolaris(): return sys.platform == "sunos5" - + def isSparc(): p = os.popen("uname -m") l = p.readline().strip() @@ -67,7 +67,7 @@ def isSparc(): def isAIX(): return sys.platform in ['aix4', 'aix5'] - + def isDarwin(): return sys.platform == "darwin" @@ -104,7 +104,7 @@ def isVS2010(): # The PHP interpreter is called "php5" on some platforms (e.g., SLES). # phpCmd = "php" -for path in string.split(os.environ["PATH"], os.pathsep): +for path in os.environ["PATH"].split(os.pathsep): # # Stop if we find "php" in the PATH first. # @@ -122,7 +122,7 @@ defaultMapping = None testErrors = [] -toplevel = None +toplevel = None path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ] head = os.path.dirname(sys.argv[0]) @@ -166,14 +166,14 @@ def dumpenv(env, lang): vars.append("RUBYLIB") for i in vars: if i in env: - print "%s=%s" % (i, env[i]) + print("%s=%s" % (i, env[i])) def configurePaths(): if iceHome: - print "*** using Ice installation from " + iceHome, + sys.stdout.write("*** using Ice installation from " + iceHome + " ") if x64: - print "(64bit)", - print + sys.stdout.write("(64bit) ") + sys.stdout.write("\n") # First sanitize the environment. os.environ["CLASSPATH"] = sanitize(os.getenv("CLASSPATH", "")) @@ -191,7 +191,7 @@ def configurePaths(): addClasspath(os.path.join(javaDir, "IceGrid.jar")) addClasspath(os.path.join(javaDir, "IcePatch2.jar")) return # That's it, we're done! - + if isWin32(): libDir = getCppBinDir() if iceHome and isBCC2010(): @@ -199,19 +199,19 @@ def configurePaths(): libDir = os.path.join(libDir, "bcc10") else: libDir = os.path.join(getIceDir("cpp"), "lib") - if iceHome and x64: - if isSolaris(): - if isSparc(): - libDir = os.path.join(libDir, "sparcv9") - else: - libDir = os.path.join(libDir, "amd64") - else: - libDir = libDir + "64" + if iceHome and x64: + if isSolaris(): + if isSparc(): + libDir = os.path.join(libDir, "sparcv9") + else: + libDir = os.path.join(libDir, "amd64") + else: + libDir = libDir + "64" addLdPath(libDir) if getDefaultMapping() == "javae": javaDir = os.path.join(getIceDir("javae"), "jdk", "lib") - addClasspath(os.path.join(javaDir, "IceE.jar")) + addClasspath(os.path.join(javaDir, "IceE.jar")) os.environ["CLASSPATH"] = os.path.join(javaDir, "IceE.jar") + os.pathsep + os.getenv("CLASSPATH", "") else: # The Ice.jar and Freeze.jar comes from the installation @@ -225,15 +225,15 @@ def configurePaths(): addClasspath(os.path.join(javaDir, "IceGrid.jar")) addClasspath(os.path.join(javaDir, "IcePatch2.jar")) addClasspath(os.path.join(javaDir)) - - # + + # # On Windows, C# assemblies are found thanks to the .exe.config files. # if isWin32(): addPathToEnv("DEVPATH", os.path.join(getIceDir("cs"), "bin")) else: addPathToEnv("MONO_PATH", os.path.join(getIceDir("cs"), "bin")) - + # # On Windows x64, set PYTHONPATH to python/x64. # @@ -265,7 +265,7 @@ def addClasspath(path, env = None): def addPathToEnv(variable, path, env = None): if env is None: env = os.environ - if not env.has_key(variable): + if variable not in env: env[variable] = path else: env[variable] = path + os.pathsep + env.get(variable) @@ -291,10 +291,10 @@ crossTests = [ "Ice/adapterDeactivation", "Ice/slicing/exceptions", "Ice/slicing/objects", ] - + def run(tests, root = False): def usage(): - print "usage: " + sys.argv[0] + """ + print("usage: " + sys.argv[0] + """ --all Run all sensible permutations of the tests. --all-cross Run all sensible permutations of cross language tests. --start=index Start running the tests at the given index. @@ -324,7 +324,7 @@ def run(tests, root = False): --sql-passwd=<passwd> Set SQL password. --service-dir=<dir> Where to locate services for builds without service support. --compact Ice for .NET uses the Compact Framework. - """ + """) sys.exit(2) try: @@ -364,8 +364,8 @@ def run(tests, root = False): filters.append((testFilter, False)) elif o == "--cross": global cross - if not a in ["cpp", "java", "cs", "py", "rb" ]: - print "cross must be one of cpp, java, cs, py or rb" + if a not in ["cpp", "java", "cs", "py", "rb" ]: + print("cross must be one of cpp, java, cs, py or rb") sys.exit(1) cross.append(a) elif o == "--all" : @@ -383,10 +383,10 @@ def run(tests, root = False): usage() if getDefaultMapping() == "cs" and a == "ssl": if mono: - print "SSL is not supported with mono" + print("SSL is not supported with mono") sys.exit(1) if compact: - print "SSL is not supported with the Compact Framework" + print("SSL is not supported with the Compact Framework") sys.exit(1) if o in ( "--cross", "--protocol", "--host", "--debug", "--compress", "--valgrind", "--serialize", "--ipv6", \ @@ -435,10 +435,10 @@ def run(tests, root = False): if allCross: if len(cross) == 0: cross = ["cpp", "java", "cs" ] - if root: - allLang = ["cpp", "java", "cs" ] - else: - allLang = [ getDefaultMapping() ] + if root: + allLang = ["cpp", "java", "cs" ] + else: + allLang = [ getDefaultMapping() ] for lang in allLang: # This is all other languages than the current mapping. crossLang = [ l for l in cross if lang != l ] @@ -447,7 +447,7 @@ def run(tests, root = False): for c in crossLang: a = "--cross=%s --protocol=tcp" % c expanded.append([ ( "%s/test/%s" % (lang, test), a, []) for test in crossTests if not (test == "Ice/background" and (lang == "cs" or c == "cs"))]) - + # Add ssl & compress for the operations test. if (compact or mono) and c == "cs": # Don't add the ssl tests. continue @@ -475,9 +475,9 @@ def run(tests, root = False): global testErrors if len(testErrors) > 0: - print "The following errors occurred:" + print("The following errors occurred:") for x in testErrors: - print x + print(x) if not isWin32(): mono = True @@ -486,13 +486,13 @@ def getIceDir(subdir = None): # # If ICE_HOME is set we're running the test against a binary distribution. Otherwise, # we're running the test against a source distribution. - # + # global iceHome if iceHome: return iceHome elif subdir: return os.path.join(toplevel, subdir) - else: + else: return toplevel def phpCleanup(): @@ -555,7 +555,7 @@ def phpSetup(clientConfig = False, iceOptions = None, iceProfile = None): else: incDir = None else: - print "unable to find IcePHP extension!" + print("unable to find IcePHP extension!") sys.exit(1) atexit.register(phpCleanup) @@ -589,8 +589,8 @@ def getIceVersion(): def getIceSoVersion(): config = open(os.path.join(toplevel, "cpp", "include", "IceUtil", "Config.h"), "r") intVersion = int(re.search("ICE_INT_VERSION ([0-9]*)", config.read()).group(1)) - majorVersion = intVersion / 10000 - minorVersion = intVersion / 100 - 100 * majorVersion + majorVersion = int(intVersion / 10000) + minorVersion = int(intVersion / 100) - 100 * majorVersion patchVersion = intVersion % 100 if patchVersion > 50: if patchVersion >= 52: @@ -603,11 +603,11 @@ def getIceSoVersion(): def getIceSSLVersion(): javaPipeIn, javaPipeOut = os.popen4("java IceSSL.Util") if not javaPipeIn or not javaPipeOut: - print "unable to get IceSSL version!" + print("unable to get IceSSL version!") sys.exit(1) version = javaPipeOut.readline() if not version: - print "unable to get IceSSL version!" + print("unable to get IceSSL version!") sys.exit(1) javaPipeIn.close() javaPipeOut.close() @@ -616,11 +616,11 @@ def getIceSSLVersion(): def getJdkVersion(): javaPipeIn, javaPipeOut = os.popen4("java -version") if not javaPipeIn or not javaPipeOut: - print "unable to get Java version!" + print("unable to get Java version!") sys.exit(1) version = javaPipeOut.readline() if not version: - print "unable to get Java version!" + print("unable to get Java version!") sys.exit(1) javaPipeIn.close() javaPipeOut.close() @@ -637,10 +637,10 @@ def getIceBox(): iceBox = os.path.join(getServiceDir(), "icebox.exe") elif isWin32(): # - # Read the build.txt file from the test directory to figure out - # how the IceBox service was built ("debug" vs. "release") and + # Read the build.txt file from the test directory to figure out + # how the IceBox service was built ("debug" vs. "release") and # decide which icebox executable to use. - # + # build = open(os.path.join(os.getcwd(), "build.txt"), "r") type = build.read().strip() if type == "debug": @@ -651,17 +651,17 @@ def getIceBox(): iceBox = os.path.join(getCppBinDir(), "icebox") if not os.path.exists(iceBox): - print "couldn't find icebox executable to run the test" + print("couldn't find icebox executable to run the test") sys.exit(0) elif lang == "java": iceBox = "IceBox.Server" elif lang == "cs": iceBox = os.path.join(getIceDir("cs"), "bin", "iceboxnet") - + if iceBox == "": - print "couldn't find icebox executable to run the test" + print("couldn't find icebox executable to run the test") sys.exit(0) - + return iceBox def getIceBoxAdmin(): @@ -694,15 +694,15 @@ class InvalidSelectorString(Exception): def __str__(self): return repr(self.value) -sslConfigTree = { - "cpp" : { +sslConfigTree = { + "cpp" : { "plugin" : " --Ice.Plugin.IceSSL=IceSSL:createIceSSL --Ice.Default.Protocol=ssl " + "--IceSSL.DefaultDir=%(certsdir)s --IceSSL.CertAuthFile=cacert.pem", "client" : " --IceSSL.CertFile=c_rsa1024_pub.pem --IceSSL.KeyFile=c_rsa1024_priv.pem", "server" : " --IceSSL.CertFile=s_rsa1024_pub.pem --IceSSL.KeyFile=s_rsa1024_priv.pem", "colloc" : " --IceSSL.CertFile=c_rsa1024_pub.pem --IceSSL.KeyFile=c_rsa1024_priv.pem" }, - "java" : { + "java" : { "plugin" : " --Ice.Plugin.IceSSL=IceSSL.PluginFactory --Ice.Default.Protocol=ssl " + "--IceSSL.DefaultDir=%(certsdir)s --IceSSL.Password=password", "client" : " --IceSSL.Keystore=client.jks", @@ -730,12 +730,20 @@ def getDefaultMapping(): return here[i] raise "cannot determine mapping" +def getStringIO(): + if sys.version_info[0] == 2: + import StringIO + return StringIO.StringIO() + else: + import io + return io.StringIO() + class DriverConfig: lang = None - protocol = None + protocol = None compress = 0 serialize = 0 - host = None + host = None mono = False valgrind = False appverifier = False @@ -743,7 +751,7 @@ class DriverConfig: overrides = None ipv6 = False x64 = False - sqlType = None + sqlType = None sqlDbName = None sqlHost = None sqlPort = None @@ -755,7 +763,7 @@ class DriverConfig: global protocol global compress global serialize - global host + global host global mono global valgrind global appverifier @@ -780,7 +788,7 @@ class DriverConfig: self.type = type self.ipv6 = ipv6 self.x64 = x64 - self.sqlType = sqlType + self.sqlType = sqlType self.sqlDbName = sqlDbName self.sqlHost = sqlHost self.sqlPort = sqlPort @@ -809,7 +817,7 @@ def argsToDict(argumentString, results): return results def getCommandLineProperties(exe, config): - + # # Command lines are built up from the items in the components # sequence, which is initialized with command line options common to @@ -839,7 +847,7 @@ def getCommandLineProperties(exe, config): if config.serialize: components.append("--Ice.ThreadPool.Server.Serialize=1") - + if config.type == "server" or config.type == "colloc" and config.lang == "py": components.append("--Ice.ThreadPool.Server.Size=1 --Ice.ThreadPool.Server.SizeMax=3 --Ice.ThreadPool.Server.SizeWarn=0") @@ -852,59 +860,59 @@ def getCommandLineProperties(exe, config): components.append("--Ice.Default.Host=%s" % config.host) # - # Not very many tests actually require an option override, so not to worried + # Not very many tests actually require an option override, so not too worried # about optimal here. # if config.overrides != None and len(config.overrides) > 0: propTable = {} for c in components: argsToDict(c, propTable) - + argsToDict(config.overrides, propTable) components = [] - for k, v in propTable.iteritems(): + for k, v in propTable.items(): if v != None: components.append("%s=%s" % (k, v)) else: components.append("%s" % k) - output = StringIO.StringIO() + output = getStringIO() for c in components: - print >>output, c, + output.write(c + " ") properties = output.getvalue() output.close() return properties def getCommandLine(exe, config): - - output = StringIO.StringIO() + + output = getStringIO() if config.mono and config.lang == "cs": - print >>output, "mono", "--debug '%s.exe'" % exe, + output.write("mono --debug '%s.exe' " % exe) elif config.lang == "rb" and config.type == "client": - print >>output, "ruby '" + exe + "'", + output.write("ruby '" + exe + "' ") elif config.lang == "java" or config.lang == "javae": - print >>output, "%s -ea" % javaCmd, + output.write("%s -ea " % javaCmd) if isSolaris() and config.x64: - print >>output, "-d64", + output.write("-d64 ") if not config.ipv6: - print >>output, "-Djava.net.preferIPv4Stack=true", - print >>output, exe, + output.write("-Djava.net.preferIPv4Stack=true ") + output.write(exe + " ") elif config.lang == "py": - print >>output, sys.executable, '"%s"' % exe, + output.write(sys.executable + ' "%s" ' % exe) elif config.lang == "php" and config.type == "client": - print >>output, phpCmd, "-c tmp.ini -f \""+ exe +"\" -- ", + output.write(phpCmd + " -c tmp.ini -f \""+ exe +"\" -- ") elif config.lang == "cpp" and config.valgrind: # --child-silent-after-fork=yes is required for the IceGrid/activator test where the node # forks a process with execv failing (invalid exe name). - print >>output, "valgrind -q --child-silent-after-fork=yes --leak-check=full ", - print >>output, '--suppressions="' + os.path.join(toplevel, "config", "valgrind.sup") + '" "' + exe + '"', + output.write("valgrind -q --child-silent-after-fork=yes --leak-check=full ") + output.write('--suppressions="' + os.path.join(toplevel, "config", "valgrind.sup") + '" "' + exe + '" ') else: if exe.find(" ") != -1: - print >>output, '"' + exe + '"', + output.write('"' + exe + '" ') else: - print >>output, exe, + output.write(exe + " ") - print >>output, getCommandLineProperties(exe, config), + output.write(getCommandLineProperties(exe, config)) commandline = output.getvalue() output.close() @@ -917,11 +925,11 @@ def directoryToPackage(): before = base lang = getDefaultMapping() while len(before) > 0: - current = os.path.basename(before) - before = os.path.dirname(before) - if current == lang: - break - after.insert(0, current) + current = os.path.basename(before) + before = os.path.dirname(before) + if current == lang: + break + after.insert(0, current) else: raise "cannot find language dir" return ".".join(after) @@ -1019,7 +1027,7 @@ def spawn(cmd, env=None, cwd=None, startReader=True, lang=None): watchDog.reset() if debug: - print "(%s)" % cmd, + sys.stdout.write("(%s) " % cmd) if printenv: dumpenv(env, lang) return Expect.Expect(cmd, startReader=startReader, env=env, logfile=tracefile, cwd=cwd) @@ -1066,12 +1074,12 @@ def setAppVerifierSettings(targets, cwd=os.getcwd()): for exe in targets: if exe.endswith(".exe") == False: exe += ".exe" - + #First enable all appverifier tests cmd = "appverif -enable * -for " + exe verifier = spawn(cmd, cwd=cwd) verifier.expect(matchAppVerifierSuccess(), -1) - + #Now disable all tests we are not intested in cmd = "appverif -disable LuaPriv PrintDriver PrintApi -for " + exe verifier = spawn(cmd, cwd=cwd) @@ -1107,11 +1115,11 @@ def getMirrorDir(base, mapping): after = [] before = base while len(before) > 0: - current = os.path.basename(before) - before = os.path.dirname(before) - if current == lang: - break - after.insert(0, current) + current = os.path.basename(before) + before = os.path.dirname(before) + if current == lang: + break + after.insert(0, current) else: raise "cannot find language dir" return os.path.join(before, mapping, *after) @@ -1147,15 +1155,15 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "", clientCfg = DriverConfig("client") if clientLang != lang: if clientDesc != getDefaultClientFile(): - print "** skipping cross test" + print("** skipping cross test") return clientCfg.lang = clientLang client = getDefaultClientFile(clientLang) clientdir = getMirrorDir(testdir, clientLang) - print clientdir + print(clientdir) if not os.path.exists(clientdir): - print "** no matching test for %s" % clientLang + print("** no matching test for %s" % clientLang) return else: clientdir = testdir @@ -1168,33 +1176,34 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "", if lang == "php": phpSetup() - + clientExe = client serverExe = server - + if appverifier: setAppVerifierSettings([clientExe, serverExe]) - print "starting " + serverDesc + "...", + sys.stdout.write("starting " + serverDesc + "... ") + sys.stdout.flush() serverCfg = DriverConfig("server") if lang in ["rb", "php"]: serverCfg.lang = "cpp" server = getCommandLine(server, serverCfg) + " " + additionalServerOptions serverProc = spawnServer(server, env = serverenv, lang=serverCfg.lang) - print "ok" + print("ok") if clientLang == lang: - print "starting %s..." % clientDesc, + sys.stdout.write("starting %s... " % clientDesc) else: - print "starting %s %s ..." % (clientLang, clientDesc), + sys.stdout.write("starting %s %s ... " % (clientLang, clientDesc)) + sys.stdout.flush() client = getCommandLine(client, clientCfg) + " " + additionalClientOptions clientProc = spawnClient(client, env = clientenv, startReader = False, lang=clientCfg.lang) - print "ok" + print("ok") clientProc.startReader() clientProc.waitTestSuccess() serverProc.waitTestSuccess() - if appverifier: appVerifierAfterTestEnd([clientExe, serverExe]) @@ -1202,24 +1211,25 @@ def clientServerTest(additionalServerOptions = "", additionalClientOptions = "", def collocatedTest(additionalOptions = ""): lang = getDefaultMapping() if len(cross) > 1 or cross[0] != lang: - print "** skipping cross test" + print("** skipping cross test") return testdir = os.getcwd() collocated = getDefaultCollocatedFile() if lang != "java" and lang != "javae": - collocated = os.path.join(testdir, collocated) + collocated = os.path.join(testdir, collocated) exe = collocated if appverifier: setAppVerifierSettings([exe]) - + env = getTestEnv(lang, testdir) - print "starting collocated...", - collocated = getCommandLine(collocated, DriverConfig("colloc")) + ' ' + additionalOptions + sys.stdout.write("starting collocated... ") + sys.stdout.flush() + collocated = getCommandLine(collocated, DriverConfig("colloc")) + ' ' + additionalOptions collocatedProc = spawnClient(collocated, env = env, startReader = False, lang=lang) - print "ok" + print("ok") collocatedProc.startReader() collocatedProc.waitTestSuccess() if appverifier: @@ -1270,25 +1280,29 @@ def simpleTest(exe = None, options = ""): if lang != "cpp": config = DriverConfig("client") config.lang = lang - - print "starting client...", + + sys.stdout.write("starting client... ") + sys.stdout.flush() command = exe + ' ' + options if lang != "cpp": command = getCommandLine(exe, config) + ' ' + options client = spawnClient(command, startReader = False, lang = lang) - print "ok" + print("ok") client.startReader() client.waitTestSuccess() - + if appverifier: appVerifierAfterTestEnd([exe]) - -def createConfig(path, lines): - config = open(path, "w") + +def createConfig(path, lines, enc=None): + if sys.version_info[0] > 2 and enc: + config = open(path, "w", encoding=enc) + else: + config = open(path, "wb") for l in lines: config.write("%s\n" % l) config.close() - + def getCppBinDir(): binDir = os.path.join(getIceDir("cpp"), "bin") if iceHome: @@ -1318,7 +1332,7 @@ def getTestEnv(lang, testdir): if lang == "cpp": addLdPath(os.path.join(testdir), env) elif lang == "java": - addClasspath(os.path.join(toplevel, "java", "lib", "IceTest.jar"), env) + addClasspath(os.path.join(toplevel, "java", "lib", "IceTest.jar"), env) return env; def getTestName(): @@ -1338,18 +1352,18 @@ def getTestName(): def joindog(dog): dog.stop() dog.join() - + class WatchDog(threading.Thread): def __init__(self): - self._reset = False - self._stop = False + self._resetFlag = False + self._stopFlag = False self._cv = threading.Condition() threading.Thread.__init__(self) - # The thread is marked as a daemon thread. The atexit handler + # The thread is marked as a daemon thread. The atexit handler # joins with the thread on exit. If the thread is not daemon, # the atexit handler will not be called. - self.setDaemon(True) + self.setDaemon(True) self.start() atexit.register(joindog, self) @@ -1358,13 +1372,13 @@ class WatchDog(threading.Thread): self._cv.acquire() while True: self._cv.wait(180) - if self._stop: - break - if self._reset: - self._reset = False + if self._stopFlag: + break + if self._resetFlag: + self._resetFlag = False else: - print "\a*** %s Warning: Test has been inactive for 3 minutes and may be hung", \ - time.strftime("%x %X") + print("\a*** %s Warning: Test has been inactive for 3 minutes and may be hung", \ + time.strftime("%x %X")) self._cv.release() except: # @@ -1376,19 +1390,19 @@ class WatchDog(threading.Thread): def reset(self): self._cv.acquire() - self._reset = True + self._resetFlag = True self._cv.notify() self._cv.release() def stop(self): self._cv.acquire() - self._stop = True + self._stopFlag = True self._cv.notify() self._cv.release() def processCmdLine(): def usage(): - print "usage: " + sys.argv[0] + """ + print("usage: " + sys.argv[0] + """ --debug Display debugging information on each test. --trace=<file> Display tracing. --protocol=tcp|ssl Run with the given protocol. @@ -1410,7 +1424,7 @@ def processCmdLine(): --sql-passwd=<passwd> Set SQL password. --service-dir=<dir> Where to locate services for builds without service support. --compact Ice for .NET uses the Compact Framework. - """ + """) sys.exit(2) try: @@ -1435,17 +1449,17 @@ def processCmdLine(): #if getTestName() not in crossTests: cross.append(a) if not a in ["cpp", "java", "cs", "py", "rb" ]: - print "cross must be one of cpp, java, cs, py or rb" + print("cross must be one of cpp, java, cs, py or rb") sys.exit(1) if getTestName() not in crossTests: - print "*** This test does not support cross language testing" + print("*** This test does not support cross language testing") sys.exit(0) - # Temporary. - lang = getDefaultMapping() + # Temporary. + lang = getDefaultMapping() if getTestName() == "Ice/background" and (lang == "cs" or cross == "cs"): - print "*** This test does not support cross language testing" + print("*** This test does not support cross language testing") sys.exit(0) - + elif o == "--x64": global x64 x64 = True @@ -1463,19 +1477,19 @@ def processCmdLine(): valgrind = True elif o == "--appverifier": if not isWin32() or getDefaultMapping() != "cpp": - print "--appverifier option is only supported for Win32 c++ tests." + print("--appverifier option is only supported for Win32 c++ tests.") sys.exit(1) global appverifier appverifier = True elif o == "--ipv6": global ipv6 ipv6 = True - if o == "--trace": + if o == "--trace": global tracefile - if a == "stdout": - tracefile = sys.stdout - else: - tracefile = open(a, "w") + if a == "stdout": + tracefile = sys.stdout + else: + tracefile = open(a, "w") elif o == "--debug": global debug debug = True @@ -1487,7 +1501,7 @@ def processCmdLine(): usage() # ssl protocol isn't directly supported with mono. if mono and getDefaultMapping() == "cs" and a == "ssl": - print "SSL is not supported with mono" + print("SSL is not supported with mono") sys.exit(1) global protocol protocol = a @@ -1525,10 +1539,10 @@ def processCmdLine(): iceHome = os.environ["ICE_HOME"] elif isLinux(): iceHome = "/usr" - + if not x64: x64 = isWin32() and os.environ.get("XTARGET") == "x64" or os.environ.get("LP64") == "yes" - + configurePaths() def runTests(start, expanded, num = 0, script = False): @@ -1548,9 +1562,9 @@ def runTests(start, expanded, num = 0, script = False): i = os.path.normpath(i) dir = os.path.join(toplevel, i) - print + sys.stdout.write("\n") if num > 0: - print "[" + str(num) + "]", + sys.stdout.write("[" + str(num) + "] ") if script: prefix = "echo \"" suffix = "\"" @@ -1558,117 +1572,117 @@ def runTests(start, expanded, num = 0, script = False): prefix = "" suffix = "" - print "%s*** running tests %d/%d in %s%s" % (prefix, index, total, dir, suffix) - print "%s*** configuration:" % prefix, + print("%s*** running tests %d/%d in %s%s" % (prefix, index, total, dir, suffix)) + sys.stdout.write("%s*** configuration: " % prefix) if len(args.strip()) == 0: - print "Default", + sys.stdout.write("Default ") else: - print args.strip(), - print suffix + sys.stdout.write(args.strip() + " ") + print(suffix) if args.find("cross") != -1: test = os.path.join(*i.split(os.sep)[2:]) # The crossTests list is in UNIX format. test = test.replace(os.sep, '/') if not test in crossTests: - print "%s*** test does not support cross testing%s" % (prefix, suffix) + print("%s*** test does not support cross testing%s" % (prefix, suffix)) continue # # Skip tests not supported with IPv6 if necessary # if args.find("ipv6") != -1 and "noipv6" in config: - print "%s*** test not supported with IPv6%s" % (prefix, suffix) + print("%s*** test not supported with IPv6%s" % (prefix, suffix)) continue if args.find("compress") != -1 and "nocompress" in config: - print "%s*** test not supported with compression%s" % (prefix, suffix) + print("%s*** test not supported with compression%s" % (prefix, suffix)) continue if args.find("compact") != -1 and "nocompact" in config: - print "%s*** test not supported with Compact Framework%s" % (prefix, suffix) + print("%s*** test not supported with Compact Framework%s" % (prefix, suffix)) continue if args.find("compact") == -1 and "compact" in config: - print "%s*** test requires Compact Framework%s" % (prefix, suffix) + print("%s*** test requires Compact Framework%s" % (prefix, suffix)) continue if isVista() and "novista" in config: - print "%s*** test not supported under Vista%s" % (prefix, suffix) + print("%s*** test not supported under Vista%s" % (prefix, suffix)) continue - + if isDarwin() and "nodarwin" in config: - print "%s*** test not supported under Darwin%s" % (prefix, suffix) + print("%s*** test not supported under Darwin%s" % (prefix, suffix)) continue - + if not isWin32() and "win32only" in config: - print "%s*** test only supported under Win32%s" % (prefix, suffix) + print("%s*** test only supported under Win32%s" % (prefix, suffix)) continue if isBCC2010() and "nobcc" in config: - print "%s*** test not supported with C++Builder%s" % (prefix, suffix) + print("%s*** test not supported with C++Builder%s" % (prefix, suffix)) continue if isVC6() and "novc6" in config: - print "%s*** test not supported with VC++ 6.0%s" % (prefix, suffix) + print("%s*** test not supported with VC++ 6.0%s" % (prefix, suffix)) continue # If this is mono and we're running ssl protocol tests # then skip. This occurs when using --all. if mono and ("nomono" in config or (i.find(os.path.join("cs","test")) != -1 and args.find("ssl") != -1)): - print "%s*** test not supported with mono%s" % (prefix, suffix) + print("%s*** test not supported with mono%s" % (prefix, suffix)) continue if args.find("ssl") != -1 and ("nossl" in config): - print "%s*** test not supported with IceSSL%s" % (prefix, suffix) + print("%s*** test not supported with IceSSL%s" % (prefix, suffix)) continue # If this is java and we're running ipv6 under windows then skip. if isWin32() and i.find(os.path.join("java","test")) != -1 and args.find("ipv6") != -1: - print "%s*** test not supported under windows%s" % (prefix, suffix) + print("%s*** test not supported under windows%s" % (prefix, suffix)) continue # Skip tests not supported by valgrind if args.find("valgrind") != -1 and ("novalgrind" in config or args.find("ssl") != -1): - print "%s*** test not supported with valgrind%s" % (prefix, suffix) + print("%s*** test not supported with valgrind%s" % (prefix, suffix)) continue - + # Skip tests not supported by appverifier if args.find("appverifier") != -1 and ("noappverifier" in config or args.find("ssl") != -1): - print "%s*** test not supported with appverifier%s" % (prefix, suffix) + print("%s*** test not supported with appverifier%s" % (prefix, suffix)) continue - + if script: - print "echo \"*** test started: `date`\"" - print "cd %s" % dir + print("echo \"*** test started: `date`\"") + print("cd %s" % dir) else: - print "*** test started:", time.strftime("%x %X") + print("*** test started: " + time.strftime("%x %X")) sys.stdout.flush() os.chdir(dir) global keepGoing if script: - print "if ! %s %s %s; then" % (sys.executable, os.path.join(dir, "run.py"), args) - print " echo 'test in %s failed'" % os.path.abspath(dir) + print("if ! %s %s %s; then" % (sys.executable, os.path.join(dir, "run.py"), args)) + print(" echo 'test in %s failed'" % os.path.abspath(dir)) if not keepGoing: - print " exit 1" - print "fi" + print(" exit 1") + print("fi") else: status = os.system(sys.executable + " " + quoteArgument(os.path.join(dir, "run.py")) + " " + args) if status: if(num > 0): - print "[" + str(num) + "]", + sys.stdout.write("[" + str(num) + "] ") message = "test in " + os.path.abspath(dir) + " failed with exit status", status, - print message + print(message) if not keepGoing: sys.exit(status) else: - print " ** Error logged and will be displayed again when suite is completed **" + print(" ** Error logged and will be displayed again when suite is completed **") global testErrors testErrors.append(message) -if os.environ.has_key("ICE_CONFIG"): +if "ICE_CONFIG" in os.environ: os.unsetenv("ICE_CONFIG") import inspect |