Changeset 1584 for pykota/trunk/bin

Show
Ignore:
Timestamp:
07/01/04 21:56:43 (20 years ago)
Author:
jalet
Message:

Better dispatching of error messages

Location:
pykota/trunk/bin
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1562 r1584  
    2424# 
    2525# $Log$ 
     26# Revision 1.66  2004/07/01 19:56:25  jalet 
     27# Better dispatching of error messages 
     28# 
    2629# Revision 1.65  2004/06/22 09:31:17  jalet 
    2730# Always send some debug info to CUPS' back channel stream (stderr) as 
     
    381384            # we deny the job in this case (nothing to print anyway) 
    382385            if not self.jobSizeBytes : 
    383                 self.logger.log_message(_("Job contains no data. Printing is denied."), "warn") 
     386                self.printInfo(_("Job contains no data. Printing is denied."), "warn") 
    384387                action = "DENY" 
    385388             
     
    446449            pollobj.unregister(fileno) 
    447450        except KeyError :     
    448             self.logger.log_message(_("File number %s unregistered twice from polling object, ignored.") % fileno, "warn") 
     451            self.printInfo(_("File number %s unregistered twice from polling object, ignored.") % fileno, "warn") 
    449452        except :     
    450453            self.logdebug("Error while unregistering file number %s from polling object." % fileno) 
     
    471474    def sendBackChannelData(self, message) :     
    472475        """Sends an informational message to CUPS via back channel stream (stderr).""" 
    473         sys.stderr.write("INFO: PyKota (PID %s) : %s\n" % (os.getpid(), message.strip())) 
    474         sys.stderr.flush() 
     476        self.printInfo("PyKota (PID %s) : %s" % (os.getpid(), message.strip())) 
    475477         
    476478    def handleData(self) :                     
     
    651653            retcode = os.WEXITSTATUS(status) 
    652654        elif not killed :     
    653             self.logger.log_message(_("CUPS backend %s died abnormally.") % realbackend, "error") 
     655            self.printInfo(_("CUPS backend %s died abnormally.") % realbackend, "error") 
    654656            retcode = -1 
    655657        else :     
  • pykota/trunk/bin/edpykota

    r1546 r1584  
    2424# 
    2525# $Log$ 
     26# Revision 1.76  2004/07/01 19:56:40  jalet 
     27# Better dispatching of error messages 
     28# 
    2629# Revision 1.75  2004/06/18 13:34:47  jalet 
    2730# Now all tracebacks include PyKota's version number 
     
    463466            if (softlimit is not None) and (hardlimit is not None) and (hardlimit < softlimit) :         
    464467                # error, exchange them 
    465                 self.logger.log_message(_("Hard limit %i is less than soft limit %i, values will be exchanged.") % (hardlimit, softlimit)) 
     468                self.printInfo(_("Hard limit %i is less than soft limit %i, values will be exchanged.") % (hardlimit, softlimit)) 
    466469                (softlimit, hardlimit) = (hardlimit, softlimit) 
    467470             
     
    541544                    protoquota = getattr(self.storage, "get%sPQuota" % suffix)(protoentry, printer) 
    542545                    if not protoquota.Exists : 
    543                         self.logger.log_message(_("Prototype %s not found in Quota Storage for printer %s.") % (protoentry.Name, printer.Name)) 
     546                        self.printInfo(_("Prototype %s not found in Quota Storage for printer %s.") % (protoentry.Name, printer.Name)) 
    544547                        continue    # skip this printer 
    545548                    else :     
    546549                        (softlimit, hardlimit) = (protoquota.SoftLimit, protoquota.HardLimit) 
    547550                else :         
    548                     self.logger.log_message(_("Prototype object %s not found in Quota Storage.") % protoentry.Name) 
     551                    self.printInfo(_("Prototype object %s not found in Quota Storage.") % protoentry.Name) 
    549552                     
    550553            if not options["noquota"] :     
     
    552555                    hardlimit = softlimit 
    553556                    if hardlimit is not None : 
    554                         self.logger.log_message(_("Undefined hard limit set to soft limit (%s) on printer %s.") % (str(hardlimit), printer.Name)) 
     557                        self.printInfo(_("Undefined hard limit set to soft limit (%s) on printer %s.") % (str(hardlimit), printer.Name)) 
    555558                if softlimit is None :     
    556559                    softlimit = hardlimit 
    557560                    if softlimit is not None : 
    558                         self.logger.log_message(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer.Name)) 
     561                        self.printInfo(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer.Name)) 
    559562                         
    560563            if options["add"] :     
     
    568571                        (name, email) = splitname 
    569572                        if email and (email.count('@') != 1) : 
    570                             self.logger.log_message(_("Invalid email address %s") % email) 
     573                            self.printInfo(_("Invalid email address %s") % email) 
    571574                            email = "" 
    572575                    entry = getattr(self.storage, "get%s" % suffix)(name) 
     
    595598                        else :     
    596599                            if options["groups"] : 
    597                                 self.logger.log_message(_("Invalid group name %s") % entry.Name) 
     600                                self.printInfo(_("Invalid group name %s") % entry.Name) 
    598601                            else :     
    599                                 self.logger.log_message(_("Invalid user name %s") % entry.Name) 
     602                                self.printInfo(_("Invalid user name %s") % entry.Name) 
    600603                elif options["delete"] :                 
    601604                    todelete[entry.Name] = entry 
     
    607610                         
    608611                if not entrypquota.Exists :      
    609                     self.logger.log_message(_("Quota not found for object %s on printer %s.") % (entry.Name, printer.Name)) 
     612                    self.printInfo(_("Quota not found for object %s on printer %s.") % (entry.Name, printer.Name)) 
    610613                else :     
    611614                    if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 
     
    640643                                    changed[entry.Name]["ingroups"].append(groupname) 
    641644                                else : 
    642                                     self.logger.log_message(_("Group %s not found in the PyKota Storage.") % groupname) 
     645                                    self.printInfo(_("Group %s not found in the PyKota Storage.") % groupname) 
    643646                                     
    644647                    # This line disabled to prevent sending of unwanted email                  
  • pykota/trunk/bin/pkhint

    r1579 r1584  
    2424# 
    2525# $Log$ 
     26# Revision 1.14  2004/07/01 19:56:40  jalet 
     27# Better dispatching of error messages 
     28# 
    2629# Revision 1.13  2004/06/29 07:55:18  jalet 
    2730# Doesn't output the warning message when --help or --version is asked 
     
    226229                device = self.extractDeviceFromURI(deviceuri) 
    227230                if devicetype is None : 
    228                     sys.stderr.write("Unknown device %s for printer %s\n" % (device, printer)) 
     231                    self.printInfo(_("Unknown device %s for printer %s") % (device, printer)) 
    229232                elif devicetype == "network" : 
    230233                    try : 
     
    245248                        else :     
    246249                            configuration.append((printer, "software(/usr/bin/pkpgcounter)")) 
    247                 # elif devicetype == "direct" :  
    248                 #    sys.stderr.write("Can't currently handle device %s for printer %s\n" % (device, printer)) 
    249                 #elif devicetype == "serial" :  
    250                 #    sys.stderr.write("Can't currently handle device %s for printer %s\n" % (device, printer)) 
    251                 #else : 
    252                 #    sys.stderr.write("Can't currently handle device %s for printer %s\n" % (device, printer)) 
    253250                else : 
    254251                    configuration.append((printer, "software(/usr/bin/pkpgcounter)")) 
  • pykota/trunk/bin/pkprinters

    r1582 r1584  
    2424# 
    2525# $Log$ 
     26# Revision 1.13  2004/07/01 19:56:41  jalet 
     27# Better dispatching of error messages 
     28# 
    2629# Revision 1.12  2004/07/01 17:45:47  jalet 
    2730# Added code to handle the description field for printers 
     
    197200                if printer.Exists : 
    198201                    if options["skipexisting"] : 
    199                         self.printError(_("Printer %s already exists, skipping.") % printer.Name) 
     202                        self.printInfo(_("Printer %s already exists, skipping.") % printer.Name) 
    200203                    else :     
    201                         self.printError(_("Printer %s already exists, will be modified.") % printer.Name) 
     204                        self.printInfo(_("Printer %s already exists, will be modified.") % printer.Name) 
    202205                        printers.append(printer) 
    203206                else : 
  • pykota/trunk/bin/pykotme

    r1546 r1584  
    2424# 
    2525# $Log$ 
     26# Revision 1.13  2004/07/01 19:56:42  jalet 
     27# Better dispatching of error messages 
     28# 
    2629# Revision 1.12  2004/06/18 13:34:49  jalet 
    2730# Now all tracebacks include PyKota's version number 
     
    151154                totalsize += parser.getJobSize() 
    152155            except PDLAnalyzerError, msg :     
    153                 sys.stderr.write("%s\n" % msg) 
    154                 sys.stderr.flush() 
     156                self.printInfo(msg) 
    155157             
    156158        # get current user