Changeset 2432
- Timestamp:
- 09/08/05 20:56:44 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkturnkey
r2420 r2432 47 47 -h | --help Prints this message then exits. 48 48 49 - d | --dryrun Doesn't modify the database at all, but instead prints50 whatit would do.49 -f | --force Modifies the database instead of printing what 50 it would do. 51 51 52 52 -u | --uidmin uid Only adds users whose uid is greater than or equal to … … 64 64 $ pkturnkey --uidmin jerome 65 65 66 Will initialize PyKota's database will all existing printers and 67 create print accounts for all users whose uid is greater than or 68 equal to jerome's one. 66 Will simulate the initialization of PyKota's database will all existing 67 printers and print accounts for all users whose uid is greater than 68 or equal to jerome's one. 69 To REALLY initialize the database instead of simulating it, please 70 use the -f | --force command line switch. 69 71 """) 70 72 … … 73 75 def listPrinters(self) : 74 76 """Returns a list of tuples (queuename, deviceuri) for all existing print queues.""" 75 self. logdebug("Extracting all print queues.")77 self.printInfo("Extracting all print queues.") 76 78 result = os.popen("lpstat -v", "r") 77 79 lines = result.readlines() … … 87 89 def listUsers(self, uidmin, uidmax) : 88 90 """Returns a list of usernames whose uids are between uidmin and uidmax.""" 89 self. logdebug("Extracting all users whose uid is between %s and %s." % (uidmin, uidmax))91 self.printInfo("Extracting all users whose uid is between %s and %s." % (uidmin, uidmax)) 90 92 return [entry[0] for entry in pwd.getpwall() if uidmin <= entry[2] <= uidmax] 91 93 92 94 def runCommand(self, command, dryrun) : 93 95 """Launches an external command.""" 94 if dryrun : 95 self.printInfo("%s" % command) 96 else : 97 self.logdebug("%s" % command) 96 self.printInfo("%s" % command) 97 if not dryrun : 98 98 os.system(command) 99 99 … … 121 121 if not names : 122 122 names = ["*"] 123 124 self.printInfo("Please be patient...") 125 dryrun = not options["force"] 126 if dryrun : 127 self.printInfo("Don't worry, the database WILL NOT BE MODIFIED.") 128 else : 129 self.printInfo("Please WORRY NOW, the database WILL BE MODIFIED.") 123 130 124 131 if not options["uidmin"] : … … 144 151 except KeyError, msg : 145 152 raise PyKotaToolError, _("Unknown username %s : %s") % (options["uidmax"], msg) 146 153 147 154 if uidmin > uidmax : 148 155 (uidmin, uidmax) = (uidmax, uidmin) … … 150 157 printers = self.listPrinters() 151 158 152 print "Please be patient..."153 154 159 if printers : 155 self.createPrinters(printers, options["dryrun"]) 156 self.createUsers(users, options["dryrun"]) 157 158 print "Database initialized." 160 self.createPrinters(printers, dryrun) 161 self.createUsers(users, dryrun) 162 163 if dryrun : 164 self.printInfo("Simulation terminated.") 165 else : 166 self.printInfo("Database initialized !") 159 167 160 168 … … 162 170 retcode = 0 163 171 try : 164 short_options = "hv du:U:"165 long_options = ["help", "version", " dryrun", "uidmin=", "uidmax="]172 short_options = "hvfu:U:" 173 long_options = ["help", "version", "force", "uidmin=", "uidmax="] 166 174 167 175 # Initializes the command line tool … … 178 186 options["help"] = options["h"] or options["help"] 179 187 options["version"] = options["v"] or options["version"] 180 options[" dryrun"] = options["d"] or options["dryrun"]188 options["force"] = options["f"] or options["force"] 181 189 options["uidmin"] = options["u"] or options["uidmin"] 182 190 options["uidmax"] = options["U"] or options["uidmax"] -
pykota/trunk/NEWS
r2425 r2432 22 22 PyKota NEWS : 23 23 24 - 1.23alpha27 : 25 26 - Replaced the --dryrun command line option by the --force 27 command line option in pkturnkey, with exactly the opposite 28 effect (for security reasons). 29 24 30 - 1.23alpha26 : 25 31 -
pykota/trunk/pykota/version.py
r2425 r2432 22 22 # 23 23 24 __version__ = "1.23alpha2 6_unofficial"24 __version__ = "1.23alpha27_unofficial" 25 25 26 26 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."