#import capturecam import web import glob #import SendKeys #import win32com #import win32con #import win32api import string import os import maccapture1257 from time import gmtime, strftime # copywrite by zhvxxh@gmail.com for iphone iSnapshot def read_data(filename): data = '' try: fp = open(filename,'r') line = fp.readline() while line != '\n' and line != '': data = data +line; line = fp.readline() fp.close(); except: print 'file operate error' return data urls = ( '/', 'hello', # '/cgi-bin/capturescreen.exe?func=1', 'captureactive', '/cgi-bin/capturewebcam.exe', 'capturecam2', # '/cgi-bin/capturescreen.exe?func=2', 'captureclipboard', '/cgi-bin/capturescreen.exe', 'capture' ) app = web.application(urls, globals()) class hello: def GET(self): return 'Hello, iSnapshot server ok' + '!' class remotefile: def GET(self): x = web.input(myfile={}) web.debug(x.filename) data = read_data(x.filename); web.debug(data); SendKeys.SendKeys(data); return 'Hello,ie ' + '!' class listfiles: def GET(self): filev = glob.glob("*.txt") print filev return filev; class capture: def GET(self): timestr = strftime("%Y%m%d%H%M%S", gmtime()) if not os.path.exists('./static'): os.mkdir('./static') if not os.path.exists('./static/images'): os.mkdir('./static/images') filename='./static/images/'+ timestr +'.jpg'; urlname = '/static/images/'+timestr +'.jpg'; x = web.input(myfile={}) ifunc = 0 try: web.debug(x.func) ifunc = string.atoi(x.func) except: print 'except' if ifunc==0: maccapture1257.capture2jpg(filename); if ifunc==1: maccapture1257.captureactivewin2jpg(filename); if ifunc==2: maccapture1257.captureclipboard2jpg(filename); raise web.redirect (urlname) class captureactive: def GET(self): timestr = strftime("%Y%m%d%H%M%S", gmtime()) filename='c:\\newcolor2009\\remote\\static\\'+ timestr +'.jpg'; urlname = '/static/'+timestr +'.jpg'; capture1257.captureactivewin2jpg(filename); raise web.redirect (urlname) class captureclipboard: def GET(self): timestr = strftime("%Y%m%d%H%M%S", gmtime()) filename='c:\\newcolor2009\\remote\\static\\'+ timestr +'.jpg'; urlname = '/static/'+timestr +'.jpg'; capture1257.captureclipboard2jpg(filename); # raise web.redirect (urlname) return 'captureclipboard' class capturecam2: def GET(self): return 'webcam capture for mac no woking ' if __name__ == "__main__": app.run()