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