| 47 | -d | --destination h[:p] Sets the destination hostname and optional |
| 48 | port onto which contact the remote PyKotIcon |
| 49 | application. This option is mandatory. |
| 50 | When not specified, the port defaults to 7654. |
| 51 | |
| 52 | -a | --ask Tells pknotify to ask something to the end |
| 53 | user. Then pknotify will output the result. |
| 54 | |
| 55 | -c | --confirm Tells pknotify to ask for either a confirmation |
| 56 | or abortion. |
| 57 | |
| 58 | -n | --notify Tells pknotify to send an informational message |
| 59 | message to the end user. |
| 60 | |
| 61 | -q | --quit Tells pknotify to send a message asking the |
| 62 | PyKotIcon application to exit. This option can |
| 63 | be combined with the other ones to make PyKotIcon |
| 64 | exit after having sent the answer from the dialog. |
| 65 | |
| 66 | You MUST specify either --ask, --confirm, --notify or --quit. |
| 67 | |
| 68 | arguments : |
| 69 | |
| 70 | -a | --ask : Several arguments are accepted, or the form |
| 71 | "label:varname:defaultvalue". The result will |
| 72 | be printed to stdout in the following format : |
| 73 | VAR1NAME=VAR1VALUE |
| 74 | VAR2NAME=VAR2VALUE |
| 75 | ... |
| 76 | If the dialog was cancelled, nothing will be |
| 77 | printed. If one of the varname is 'password' |
| 78 | then this field is asked as a password (you won't |
| 79 | see what you type in). |
| 80 | |
| 81 | -c | --confirm : A single argument is expected, representing the |
| 82 | message to display. If the dialog is confirmed |
| 83 | then pknotify will print OK, else CANCEL. |
| 84 | |
| 85 | -n | --notify : A single argument is expected, representing the |
| 86 | message to display. In this case pknotify will |
| 87 | always print OK. |
| 88 | |
| 89 | examples : |
| 90 | |
| 91 | pknotify -d client:7654 --confirm "This job costs :\n10 credits !" |
| 92 | |
| 93 | would display the cost of a print job and asks for confirmation. |
52 | | pass # TODO : do something ! |
53 | | |
| 104 | try : |
| 105 | (destination, port) = options["destination"].split(":") |
| 106 | except ValueError : |
| 107 | destination = options["destination"] |
| 108 | port = 7654 |
| 109 | server = xmlrpclib.ServerProxy("http://%s:%s" % (destination, port)) |
| 110 | if options["ask"] : |
| 111 | labels = [] |
| 112 | varnames = [] |
| 113 | varvalues = {} |
| 114 | for arg in arguments : |
| 115 | try : |
| 116 | (label, varname, varvalue) = arg.split(":", 2) |
| 117 | except ValueError : |
| 118 | raise PyKotaCommandLineError, "argument '%s' is invalid !" % arg |
| 119 | labels.append(self.sanitizeMessage(label)) |
| 120 | varname = varname.lower() |
| 121 | varnames.append(varname) |
| 122 | varvalues[varname] = self.sanitizeMessage(varvalue) |
| 123 | result = server.askDatas(labels, varnames, varvalues) |
| 124 | if result["isValid"] : |
| 125 | for varname in varnames : |
| 126 | print "%s=%s" % (varname.upper(), result[varname]) |
| 127 | elif options["confirm"] : |
| 128 | print server.showDialog(self.sanitizeMessage(arguments[0]), True) |
| 129 | elif options["notify"] : |
| 130 | print server.showDialog(self.sanitizeMessage(arguments[0]), False) |
| 131 | |
| 132 | if options["quit"] : |
| 133 | server.quitApplication() |
| 134 | |
| 164 | elif (options["ask"] and (options["confirm"] or options["notify"])) \ |
| 165 | or (options["confirm"] and (options["ask"] or options["notify"])) \ |
| 166 | or (options["notify"] and (options["ask"] or options["confirm"])) : |
| 167 | raise PyKotaCommandLineError, _("incompatible options, see help.") |
| 168 | elif (not options["destination"]) \ |
| 169 | or not (options["quit"] or options["ask"] or options["confirm"] or options["notify"]) : |
| 170 | raise PyKotaCommandLineError, _("some options are mandatory, see help.") |
| 171 | elif (not args) and (not options["quit"]) : |
| 172 | raise PyKotaCommandLineError, _("some options require arguments, see help.") |