Show
Ignore:
Timestamp:
09/27/08 22:02:37 (16 years ago)
Author:
jerome
Message:

Removed unnecessary spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/software.py

    r3411 r3413  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    3030 
    3131class Accounter(AccounterBase) : 
    32     def computeJobSize(self) :     
     32    def computeJobSize(self) : 
    3333        """Feeds an external command with our datas to let it compute the job size, and return its value.""" 
    3434        if (not self.isPreAccounter) and \ 
     
    3939            self.filter.logdebug("Precomputing pass told us that job is %s pages long." % self.filter.softwareJobSize) 
    4040            return self.filter.softwareJobSize   # Optimize : already computed ! 
    41              
     41 
    4242        if self.arguments : 
    4343            self.filter.logdebug("Using external script %s to compute job's size." % self.arguments) 
    4444            return self.withExternalScript() 
    45         else :     
     45        else : 
    4646            self.filter.logdebug("Using internal parser to compute job's size.") 
    4747            return self.withInternalParser() 
    48          
    49     def withInternalParser(self) :     
     48 
     49    def withInternalParser(self) : 
    5050        """Does software accounting through an external script.""" 
    5151        jobsize = 0 
     
    5353            try : 
    5454                from pkpgpdls import analyzer, pdlparser 
    55             except ImportError :     
     55            except ImportError : 
    5656                self.filter.printInfo("pkpgcounter is now distributed separately, please grab it from http://www.pykota.com/software/pkpgcounter", "error") 
    5757                self.filter.printInfo("Precomputed job size will be forced to 0 pages.", "error") 
    58             else :      
     58            else : 
    5959                try : 
    6060                    parser = analyzer.PDLAnalyzer(self.filter.DataFile) 
    6161                    jobsize = parser.getJobSize() 
    62                 except pdlparser.PDLParserError, msg :     
     62                except pdlparser.PDLParserError, msg : 
    6363                    # Here we just log the failure, but 
    6464                    # we finally ignore it and return 0 since this 
     
    6666                    # job's size MAY be. 
    6767                    self.filter.printInfo(_("Unable to precompute the job's size with the generic PDL analyzer : %s") % msg, "warn") 
    68                 else :     
     68                else : 
    6969                    try : 
    7070                        if self.filter.Ticket.FileName is not None : 
    71                             # when a filename is passed as an argument, the backend  
     71                            # when a filename is passed as an argument, the backend 
    7272                            # must generate the correct number of copies. 
    7373                            jobsize *= self.filter.Ticket.Copies 
    7474                    except AttributeError : # When not run from the cupspykota backend 
    7575                        pass 
    76         return jobsize         
    77                  
    78     def withExternalScript(self) :     
     76        return jobsize 
     77 
     78    def withExternalScript(self) : 
    7979        """Does software accounting through an external script.""" 
    8080        self.filter.logdebug(_("Launching SOFTWARE(%s)...") % self.arguments) 
     
    8383        try : 
    8484            answer = child.read() 
    85         except (IOError, OSError), msg :     
    86             msg = "%s : %s" % (self.arguments, msg)  
     85        except (IOError, OSError), msg : 
     86            msg = "%s : %s" % (self.arguments, msg) 
    8787            self.filter.printInfo(_("Unable to compute job size with accounter %s") % msg, "warn") 
    88         else :     
     88        else : 
    8989            lines = [l.strip() for l in answer.split("\n")] 
    90             for i in range(len(lines)) :  
     90            for i in range(len(lines)) : 
    9191                try : 
    9292                    pagecounter = int(lines[i]) 
    9393                except (AttributeError, ValueError) : 
    9494                    self.filter.logdebug(_("Line [%s] skipped in accounter's output. Trying again...") % lines[i]) 
    95                 else :     
     95                else : 
    9696                    break 
    97                      
     97 
    9898        status = child.close() 
    9999        try : 
    100100            if os.WIFEXITED(status) : 
    101101                status = os.WEXITSTATUS(status) 
    102         except TypeError :         
     102        except TypeError : 
    103103            pass # None means no error occured. 
    104104        self.filter.logdebug(_("Software accounter %s exit code is %s") % (self.arguments, str(status))) 
    105              
    106         if pagecounter is None :     
     105 
     106        if pagecounter is None : 
    107107            message = _("Unable to compute job size with accounter %s") % self.arguments 
    108108            if self.onerror == "CONTINUE" : 
     
    111111                raise PyKotaAccounterError, message 
    112112        self.filter.logdebug("Software accounter %s said job is %s pages long." % (self.arguments, repr(pagecounter))) 
    113              
    114         pagecounter = pagecounter or 0     
     113 
     114        pagecounter = pagecounter or 0 
    115115        try : 
    116116            if self.filter.Ticket.FileName is not None : 
    117                 # when a filename is passed as an argument, the backend  
     117                # when a filename is passed as an argument, the backend 
    118118                # must generate the correct number of copies. 
    119119                pagecounter *= self.filter.Ticket.Copies 
    120         except AttributeError :         
     120        except AttributeError : 
    121121            pass # when called from pykotme. TODO : clean this mess some day. 
    122                          
     122 
    123123        return pagecounter