This piece of python will take a screenshot (under linux and windows) and will upload it to an ftp server
import os
import ftplib
FTPHOST = "ftp.example.com"
FTPPORT = 21
FTPUSER = "anonymous"
FTPPASS = "a@anonymous.com"
def upload(filetoupload):
ftp = ftplib.FTP()
ftp.connect(FTPHOST,FTPPORT)
ftp.login(FTPUSER,FTPPASS)
f = open(filetoupload,'rb')
ftp.storbinary(('STOR '+filetoupload),f)
f.close()
ftp.quit()
def screenshot(shotname):
shotname = shotname+".png"
if os.name == "nt":
import ImageGrab
img = ImageGrab.grab()
img.save(shotname)
upload(shotname)
os.remove(shotname)
elif os.name == "posix":
import gtk.gdk
w = gtk.gdk.get_default_root_window()
sz = w.get_size()
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
pb.save(shotname,"png")
upload(shotname)
os.remove(shotname)
screenshot("screenshot")