Changeset 2466 for pykota/trunk/bin
- Timestamp:
- 09/19/05 19:26:41 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkturnkey
r2435 r2466 41 41 command line usage : 42 42 43 pkturnkey [options] 43 pkturnkey [options] [printqueues names] 44 44 45 45 options : … … 92 92 To REALLY initialize the database instead of simulating it, please 93 93 use the -f | --force command line switch. 94 95 You can limit the initialization to only a subset of the existing 96 printers, by passing their names at the end of the command line. 94 97 """) 95 98 96 99 class PKTurnKey(Tool) : 97 100 """A class for an initialization tool.""" 98 def listPrinters(self ) :101 def listPrinters(self, namestomatch) : 99 102 """Returns a list of tuples (queuename, deviceuri) for all existing print queues.""" 100 103 self.printInfo("Extracting all print queues.") … … 107 110 deviceuri = end.strip() 108 111 queuename = begin.split()[-1] 109 printers.append((queuename, deviceuri)) 112 if self.matchString(queuename, namestomatch) : 113 printers.append((queuename, deviceuri)) 114 else : 115 self.printInfo("Print queue %s skipped." % queuename) 110 116 return printers 111 117 … … 160 166 self.printInfo(_("Printer %s is not managed by PyKota yet. Please modify printers.conf and restart CUPS.") % p, "warn") 161 167 162 def createUsers(self, users, dryrun=0) :168 def createUsers(self, users, printers, dryrun=0) : 163 169 """Creates all users in PyKota's database.""" 164 170 if users : 165 command = "edpykota --add --noquota %s" % " ".join(['"%s"' % u for u in users]) 171 printersnames = [p[0] for p in printers] 172 command = "edpykota --add --noquota --printer %s %s" % (",".join(['"%s"' % p for p in printersnames]), \ 173 " ".join(['"%s"' % u for u in users])) 166 174 self.runCommand(command, dryrun) 167 175 168 def createGroups(self, groups, dryrun=0) :176 def createGroups(self, groups, printers, dryrun=0) : 169 177 """Creates all groups in PyKota's database.""" 170 178 if groups : 171 commands = ["edpykota --groups --add --noquota %s" % " ".join(['"%s"' % g for g in groups.keys()])] 179 printersnames = [p[0] for p in printers] 180 commands = ["edpykota --add --groups --noquota --printer %s %s" % (",".join(['"%s"' % p for p in printersnames]), \ 181 " ".join(['"%s"' % g for g in groups.keys()]))] 172 182 revmembership = {} 173 183 for (groupname, usernames) in groups.items() : … … 184 194 raise PyKotaToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 185 195 186 # TODO : names not used for now187 196 if not names : 188 197 names = ["*"] … … 259 268 groups = [] 260 269 261 printers = self.listPrinters( )270 printers = self.listPrinters(names) 262 271 if printers : 263 272 self.createPrinters(printers, dryrun) 264 self.createUsers([entry[0] for entry in users], dryrun)265 self.createGroups(groups, dryrun)273 self.createUsers([entry[0] for entry in users], printers, dryrun) 274 self.createGroups(groups, printers, dryrun) 266 275 267 276 if dryrun :