Changeset 3442
- Timestamp:
- 10/17/08 22:51:04 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pknotify
r3441 r3442 80 80 """Checks if we could authenticate an username with a password.""" 81 81 if not hasPAM : 82 raise PyKotaToolError, _("You MUST install PyPAM for this functionnality to work !")82 raise PyKotaToolError, "You MUST install PyPAM for this functionnality to work !" 83 83 else : 84 84 retcode = False … … 91 91 auth.authenticate() 92 92 auth.acct_mgmt() 93 except PAM.error, resp :94 self.printInfo(_("Authentication error for user % s : %s") % (username, resp), "warn")93 except PAM.error, response : 94 self.printInfo(_("Authentication error for user %(username)s : %(response)s") % locals(), "warn") 95 95 except : 96 self.printInfo(_("Internal error : can't authenticate user % s") % username, "error")96 self.printInfo(_("Internal error : can't authenticate user %(username)s") % locals(), "error") 97 97 else : 98 self.logdebug( _("Password correct for user %s")% username)98 self.logdebug("Entered password is correct for user %s" % username) 99 99 retcode = True 100 100 return retcode … … 107 107 """Notifies or asks questions to end users through PyKotIcon.""" 108 108 try : 109 (self.destination, self.port) = options ["destination"].split(":")109 (self.destination, self.port) = options.destination.split(":") 110 110 self.port = int(self.port) 111 111 except ValueError : 112 self.destination = options ["destination"]112 self.destination = options.destination 113 113 self.port = 7654 114 114 115 115 try : 116 denyafter = int(options["denyafter"]) 117 if denyafter < 1 : 118 raise ValueError 119 except (ValueError, TypeError) : 120 denyafter = 1 121 122 try : 123 self.timeout = int(options["timeout"]) 116 self.timeout = options.timeout 124 117 if self.timeout < 0 : 125 118 raise ValueError … … 134 127 try : 135 128 server = xmlrpclib.ServerProxy("http://%s:%s" % (self.destination, self.port)) 136 if options ["ask"]:129 if options.action == "ask" : 137 130 try : 138 denyafter = int(options["denyafter"]) 139 if denyafter < 1 : 131 if options.denyafter < 1 : 140 132 raise ValueError 141 133 except (ValueError, TypeError) : 142 denyafter = 1134 options.denyafter = 1 143 135 labels = [] 144 136 varnames = [] … … 156 148 passnumber = 1 157 149 authok = None 158 while (authok != "AUTH=YES") and (passnumber <= denyafter) :150 while (authok != "AUTH=YES") and (passnumber <= options.denyafter) : 159 151 result = server.askDatas(labels, varnames, varvalues) 160 if not options ["checkauth"]:152 if not options.checkauth : 161 153 break 162 154 if result["isValid"] : … … 171 163 passnumber += 1 172 164 173 if options ["checkauth"] and options["denyafter"]\174 and (passnumber > denyafter) \165 if options.checkauth and options.denyafter \ 166 and (passnumber > options.denyafter) \ 175 167 and (authok != "AUTH=YES") : 176 168 print "DENY" … … 182 174 if authok is not None : 183 175 print authok 184 elif options ["confirm"]:176 elif options.action == "confirm" : 185 177 print server.showDialog(self.sanitizeMessage(arguments[0]), True) 186 elif options ["notify"]:178 elif options.action == "notify" : 187 179 print server.showDialog(self.sanitizeMessage(arguments[0]), False) 188 180 189 if options ["quit"]:181 if options.quit : 190 182 server.quitApplication() 191 183 except (xmlrpclib.ProtocolError, socket.error, socket.gaierror), msg : 192 print options ["noremote"]184 print options.noremote 193 185 #try : 194 186 # errnum = msg.args[0]