248 | | (label, varname, varvalue) = arg.split(":", 2) |
249 | | except ValueError : |
250 | | raise PyKotaCommandLineError, "argument '%s' is invalid !" % arg |
251 | | labels.append(self.sanitizeMessage(label)) |
252 | | varname = varname.lower() |
253 | | varnames.append(varname) |
254 | | varvalues[varname] = self.sanitizeMessage(varvalue) |
| 239 | denyafter = int(options["denyafter"]) |
| 240 | if denyafter < 1 : |
| 241 | raise ValueError |
| 242 | except (ValueError, TypeError) : |
| 243 | denyafter = 1 |
| 244 | labels = [] |
| 245 | varnames = [] |
| 246 | varvalues = {} |
| 247 | for arg in arguments : |
| 248 | try : |
| 249 | (label, varname, varvalue) = arg.split(":", 2) |
| 250 | except ValueError : |
| 251 | raise PyKotaCommandLineError, "argument '%s' is invalid !" % arg |
| 252 | labels.append(self.sanitizeMessage(label)) |
| 253 | varname = varname.lower() |
| 254 | varnames.append(varname) |
| 255 | varvalues[varname] = self.sanitizeMessage(varvalue) |
| 256 | |
| 257 | passnumber = 1 |
| 258 | authok = None |
| 259 | while (authok != "AUTH=YES") and (passnumber <= denyafter) : |
| 260 | result = server.askDatas(labels, varnames, varvalues) |
| 261 | if not options["checkauth"] : |
| 262 | break |
| 263 | if result["isValid"] : |
| 264 | if ("username" in varnames) and ("password" in varnames) : |
| 265 | if self.checkAuth(self.UTF8ToUserCharset(result["username"].data[:]), |
| 266 | self.UTF8ToUserCharset(result["password"].data[:])) : |
| 267 | authok = "AUTH=YES" |
| 268 | else : |
| 269 | authok = "AUTH=NO" |
| 270 | else : |
| 271 | authok = "AUTH=IMPOSSIBLE" |
| 272 | passnumber += 1 |
| 273 | |
| 274 | if options["checkauth"] and options["denyafter"] \ |
| 275 | and (passnumber > denyafter) \ |
| 276 | and (authok != "AUTH=YES") : |
| 277 | print "DENY" |
| 278 | if result["isValid"] : |
| 279 | for varname in varnames : |
| 280 | if (varname != "password") \ |
| 281 | and ((varname != "username") or (authok in (None, "AUTH=YES"))) : |
| 282 | print "%s=%s" % (varname.upper(), self.UTF8ToUserCharset(result[varname].data[:])) |
| 283 | if authok is not None : |
| 284 | print authok |
| 285 | elif options["confirm"] : |
| 286 | print server.showDialog(self.sanitizeMessage(arguments[0]), True) |
| 287 | elif options["notify"] : |
| 288 | print server.showDialog(self.sanitizeMessage(arguments[0]), False) |
256 | | passnumber = 1 |
257 | | authok = None |
258 | | while (authok != "AUTH=YES") and (passnumber <= denyafter) : |
259 | | result = server.askDatas(labels, varnames, varvalues) |
260 | | if not options["checkauth"] : |
261 | | break |
262 | | if result["isValid"] : |
263 | | if ("username" in varnames) and ("password" in varnames) : |
264 | | if self.checkAuth(self.UTF8ToUserCharset(result["username"].data[:]), |
265 | | self.UTF8ToUserCharset(result["password"].data[:])) : |
266 | | authok = "AUTH=YES" |
267 | | else : |
268 | | authok = "AUTH=NO" |
269 | | else : |
270 | | authok = "AUTH=IMPOSSIBLE" |
271 | | passnumber += 1 |
272 | | |
273 | | if options["checkauth"] and options["denyafter"] \ |
274 | | and (passnumber > denyafter) \ |
275 | | and (authok != "AUTH=YES") : |
276 | | print "DENY" |
277 | | if result["isValid"] : |
278 | | for varname in varnames : |
279 | | if (varname != "password") \ |
280 | | and ((varname != "username") or (authok in (None, "AUTH=YES"))) : |
281 | | print "%s=%s" % (varname.upper(), self.UTF8ToUserCharset(result[varname].data[:])) |
282 | | if authok is not None : |
283 | | print authok |
284 | | elif options["confirm"] : |
285 | | print server.showDialog(self.sanitizeMessage(arguments[0]), True) |
286 | | elif options["notify"] : |
287 | | print server.showDialog(self.sanitizeMessage(arguments[0]), False) |
288 | | |
289 | | if options["quit"] : |
290 | | server.quitApplication() |
291 | | except (socket.error, socket.gaierror), msg : |
292 | | print options["noremote"] |
293 | | try : |
294 | | errnum = msg.args[0] |
295 | | except (AttributeError, IndexError) : |
296 | | pass |
297 | | else : |
298 | | if errnum == errno.ECONNREFUSED : |
299 | | raise PyKotaToolError, "%s : %s" % (str(msg), (_("Are you sure that PyKotIcon is running and accepting incoming connections on %s:%s ?") % (self.destination, self.port))) |
300 | | self.printInfo("%s : %s" % (_("Connection error"), str(msg)), "warn") |
301 | | except TimeoutError, msg : |
302 | | self.printInfo(msg, "warn") |
303 | | print "CANCEL" # Timeout occured : job is cancelled. |
304 | | |
305 | | if self.timeout : |
306 | | signal.alarm(0) |
| 290 | if options["quit"] : |
| 291 | server.quitApplication() |
| 292 | except (xmlrpclib.ProtocolError, socket.error, socket.gaierror), msg : |
| 293 | print options["noremote"] |
| 294 | #try : |
| 295 | # errnum = msg.args[0] |
| 296 | #except (AttributeError, IndexError) : |
| 297 | # pass |
| 298 | #else : |
| 299 | # if errnum == errno.ECONNREFUSED : |
| 300 | # raise PyKotaToolError, "%s : %s" % (str(msg), (_("Are you sure that PyKotIcon is running and accepting incoming connections on %s:%s ?") % (self.destination, self.port))) |
| 301 | self.printInfo("%s : %s" % (_("Connection error"), str(msg)), "warn") |
| 302 | except TimeoutError, msg : |
| 303 | self.printInfo(msg, "warn") |
| 304 | print "CANCEL" # Timeout occured : job is cancelled. |
| 305 | finally : |
| 306 | if self.timeout : |
| 307 | signal.alarm(0) |