Changeset 2937 for pykota/trunk/bin
- Timestamp:
- 06/13/06 23:10:15 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkusers
r2829 r2937 54 54 55 55 -d | --delete Deletes users from the quota storage. 56 56 57 -e | --email addr Sets the email address for the users. 58 If the addr parameter begins with @, then 59 the username is prepended to addr to form 60 a valid email address. 61 57 62 -D | --description d Adds a textual description to users or groups. 58 63 … … 154 159 cost of each print job will be multiplied by zero before charging 155 160 his account. 161 162 $ pkusers --email @example.com 163 164 This will set the email address for each user to username@example.com 156 165 """) 157 166 … … 165 174 entry.setLimitBy(limitby) 166 175 if not groups : 167 if email : 168 entry.Email = email 176 if email is not None : # we allow "" to empty the field 177 if email.startswith("@") : 178 email = "%s%s" % (entry.Name, email) 179 if email and email.count('@') != 1 : 180 raise PyKotaCommandLineError, _("Invalid email address %s") % email 181 entry.setEmail(email) 169 182 if overcharge is not None : # NB : 0 is allowed ! 170 183 entry.setOverChargeFactor(overcharge) … … 279 292 description = options["description"] 280 293 if description : 281 description = options["description"].strip()294 description = description.strip() 282 295 283 296 comment = options["comment"] 284 297 if comment : 285 comment = options["comment"].strip() 298 comment = comment.strip() 299 email = options["email"] 300 if email : 301 email = email.strip() 286 302 skipexisting = options["skipexisting"] 287 303 groups = options["groups"] … … 294 310 percent.setSize(len(names)) 295 311 for ename in names : 296 email = None312 useremail = None 297 313 if not groups : 298 314 splitname = ename.split('/', 1) # username/email 299 315 if len(splitname) == 1 : 300 316 splitname.append("") 301 (ename, email) = splitname 302 if email and (email.count('@') != 1) : 303 raise PyKotaCommandLineError, _("Invalid email address %s") % email 317 (ename, useremail) = splitname 304 318 if self.isValidName(ename) : 305 319 reject = 0 … … 326 340 description, overcharge,\ 327 341 balance, balancevalue, \ 328 comment, email)342 comment, useremail or email) 329 343 oldentry = getattr(self.storage, "add%s" % suffix)(entry) 330 344 if oldentry is not None : … … 340 354 description, overcharge,\ 341 355 balance, balancevalue, \ 342 comment, email)356 comment, useremail or email) 343 357 oldentry.save() 344 358 if not groups : … … 359 373 self.modifyEntry(entry, groups, limitby, description, \ 360 374 overcharge, balance, balancevalue, \ 361 comment )375 comment, email) 362 376 self.manageUsersGroups(usersgroups, entry, remove) 363 377 entry.save() … … 378 392 "comment" : "", \ 379 393 } 380 short_options = "hvaD:dgl:rso:i:b:C:L "394 short_options = "hvaD:dgl:rso:i:b:C:Le:" 381 395 long_options = ["help", "version", "add", "description=", \ 382 396 "delete", "groups", "list", "remove", \ 383 "skipexisting", "overcharge=", \397 "skipexisting", "overcharge=", "email=", \ 384 398 "ingroups=", "limitby=", "balance=", "comment=", \ 385 399 ] … … 408 422 options["overcharge"] = options["o"] or options["overcharge"] 409 423 options["comment"] = options["C"] or options["comment"] or defaults["comment"] 424 options["email"] = options["e"] or options["email"] 410 425 411 426 if options["help"] : … … 413 428 elif options["version"] : 414 429 manager.display_version_and_quit() 415 elif (options["delete"] and (options["add"] or options["remove"] or options["description"] )) \430 elif (options["delete"] and (options["add"] or options["remove"] or options["description"] or options["email"])) \ 416 431 or (options["skipexisting"] and not options["add"]) \ 417 or (options["list"] and (options["add"] or options["delete"] or options["remove"] or options["description"] )) \432 or (options["list"] and (options["add"] or options["delete"] or options["remove"] or options["description"] or options["email"])) \ 418 433 or (options["groups"] and (options["balance"] or options["ingroups"] or options["overcharge"])) : 419 434 raise PyKotaCommandLineError, _("incompatible options, see help.")