Changeset efee0f1 for server


Ignore:
Timestamp:
Oct 29, 2010, 11:25:48 PM (14 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
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)
Message:

Started customization, then realized that ipplib isn't supported.
Will probably write a perl ipp server instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/lib/ipp.py

    r2876403 refee0f1  
    11#!/usr/bin/env python
    22
    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
    411
    512import 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')
     13import cgi, cgitb
     14import logging
    1415import MySQLdb
    15 from ipplib import IPPRequest
    1616import ipplib
    1717
     18from ipplib import IPPRequest
    1819from tempfile import mkstemp
    1920from shutil import move
     21from logging import debug, info, warning, error, critical
     22
     23# set up logging
     24LOGFILE = "/var/log/gutenbach/ipp.log"
     25logging.basicConfig(filename=LOGFILE, level=logging.DEBUG)
     26cgitb.enable(logdir='/var/log/gutenbach/cgi.log')
     27
     28# make sure a temporary folder exists
     29TEMPDIR = '/tmp/gutenbach/ipp'
     30try:
     31    if not os.path.exists(TEMPDIR):
     32        info("Creating temporay directory '%s'" % TEMPDIR)
     33        os.makedirs(TEMPDIR)
     34except e, Exception:
     35    error("Could not create temporary directory '%s'" % TEMPDIR)
     36
    2037
    2138authfail = False
     
    2441except:
    2542    pass
     43
    2644try:
    2745    argv = cgi.parse(os.environ['QUERY_STRING'])
     
    7391            request._operation_attributes[0])
    7492
    75         # f = file('/tmp/gutenbach/printer2.log','a')
     93        # f = file('/tmp/gutenbach/ipp/printer2.log','a')
    7694        # f.write("\n" + "*"*80 + "\n")
    7795        # f.write(str(request))
     
    89107    def _operation_2(self, request, response):
    90108        """print-job response"""
    91         (fno, fname) = mkstemp(dir='/tmp/gutenbach')
     109        (fno, fname) = mkstemp(dir='/tmp/gutenbach/ipp')
    92110        os.write(fno, request.data)
    93111        os.close(fno)
Note: See TracChangeset for help on using the changeset viewer.