Changeset 1606 for pykota/trunk/bin

Show
Ignore:
Timestamp:
07/21/04 00:19:45 (20 years ago)
Author:
jalet
Message:

Sanitized a bit + use of gettext

Location:
pykota/trunk/bin
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1600 r1606  
    2424# 
    2525# $Log$ 
     26# Revision 1.68  2004/07/20 22:19:44  jalet 
     27# Sanitized a bit + use of gettext 
     28# 
    2629# Revision 1.67  2004/07/16 12:22:45  jalet 
    2730# LPRng support early version 
     
    348351            pagelog.close()         
    349352            if matchingline is None : 
    350                 self.logdebug("No matching line found in page_log") 
     353                self.logdebug("No matching line found in %s" % pagelogpath) 
    351354                return # correct line not found, job-originating-hostname unknown 
    352355            else :     
     
    376379                self.softwareJobSize = self.precomputeJobSize() 
    377380                self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize) 
    378                 self.sendBackChannelData("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
     381                self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
    379382            os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize) 
    380383            os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice) 
    381              
    382             # checks the user's quota 
    383             action = self.warnUserPQuota(userpquota) 
    384384             
    385385            # if no data to pass to real backend, probably a filter 
     
    389389                self.printInfo(_("Job contains no data. Printing is denied."), "warn") 
    390390                action = "DENY" 
     391            else :     
     392                # checks the user's quota 
     393                action = self.warnUserPQuota(userpquota) 
    391394             
    392395            # exports some new environment variables 
     
    396399            self.prehook(userpquota) 
    397400             
    398             self.sendBackChannelData("Job accounting begins.") 
     401            self.printInfo(_("Job accounting begins.")) 
    399402            self.accounter.beginJob(userpquota) 
    400403        else :     
     
    417420            # stops accounting.  
    418421            self.accounter.endJob(userpquota) 
    419             self.sendBackChannelData("Job accounting ends.") 
     422            self.printInfo(_("Job accounting ends.")) 
    420423                 
    421424            # retrieve the job size     
    422425            if action == "DENY" : 
    423426                jobsize = 0 
    424                 self.sendBackChannelData("Job size forced to 0 because printing is denied.") 
     427                self.printInfo(_("Job size forced to 0 because printing is denied.")) 
    425428            else :     
    426429                jobsize = self.accounter.getJobSize() 
    427             self.sendBackChannelData("Job size : %i" % jobsize) 
     430            self.printInfo(_("Job size : %i") % jobsize) 
    428431             
    429432            # update the quota for the current user on this printer  
    430             self.sendBackChannelData("Updating user %s's quota on printer %s" % (user.Name, printer.Name)) 
     433            self.printInfo(_("Updating user %s's quota on printer %s") % (user.Name, printer.Name)) 
    431434            jobprice = userpquota.increasePagesUsage(jobsize) 
    432435             
    433436            # adds the current job to history     
    434437            printer.addJobToHistory(self.jobid, user, self.accounter.getLastPageCounter(), action, jobsize, jobprice, self.preserveinputfile, self.title, self.copies, self.options, clienthost, self.jobSizeBytes) 
    435             self.sendBackChannelData("Job added to history.") 
     438            self.printInfo(_("Job added to history.")) 
    436439             
    437440            # exports some new environment variables 
     
    481484         
    482485        # And launch it 
    483         self.sendBackChannelData("Starting real backend %s with args %s" % (realbackend, " ".join(['"%s"' % a for a in ([os.environ["DEVICE_URI"]] + sys.argv[1:])]))) 
     486        self.logdebug("Starting real backend %s with args %s" % (realbackend, " ".join(['"%s"' % a for a in ([os.environ["DEVICE_URI"]] + sys.argv[1:])]))) 
    484487        subprocess = PyKotaPopen4([realbackend] + sys.argv[1:], bufsize=0, arg0=os.environ["DEVICE_URI"]) 
    485488         
     
    511514            # job's data is in a file, no need to pass the data 
    512515            # to the real backend 
    513             self.sendBackChannelData("Job's data is in %s" % self.preserveinputfile) 
     516            self.logdebug("Job's data is in %s" % self.preserveinputfile) 
    514517            infno = None 
    515518            endinput = 1 
    516519         
    517         self.sendBackChannelData("Entering streams polling loop...") 
     520        self.logdebug("Entering streams polling loop...") 
    518521        MEGABYTE = 1024*1024 
    519522        killed = 0 
     
    531534                    self.logdebug("Error while sending signal to pid %s : %s" % (subprocess.pid, msg)) 
    532535                else :     
    533                     self.sendBackChannelData(_("SIGTERM was sent to real backend %s (pid: %s)") % (realbackend, subprocess.pid)) 
     536                    self.printInfo(_("SIGTERM was sent to real backend %s (pid: %s)") % (realbackend, subprocess.pid)) 
    534537                    killed = 1 
    535538             
     
    541544                availablefds = [] 
    542545            if not availablefds : 
    543                 self.sendBackChannelData("Nothing to do, sleeping a bit...") 
     546                self.logdebug("Nothing to do, sleeping a bit...") 
    544547                time.sleep(0.01) # give some time to the system 
    545548            else : 
     
    558561                                        indata = "" 
    559562                                else :         
    560                                     self.sendBackChannelData("No data to send to real backend yet, sleeping a bit...") 
     563                                    self.logdebug("No data to send to real backend yet, sleeping a bit...") 
    561564                                    time.sleep(0.01) 
    562565                                     
    563566                                if endinput :     
    564567                                    self.unregisterFileNo(pollster, tocfno)         
    565                                     self.sendBackChannelData("Closing real backend's stdin.") 
     568                                    self.logdebug("Closing real backend's stdin.") 
    566569                                    os.close(tocfno) 
    567570                                    inputclosed = 1 
     
    595598                                    if not data :    # If yes, then no more input data 
    596599                                        self.unregisterFileNo(pollster, infno) 
    597                                         self.sendBackChannelData("Input data ends.") 
     600                                        self.logdebug("Input data ends.") 
    598601                                        endinput = 1 # this happens with real files. 
    599602                                    else :     
     
    601604                                elif fd == fromcfno : 
    602605                                    if not data : 
    603                                         self.sendBackChannelData("No back channel data to read from real backend yet, sleeping a bit...") 
     606                                        self.logdebug("No back channel data to read from real backend yet, sleeping a bit...") 
    604607                                        time.sleep(0.01) 
    605608                                    else : 
     
    616619                                # Here we are in the case where the input file is stdin. 
    617620                                # which has no more data to be read. 
    618                                 self.sendBackChannelData("Input data ends.") 
     621                                self.logdebug("Input data ends.") 
    619622                                endinput = 1 
    620623                            elif fd == fromcfno :     
    621624                                # We are no more interested in this file descriptor         
    622                                 self.sendBackChannelData("Closing real backend's stdout+stderr.") 
     625                                self.logdebug("Closing real backend's stdout+stderr.") 
    623626                                os.close(fromcfno) 
    624627                                endoutput = 1 
     
    628631                                 
    629632                        if mask & select.POLLNVAL :         
    630                             self.sendBackChannelData("File %s was closed. Unregistering from polling object." % fd) 
     633                            self.logdebug("File %s was closed. Unregistering from polling object." % fd) 
    631634                            self.unregisterFileNo(pollster, fd) 
    632635                    except IOError, msg :             
     
    635638        # We must close the real backend's input stream 
    636639        if killed and not inputclosed : 
    637             self.sendBackChannelData("Forcing close of real backend's stdin.") 
     640            self.logdebug("Forcing close of real backend's stdin.") 
    638641            os.close(tocfno) 
    639642         
    640         self.sendBackChannelData("Exiting streams polling loop...") 
     643        self.logdebug("Exiting streams polling loop...") 
    641644         
    642645        # Check exit code of original CUPS backend.     
     
    644647            # we exited the loop before the real backend exited 
    645648            # now we have to wait for it to finish and get its status 
    646             self.sendBackChannelData("Waiting for real backend to exit...") 
     649            self.logdebug("Waiting for real backend to exit...") 
    647650            try : 
    648651                status = subprocess.wait() 
     
    652655            retcode = os.WEXITSTATUS(status) 
    653656        elif not killed :     
    654             self.printInfo(_("CUPS backend %s died abnormally.") % realbackend, "error") 
     657            self.sendBackChannelData(_("CUPS backend %s died abnormally.") % realbackend, "error") 
    655658            retcode = -1 
    656659        else :     
  • pykota/trunk/bin/pkhint

    r1584 r1606  
    2424# 
    2525# $Log$ 
     26# Revision 1.15  2004/07/20 22:19:45  jalet 
     27# Sanitized a bit + use of gettext 
     28# 
    2629# Revision 1.14  2004/07/01 19:56:40  jalet 
    2730# Better dispatching of error messages 
     
    196199            (backend, destination) = device.split(":", 1)  
    197200        except ValueError :     
    198             raise PyKotaToolError, "Invalid DEVICE_URI : %s\n" % device 
     201            raise PyKotaToolError, _("Invalid DeviceURI : %s") % device 
    199202        while destination.startswith("/") : 
    200203            destination = destination[1:] 
     
    220223        """Main work is done here.""" 
    221224        sys.stderr.write("BEWARE : This tool doesn't support LPRng's printcap files yet.\n") 
    222         print "\nPlease wait while pkhint analyzes your printing system's configuration..." 
     225        print _("\nPlease wait while pkhint analyzes your printing system's configuration...") 
    223226        printers = self.extractPrintersInformation() 
    224227        devicestypes = self.extractDevices() # TODO : IT'S CUPS ONLY FOR NOW 
     
    254257            print "\nSorry, pkhint can't help you for now. Please configure PyKota manually." 
    255258        else : 
    256             print "\nPut the following lines into your /etc/pykota/pykota.conf file :\n" 
    257             print "# BEWARE : if software accounting is suggested, this doesn't mean" 
    258             print "# that hardware accounting wouldn't work, this only means that PyKota" 
    259             print "# wasn't able to autodetect which hardware accounting method to use." 
     259            print _("\nPut the following lines into your /etc/pykota/pykota.conf file :\n") 
     260            print _("# BEWARE : if software accounting is suggested, this doesn't mean") 
     261            print _("# that hardware accounting wouldn't work, this only means that PyKota") 
     262            print _("# wasn't able to autodetect which hardware accounting method to use.") 
    260263            for (printer, accounter) in configuration : 
    261264                print "[%s]" % printer 
  • pykota/trunk/bin/pykosd

    r1605 r1606  
    2424# 
    2525# $Log$ 
     26# Revision 1.5  2004/07/20 22:19:45  jalet 
     27# Sanitized a bit + use of gettext 
     28# 
    2629# Revision 1.4  2004/07/19 22:37:13  jalet 
    2730# pykosd is now a very good tool 
     
    101104            duration = int(options["duration"]) 
    102105        except :     
    103             raise PyKotaToolError, "Invalid duration option %s" % str(options["duration"]) 
     106            raise PyKotaToolError, _("Invalid duration option %s") % str(options["duration"]) 
    104107             
    105108        try :     
    106109            loop = int(options["loop"]) 
    107110        except :     
    108             raise PyKotaToolError, "Invalid loop option %s" % str(options["loop"]) 
     111            raise PyKotaToolError, _("Invalid loop option %s") % str(options["loop"]) 
    109112             
    110113        try :     
    111114            sleep = float(options["sleep"]) 
    112115        except :     
    113             raise PyKotaToolError, "Invalid sleep option %s" % str(options["sleep"]) 
     116            raise PyKotaToolError, _("Invalid sleep option %s") % str(options["sleep"]) 
    114117             
    115118        uid = os.geteuid() 
     
    118121            user = cmd.storage.getUserFromBackend(uname)        # don't use cache 
    119122            if not user.Exists : 
    120                 raise PyKotaToolError, "User %s doesn't exist in PyKota's database." % uname 
     123                raise PyKotaToolError, _("User %s doesn't exist in PyKota's database") % uname 
    121124            if user.LimitBy == "quota" :     
    122125                printers = cmd.storage.getMatchingPrinters("*")