Changeset 643

Show
Ignore:
Timestamp:
06/12/05 22:29:06 (19 years ago)
Author:
jerome
Message:

Fixed some code which wouldn't have run on Python2.1.
Fixed some code which made the bad assumption that
dictionnary.items() is always sorted : this was just luck !

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tea4cups/trunk/tea4cups

    r641 r643  
    557557        signal.signal(signal.SIGTERM, self.sigtermHandler) 
    558558        serialize = self.isTrue(self.getPrintQueueOption(self.PrinterName, "serialize", ignore=1)) 
    559         self.pipes = { 0: (0,1) } 
     559        self.pipes = { 0: (0, 1) } 
    560560        branches = self.enumBranches(self.PrinterName, "prehook") 
    561561        for b in branches : 
    562562            self.pipes[b.split("_", 1)[1]] = os.pipe() 
    563563        retcode = self.runCommands("prehook", branches, serialize) 
    564         for p in self.pipes.items()[1:] : 
     564        for p in [ (k, v) for (k, v) in self.pipes.items() if k != 0 ] : 
    565565            os.close(p[1][1]) 
    566566        if not self.isCancelled and not self.gotSigTerm : 
     
    572572                if self.runCommands("posthook", branches, serialize) : 
    573573                    self.logInfo("An error occured during the execution of posthooks.", "warn") 
    574         for p in self.pipes.items()[1:] : 
     574        for p in [ (k, v) for (k, v) in self.pipes.items() if k != 0 ] : 
    575575            os.close(p[1][0]) 
    576576        signal.signal(signal.SIGTERM, signal.SIG_IGN) 
     
    607607        self.logDebug("Launching %s : %s" % (branch, command)) 
    608608        btype, bname = branch.split("_", 1) 
    609         if bname not in self.pipes : 
     609        if bname not in self.pipes.keys() : 
    610610            bname = 0 
    611611        if btype == "prehook" : 
     
    677677                f.close() 
    678678            try : 
    679                 os.execve(originalbackend,arguments,os.environ) 
     679                os.execve(originalbackend, arguments, os.environ) 
    680680            except OSError, msg : 
    681681                self.logDebug("execve() failed: %s" % msg) 
     
    693693            status = os.WEXITSTATUS(status) 
    694694            if status : 
    695               self.logInfo("CUPS backend %s returned %d." % (originalbackend, status), "error") 
     695              self.logInfo("CUPS backend %s returned %d." % (originalbackend,\ 
     696                                                             status), "error") 
    696697            return status 
    697698        elif not killed : 
    698             self.logInfo("CUPS backend %s died abnormally." % originalbackend, "error") 
     699            self.logInfo("CUPS backend %s died abnormally." % originalbackend,\ 
     700                                                              "error") 
    699701            return -1 
    700702        else : 
     
    726728            for line in traceback.format_exception(*sys.exc_info()) : 
    727729                lines.extend([l for l in line.split("\n") if l]) 
    728             msg = "ERROR: ".join(["%s (PID %s) : %s\n" % (wrapper.MyName, wrapper.pid, l) for l in (["ERROR: Tea4CUPS v%s" % version] + lines)]) 
     730            msg = "ERROR: ".join(["%s (PID %s) : %s\n" % (wrapper.MyName, \ 
     731                                                          wrapper.pid, l) \ 
     732                        for l in (["ERROR: Tea4CUPS v%s" % version] + lines)]) 
    729733            sys.stderr.write(msg) 
    730734            sys.stderr.flush()