Changeset 3075 for pykota/trunk/bin

Show
Ignore:
Timestamp:
11/28/06 22:28:36 (18 years ago)
Author:
jerome
Message:

Added the --noremote command line option to pknotify.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pknotify

    r2829 r3075  
    2727import sys 
    2828import socket 
     29import errno 
    2930import signal 
    3031import xmlrpclib 
     
    7879                             The default value of N is 1, meaning the job 
    7980                             is denied after the first unsuccessful try. 
     81                              
     82  -N | --noremote action     If it's impossible to connect to the remote 
     83                             PyKotIcon machine, do this action instead. 
     84                             Allowed actions are 'CONTINUE' and 'CANCEL',  
     85                             which will respectively allow the processing 
     86                             of the print job to continue, or the job to 
     87                             be cancelled. The default value is CANCEL. 
    8088                              
    8189  -n | --notify              Tells pknotify to send an informational message 
     
    121129examples :                     
    122130 
    123   pknotify -d client:7654 --confirm "This job costs :\n10 credits !" 
    124    
    125   Would display the cost of a print job and asks for confirmation. 
     131  pknotify -d client:7654 --noremote CONTINUE --confirm "This job costs 10 credits" 
     132   
     133  Would display the cost of the print job and asks for confirmation. 
     134  If the end user doesn't have PyKotIcon running and accepting connections 
     135  from the print server, PyKota will consider that the end user accepted 
     136  to print this job. 
    126137   
    127138  pknotify --destination $PYKOTAJOBORIGINATINGHOSTNAME:7654 \\ 
     
    279290                server.quitApplication() 
    280291        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                    self.printInfo(_("Are you sure that PyKotIcon is running and accepting incoming connections on %s:%s ?") % (self.destination, self.port), "error") 
    281300            raise PyKotaCommandLineError, "%s : %s" % (_("Connection error"), str(msg)) 
    282301        except TimeoutError, msg :     
     
    292311        defaults = { \ 
    293312                     "timeout" : 0, 
     313                     "noremote" : "CANCEL", 
    294314                   } 
    295         short_options = "vhd:acnqCD:t:" 
     315        short_options = "vhd:acnqCD:t:N:" 
    296316        long_options = ["help", "version", "destination=", "denyafter=", \ 
    297317                        "timeout=", "ask", "checkauth", "confirm", "notify", \ 
    298                         "quit" ] 
     318                        "quit", "noremote=" ] 
    299319         
    300320        # Initializes the command line tool 
     
    316336        options["denyafter"] = options["D"] or options["denyafter"] 
    317337        options["timeout"] = options["t"] or options["timeout"] or defaults["timeout"] 
     338        options["noremote"] = (options["N"] or options["noremote"] or defaults["noremote"]).upper() 
    318339         
    319340        if options["help"] : 
     
    329350             or not (options["quit"] or options["ask"] or options["confirm"] or options["notify"]) : 
    330351            raise PyKotaCommandLineError, _("some options are mandatory, see help.") 
     352        elif options["noremote"] not in ("CANCEL", "CONTINUE") : 
     353            raise PyKotaCommandLineError, _("incorrect value for the --noremote command line switch, see help.") 
    331354        elif (not args) and (not options["quit"]) : 
    332355            raise PyKotaCommandLineError, _("some options require arguments, see help.")