- Timestamp:
- 02/21/06 14:26:07 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/tests/filldb.py
r2706 r2729 27 27 os.system('pkbcodes --arguments arguments.list') 28 28 showTiming(number, before) 29 return billingcodes 29 30 30 def deleteBillingCodes( number) :31 def deleteBillingCodes(billingcodes) : 31 32 """Deletes all test billing codes.""" 32 33 sys.stdout.write("Deleting billing codes...\n") 34 argsfile = open("arguments.list", "w") 35 argsfile.write('--delete\n') 36 for bname in billingcodes : 37 argsfile.write("%s\n" % bname) 38 argsfile.close() 33 39 before = time.time() 34 os.system('pkbcodes -- delete "test-billingcode-*"')35 showTiming( number, before)40 os.system('pkbcodes --arguments arguments.list') 41 showTiming(len(billingcodes), before) 36 42 37 43 def createPrinters(number) : … … 47 53 os.system('pkprinters --arguments arguments.list') 48 54 showTiming(number, before) 55 return printernames 49 56 50 def deletePrinters( number) :57 def deletePrinters(printernames) : 51 58 """Deletes all test printers.""" 52 59 sys.stdout.write("Deleting printers...\n") 60 argsfile = open("arguments.list", "w") 61 argsfile.write('--delete\n') 62 for pname in printernames : 63 argsfile.write("%s\n" % pname) 64 argsfile.close() 53 65 before = time.time() 54 os.system('pkprinters -- delete "test-printer-*"')55 showTiming( number, before)66 os.system('pkprinters --arguments arguments.list') 67 showTiming(len(printernames), before) 56 68 57 69 def createUsers(number) : … … 67 79 os.system('pkusers --arguments arguments.list') 68 80 showTiming(number, before) 81 return usernames 69 82 70 def deleteUsers( number) :83 def deleteUsers(usernames) : 71 84 """Deletes all test users.""" 72 85 sys.stdout.write("Deleting users...\n") 86 argsfile = open("arguments.list", "w") 87 argsfile.write('--delete\n') 88 for uname in usernames : 89 argsfile.write("%s\n" % uname) 90 argsfile.close() 73 91 before = time.time() 74 os.system('pkusers --delete "test-user-*"') 92 os.system('pkusers --arguments arguments.list') 93 showTiming(len(usernames), before) 94 95 def createUserPQuotas(usernames, printernames) : 96 """Creates a number of user print quota entries.""" 97 number = len(usernames) * len(printernames) 98 sys.stdout.write("Adding %i user print quota entries...\n" % number) 99 argsfile = open("arguments.list", "w") 100 argsfile.write('--add\n--softlimit\n100\n--hardlimit\n110\n--reset\n--hardreset\n--printer\n') 101 argsfile.write("%s\n" % ",".join(printernames)) 102 for uname in usernames : 103 argsfile.write("%s\n" % uname) 104 argsfile.close() 105 before = time.time() 106 os.system('edpykota --arguments arguments.list') 75 107 showTiming(number, before) 108 109 def deleteUserPQuotas(usernames, printernames) : 110 """Deletes all test user print quota entries.""" 111 number = len(usernames) * len(printernames) 112 sys.stdout.write("Deleting user print quota entries...\n") 113 argsfile = open("arguments.list", "w") 114 argsfile.write('--delete\n--printer\n') 115 argsfile.write("%s\n" % ",".join(printernames)) 116 for uname in usernames : 117 argsfile.write("%s\n" % uname) 118 argsfile.close() 119 before = time.time() 120 os.system('edpykota --arguments arguments.list') 121 showTiming(len(usernames), before) 76 122 77 123 if __name__ == "__main__" : … … 83 129 nbusers = int(sys.argv[3]) 84 130 if nbbillingcodes : 85 createBillingCodes(nbbillingcodes)131 bcodes = createBillingCodes(nbbillingcodes) 86 132 if nbprinters : 87 createPrinters(nbprinters)133 printers = createPrinters(nbprinters) 88 134 if nbusers : 89 createUsers(nbusers) 90 if nbbillingcodes : 91 deleteBillingCodes(nbbillingcodes) 92 if nbusers : 93 deleteUsers(nbusers) # NB : either this one or the one below 94 if nbprinters : 95 deletePrinters(nbprinters) # also delete user print quota entries. 135 users = createUsers(nbusers) 136 137 if users and printers : 138 createUserPQuotas(users, printers) 139 deleteUserPQuotas(users, printers) 140 141 if bcodes : 142 deleteBillingCodes(bcodes) 143 if users : 144 deleteUsers(users) # NB : either this one or the one below 145 if printers : 146 deletePrinters(printers) # also delete user print quota entries. 96 147 os.remove("arguments.list") 97 148