Public feed #528392

Miscellany

public python v1 · immutable
Raw Edit
·published 2007-06-01 15:13 UTC
rendered paste body
""" Itaka web server engine """import config as iconfigimage_dir = iconfig.image_dirsystem = iconfig.systemplatform = iconfig.platformiconfig = iconfig.valuesimport screenshot as iscreenshotfrom twisted.web.resource import Resourceimport datetime, osimport pygtkpygtk.require("2.0")import gtk, gobject#: Local iteration counterlcounter = 0# Set up the screenshooter serverclass ImageResource(Resource):    """ Take the screenshot code and handle the requests. """    def __init__(self, ginstance, cinstance):        """ Intialize inherited GUI and Console instances """        self.igui = ginstance    def render_GET(self, request):        """ Handle GET requests for screenshot. """        request.setHeader("Content-type", "image/" + iconfig['screenshot']['format'])        self.icip = request.getClientIP()        self.time = datetime.datetime.now()        # self.icbrowser = request.getClient()        # This gets us a screenshot file        self.shotFile = iscreenshot.Screenshot()        global lcounter        lcounter += 1        # Tell the GUI what changed        self.igui.talk('updateGuiStatus', str(lcounter), str(self.icip), self.time)        return open(self.shotFile, 'rb').read()