Changeset 2745
- Timestamp:
- 02/21/06 23:51:52 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkturnkey
r2715 r2745 166 166 if printers : 167 167 needswarning = [p[0] for p in printers if p[1].find("cupspykota") == -1] 168 command = "pkprinters --add %s" % " ".join(['"%s"' % p[0] for p in printers]) 169 self.runCommand(command, dryrun) 168 args = open("/tmp/pkprinters.args", "w") 169 args.write('--add\n--skipexisting\n--description\n"printer created from pkturnkey"\n') 170 args.write("%s\n" % "\n".join(['"%s"' % p[0] for p in printers])) 171 args.close() 172 self.runCommand("pkprinters --arguments /tmp/pkprinters.args", dryrun) 170 173 for p in needswarning : 171 174 self.printInfo(_("Printer %s is not managed by PyKota yet. Please modify printers.conf and restart CUPS.") % p, "warn") … … 174 177 """Creates all users in PyKota's database.""" 175 178 if users : 179 args = open("/tmp/pkusers.users.args", "w") 180 args.write('--add\n--skipexisting\n--description\n"user created from pkturnkey"\n--limitby\nnoquota\n') 181 args.write("%s\n" % "\n".join(['"%s"' % u for u in users])) 182 args.close() 183 self.runCommand("pkusers --arguments /tmp/pkusers.users.args", dryrun) 184 176 185 printersnames = [p[0] for p in printers] 177 command = "edpykota --add --noquota --printer %s %s" \ 178 % (",".join(['"%s"' % p for p in printersnames]), \ 179 " ".join(['"%s"' % u for u in users])) 180 self.runCommand(command, dryrun) 186 args = open("/tmp/edpykota.users.args", "w") 187 args.write('--add\n--skipexisting\n--noquota\n--printer\n') 188 args.write("%s\n" % ",".join(['"%s"' % p for p in printersnames])) 189 args.write("%s\n" % "\n".join(['"%s"' % u for u in users])) 190 args.close() 191 self.runCommand("edpykota --arguments /tmp/edpykota.users.args", dryrun) 181 192 182 193 def createGroups(self, groups, printers, dryrun=0) : 183 194 """Creates all groups in PyKota's database.""" 184 195 if groups : 196 args = open("/tmp/pkusers.groups.args", "w") 197 args.write('--groups\n--add\n--skipexisting\n--description\n"group created from pkturnkey"\n--limitby\nnoquota\n') 198 args.write("%s\n" % "\n".join(['"%s"' % g for g in groups])) 199 args.close() 200 self.runCommand("pkusers --arguments /tmp/pkusers.groups.args", dryrun) 201 185 202 printersnames = [p[0] for p in printers] 186 commands = ["edpykota --add --groups --noquota --printer %s %s" \ 187 % (",".join(['"%s"' % p for p in printersnames]), \ 188 " ".join(['"%s"' % g for g in groups.keys()]))] 203 args = open("/tmp/edpykota.groups.args", "w") 204 args.write('--groups\n--add\n--skipexisting\n--noquota\n--printer\n') 205 args.write("%s\n" % ",".join(['"%s"' % p for p in printersnames])) 206 args.write("%s\n" % "\n".join(['"%s"' % g for g in groups])) 207 args.close() 208 self.runCommand("edpykota --arguments /tmp/edpykota.groups.args", dryrun) 209 189 210 revmembership = {} 190 211 for (groupname, usernames) in groups.items() : 191 212 for username in usernames : 192 213 revmembership.setdefault(username, []).append(groupname) 214 commands = [] 193 215 for (username, groupnames) in revmembership.items() : 194 commands.append(' edpykota--ingroups %s "%s"' \216 commands.append('pkusers --ingroups %s "%s"' \ 195 217 % (",".join(['"%s"' % g for g in groupnames]), username)) 196 218 for command in commands : … … 441 463 retcode = 0 442 464 try : 443 raise PyKotaCommandLineError, "This version is not stable, download an earlier one. Operation aborted."444 445 465 short_options = "hvdDefu:U:g:G:c" 446 466 long_options = ["help", "version", "dousers", "dogroups", \