Changeset 2420 for pykota/trunk/bin/pkturnkey
- Timestamp:
- 09/03/05 15:48:56 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkturnkey
r2419 r2420 47 47 -h | --help Prints this message then exits. 48 48 49 -d | --dryrun Doesn't modify the database at all, but instead prints 50 what it would do. 51 49 52 -u | --uidmin uid Only adds users whose uid is greater than or equal to 50 53 uid. You can pass an username there as well, and its … … 87 90 return [entry[0] for entry in pwd.getpwall() if uidmin <= entry[2] <= uidmax] 88 91 89 def createPrinters(self, printers) : 92 def runCommand(self, command, dryrun) : 93 """Launches an external command.""" 94 if dryrun : 95 self.printInfo("%s" % command) 96 else : 97 self.logdebug("%s" % command) 98 os.system(command) 99 100 def createPrinters(self, printers, dryrun=0) : 90 101 """Creates all printers in PyKota's database.""" 91 needswarning = [p[0] for p in printers if p[1].find("cupspykota") == -1] 92 command = "pkprinters --add %s" % " ".join(['"%s"' % p[0] for p in printers]) 93 self.logdebug("Launching : %s" % command) 94 os.system(command) 95 96 def createUsers(self, users) : 102 if printers : 103 needswarning = [p[0] for p in printers if p[1].find("cupspykota") == -1] 104 command = "pkprinters --add %s" % " ".join(['"%s"' % p[0] for p in printers]) 105 self.runCommand(command, dryrun) 106 for p in needswarning : 107 self.printInfo(_("Printer %s is not managed by PyKota yet. Please modify printers.conf and restart CUPS.") % p, "warn") 108 109 def createUsers(self, users, dryrun=0) : 97 110 """Creates all users in PyKota's database.""" 98 command = "edpykota --add --noquota %s" % " ".join(['"%s"' % u for u in users])99 self.logdebug("Launching : %s" % command)100 os.system(command)111 if users : 112 command = "edpykota --add --noquota %s" % " ".join(['"%s"' % u for u in users]) 113 self.runCommand(command, dryrun) 101 114 102 115 def main(self, names, options) : … … 137 150 printers = self.listPrinters() 138 151 139 print "Please be patient...", 140 sys.stdout.flush() 141 self.createPrinters(printers) 142 self.createUsers(users) 143 print 152 print "Please be patient..." 153 154 if printers : 155 self.createPrinters(printers, options["dryrun"]) 156 self.createUsers(users, options["dryrun"]) 157 144 158 print "Database initialized." 145 159 … … 148 162 retcode = 0 149 163 try : 150 short_options = "hv u:U:"151 long_options = ["help", "version", " uidmin=", "uidmax="]164 short_options = "hvdu:U:" 165 long_options = ["help", "version", "dryrun", "uidmin=", "uidmax="] 152 166 153 167 # Initializes the command line tool … … 164 178 options["help"] = options["h"] or options["help"] 165 179 options["version"] = options["v"] or options["version"] 180 options["dryrun"] = options["d"] or options["dryrun"] 166 181 options["uidmin"] = options["u"] or options["uidmin"] 167 182 options["uidmax"] = options["U"] or options["uidmax"]