Changeset 1678

Show
Ignore:
Timestamp:
08/22/04 16:04:47 (20 years ago)
Author:
jalet
Message:

Tries to fix problem with subprocesses outputting more datas than needed

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1676 r1678  
    2424    - 1.20alpha2 : 
    2525     
     26        - Now software accounting method reads accounter's 
     27          answer until a line with a single integer is  
     28          obtained or until all of its output has been read. 
     29          This should fix the problem some people have 
     30          when strange locale related messages are sent 
     31          when running subprocesses (Solaris only ?). 
     32           
    2633        - First version of ESC/P2 analyzer. Seems to work 
    2734          ok at least with 'epson', 'epsonc', 'eps9mid'  
  • pykota/trunk/pykota/accounters/software.py

    r1665 r1678  
    2222# 
    2323# $Log$ 
     24# Revision 1.8  2004/08/22 14:04:47  jalet 
     25# Tries to fix problem with subprocesses outputting more datas than needed 
     26# 
    2427# Revision 1.7  2004/08/06 13:45:51  jalet 
    2528# Fixed french translation problem. 
     
    7376        pagecount = 0 
    7477        try : 
    75             pagecount = int(child.fromchild.readline().strip()) 
    76         except (AttributeError, ValueError) : 
    77             self.filter.printInfo(_("Unable to compute job size with accounter %s") % self.arguments) 
     78            answer = child.fromchild.read() 
    7879        except (IOError, OSError), msg :     
    7980            msg = "%s : %s" % (self.arguments, msg)  
    8081            self.filter.printInfo(_("Unable to compute job size with accounter %s") % msg) 
     82        else :     
     83            lines = [l.strip() for l in answer.split("\n")] 
     84            for i in range(len(lines)) :  
     85                try : 
     86                    pagecount = int(lines[i]) 
     87                except (AttributeError, ValueError) : 
     88                    self.filter.printInfo(_("Unable to compute job size with accounter %s") % self.arguments) 
     89                    self.filter.printInfo(_("Line skipped in accounter's output. Trying again...")) 
     90                else :     
     91                    break 
    8192        child.fromchild.close() 
    8293