Show
Ignore:
Timestamp:
04/04/05 21:04:21 (19 years ago)
Author:
jerome
Message:

pkbanner now accepts more info to display on its command line

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkbanner

    r2147 r2193  
    5555command line usage : 
    5656 
    57   pkbanner  [options]  
     57  pkbanner  [options]  [more info] 
    5858 
    5959options : 
     
    144144        return (size + 4) 
    145145     
    146     def genPDF(self, pagesize, logo, url, savetoner) : 
     146    def genPDF(self, pagesize, logo, url, text, savetoner) : 
    147147        """Generates the banner in PDF format, return the PDF document as a string.""" 
    148          
    149148        document = cStringIO.StringIO() 
    150149        c = canvas.Canvas(document, pagesize=pagesize, pageCompression=1) 
     
    183182        # Outputs the username 
    184183        ypos -= self.printVar(c, xcenter, ypos, _("Username"), username, 20, savetoner)  
     184         
     185        # Text     
     186        if text : 
     187            ypos -= self.printVar(c, xcenter, ypos, _("More Info"), text, 20, savetoner)  
    185188         
    186189        # Printer and Job Id 
     
    239242        return document.getvalue() 
    240243         
    241     def main(self, files, options) : 
     244    def main(self, arguments, options) : 
    242245        """Generates a banner.""" 
    243246        if not hasRL : 
     
    261264             
    262265        self.logdebug("Generating the banner in PDF format...")     
    263         doc = self.genPDF(pagesize, options["logo"].strip(), options["url"].strip(), savetoner) 
     266        doc = self.genPDF(pagesize,  
     267                          options["logo"].strip(),  
     268                          options["url"].strip(),  
     269                          " ".join(arguments).strip(),  
     270                          savetoner) 
    264271         
    265272        self.logdebug("Converting the banner to PostScript...")     
    266273        os.environ["PATH"] = "%s:/bin:/usr/bin:/usr/local/bin:/opt/bin:/sbin:/usr/sbin" % os.environ.get("PATH", "") 
    267         child = popen2.Popen3("gs -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -sDEVICE=pswrite -sOutputFile=- - 2>/tmp/errgs") 
    268         child.tochild.write(doc) 
    269         child.tochild.close() 
    270         sys.stdout.write(child.fromchild.read()) 
    271         sys.stdout.flush() 
    272         child.fromchild.close() 
     274        child = popen2.Popen3("gs -q -dNOPAUSE -dBATCH -dPARANOIDSAFER -sDEVICE=pswrite -sOutputFile=- -") 
     275        try : 
     276            child.tochild.write(doc) 
     277            child.tochild.close() 
     278            sys.stdout.write(child.fromchild.read()) 
     279            sys.stdout.flush() 
     280            child.fromchild.close() 
     281        except IOError, msg :     
     282            self.printInfo("I/O Error %s" % msg, "error") 
    273283        status = child.wait() 
    274284        if os.WIFEXITED(status) :