diff options
Diffstat (limited to 'demoscript/Freeze')
-rwxr-xr-x | demoscript/Freeze/bench.py | 52 | ||||
-rwxr-xr-x | demoscript/Freeze/casino.py | 24 | ||||
-rwxr-xr-x | demoscript/Freeze/library.py | 26 | ||||
-rwxr-xr-x | demoscript/Freeze/phonebook.py | 10 | ||||
-rwxr-xr-x | demoscript/Freeze/transform.py | 34 |
5 files changed, 76 insertions, 70 deletions
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") |