Changeset efee0f1 for server/lib/ipp.py
- Timestamp:
- Oct 29, 2010, 11:25:48 PM (14 years ago)
- Branches:
- no-cups
- Children:
- c216863
- Parents:
- 2876403
- git-author:
- Jessica B. Hamrick <jhamrick@…> (10/29/10 23:25:48)
- git-committer:
- Jessica B. Hamrick <jhamrick@…> (10/29/10 23:25:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/lib/ipp.py
r2876403 refee0f1 1 1 #!/usr/bin/env python 2 2 3 # Adapted from the Quickprint IPP server code 3 # Adapted from the Quickprint IPP server code (http://quickprint.mit.edu) 4 # Modifications and additions written by Jessica Hamrick (jhamrick@mit.edu) 5 6 # Notes and Todo: 7 # - make sure package creates gutenbach folder in /var/log 8 # - ok, so ipplib actually seems to be an unsupported library. 9 # Maybe want to write this in perl instead since there is 10 # Net::IPP::IPPRequest 4 11 5 12 import os, sys 6 7 try: 8 if not os.path.isdir('/tmp/gutenbach'): 9 os.mkdir('/tmp/gutenbach') 10 except e, Exception: 11 pass 12 13 import cgi #, cgitb; cgitb.enable(logdir='/tmp/gutenbach') 13 import cgi, cgitb 14 import logging 14 15 import MySQLdb 15 from ipplib import IPPRequest16 16 import ipplib 17 17 18 from ipplib import IPPRequest 18 19 from tempfile import mkstemp 19 20 from shutil import move 21 from logging import debug, info, warning, error, critical 22 23 # set up logging 24 LOGFILE = "/var/log/gutenbach/ipp.log" 25 logging.basicConfig(filename=LOGFILE, level=logging.DEBUG) 26 cgitb.enable(logdir='/var/log/gutenbach/cgi.log') 27 28 # make sure a temporary folder exists 29 TEMPDIR = '/tmp/gutenbach/ipp' 30 try: 31 if not os.path.exists(TEMPDIR): 32 info("Creating temporay directory '%s'" % TEMPDIR) 33 os.makedirs(TEMPDIR) 34 except e, Exception: 35 error("Could not create temporary directory '%s'" % TEMPDIR) 36 20 37 21 38 authfail = False … … 24 41 except: 25 42 pass 43 26 44 try: 27 45 argv = cgi.parse(os.environ['QUERY_STRING']) … … 73 91 request._operation_attributes[0]) 74 92 75 # f = file('/tmp/gutenbach/ printer2.log','a')93 # f = file('/tmp/gutenbach/ipp/printer2.log','a') 76 94 # f.write("\n" + "*"*80 + "\n") 77 95 # f.write(str(request)) … … 89 107 def _operation_2(self, request, response): 90 108 """print-job response""" 91 (fno, fname) = mkstemp(dir='/tmp/gutenbach ')109 (fno, fname) = mkstemp(dir='/tmp/gutenbach/ipp') 92 110 os.write(fno, request.data) 93 111 os.close(fno)
Note: See TracChangeset
for help on using the changeset viewer.