Changeset 3545

Show
Ignore:
Timestamp:
04/27/10 23:38:18 (14 years ago)
Author:
jerome
Message:

Ensures that all command lines are properly encoded before calling
os.system() on them from the cupspykota backend wrapper.
TODO : check command line tools for the same potential problem.

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r3489 r3545  
    380380            self.logdebug("Launching subprocess [%s] to ask for user confirmation." \ 
    381381                                     % confirmationcommand) 
    382             inputfile = os.popen(confirmationcommand, "r") 
     382            inputfile = os.popen(confirmationcommand.encode(self.charset, "replace"), "r") 
    383383            try : 
    384384                for answer in inputfile.xreadlines() : 
     
    402402            self.logdebug("Launching subprocess [%s] to overwrite the job ticket." \ 
    403403                                     % jobticketcommand) 
    404             inputfile = os.popen(jobticketcommand, "r") 
     404            inputfile = os.popen(jobticketcommand.encode(self.charset, "replace"), "r") 
    405405            try : 
    406406                for line in inputfile.xreadlines() : 
     
    620620        if prehook : 
    621621            self.logdebug("Executing pre-hook [%s]..." % prehook) 
    622             retcode = os.system(prehook) 
     622            retcode = os.system(prehook.encode(self.charset, "replace")) 
    623623            self.logdebug("pre-hook exited with status %s." % retcode) 
    624624 
     
    628628        if posthook : 
    629629            self.logdebug("Executing post-hook [%s]..." % posthook) 
    630             retcode = os.system(posthook) 
     630            retcode = os.system(posthook.encode(self.charset, "replace")) 
    631631            self.logdebug("post-hook exited with status %s." % retcode) 
    632632 
     
    672672                  not os.path.isfile(bannerfileorcommand) : 
    673673                self.logdebug("Launching %s to generate a banner." % bannerfileorcommand) 
    674                 child = popen2.Popen3(bannerfileorcommand, capturestderr=1) 
     674                child = popen2.Popen3(bannerfileorcommand.encode(self.charset, "replace"), capturestderr=1) 
    675675                self.runOriginalBackend(child.fromchild, isBanner=1) 
    676676                child.tochild.close() 
     
    808808                if not userpquota.Exists : 
    809809                    self.printInfo(_("User %s doesn't have quota on printer %s in the PyKota system, applying external policy (%s) for printer %s") % (self.UserName, self.PrinterName, commandline, self.PrinterName)) 
    810                 if os.system(commandline) : 
     810                if os.system(commandline.encode(self.charset, "replace")) : 
    811811                    self.printInfo(_("External policy %s for printer %s produced an error. Job rejected. Please check PyKota's configuration files.") % (commandline, self.PrinterName), "error") 
    812812                    policy = "EXTERNALERROR" 
     
    863863                    if script is not None : 
    864864                        self.logdebug(msg + "launching subprocess [%s] to notify user." % script) 
    865                         os.system(script) 
     865                        os.system(script.encode(self.charset, "replace")) 
    866866        self.logdebug("Retrieval of billing code information done.") 
    867867 
     
    894894                    # TODO : important, because usually duplicate jobs are sucessive. 
    895895                    msg = _("Job is a dupe") 
    896                     if denyduplicates == 1 : 
     896                    if denyduplicates is True : 
    897897                        self.printInfo("%s : %s." % (msg, _("Printing is denied by configuration")), "warn") 
    898898                        self.Action = "DENY" 
     
    900900                    else : 
    901901                        self.logdebug("Launching subprocess [%s] to see if duplicate jobs should be allowed or not." % denyduplicates) 
    902                         fanswer = os.popen(denyduplicates, "r") 
     902                        fanswer = os.popen(denyduplicates.encode(self.charset, "replace"), "r") 
    903903                        self.Action = fanswer.read().strip().upper() 
    904904                        fanswer.close() 
  • pykota/trunk/pykota/tool.py

    r3489 r3545  
    486486    def externalMailTo(self, cmd, action, user, printer, message) : 
    487487        """Warns the user with an external command.""" 
     488        cmd = cmd.encode(self.charset, "replace") 
    488489        message = message.encode(self.charset, "replace") 
    489490        username = user.Name 
  • pykota/trunk/pykota/version.py

    r3533 r3545  
    2424import time 
    2525 
    26 __version__ = "1.27alpha10_unofficial" 
     26__version__ = "1.27alpha11_unofficial" 
    2727 
    2828__doc__ = "PyKota : a complete Printing Quota Solution for CUPS."