
You can see it being made here here.
A collection of unordered thoughts somehow expressed in English.
gabbpuy
It uses the sendfile wrapper module from here.
import os
directory = '/shared/images'
def Image(self, filename):
newPath = os.path.join(directory, filename)
if not os.access(newPath, os.F_OK|os.R_OK):
self.REQUEST.RESPONSE.setStatus(404)
return ''
f = open(newPath, 'rb')
self.REQUEST.RESPONSE.sendfile(f, content_type='image/jpeg', other_headers = {'Content-Disposition', 'inline;filename=%s'%(filename))
f.close()
return ''
[Terrorists' ultimate aim is to establish] "a caliphate covering a region from Spain, across North Africa, through the Middle East and South Asia, all the way to Indonesia -and it wouldn't stop there."
# Code to rotate or set wallpaper under windows # Copyright (C) Andrew K. Milton 2007 # Released under a 2-clause BSD License # See: http://www.opensource.org/licenses/bsd-license.php import os import time import random from optparse import OptionParser from ConfigParser import SafeConfigParser from ctypes import windll from win32con import * from PIL import Image """ I recommend you create a pywallpaper.conf file that looks something like this; [directories] paths = C:\Documents and Settings\akm\My Documents\My Pictures\gb C:\Documents and Settings\akm\My Documents\My Pictures\Ralph to store the directories in rather than specifying -d multiple times on the command line""" def getDefaultDirs(): return [r'C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures',] def setWallPaperFromBmp(pathToBmp): """ Given a path to a bmp, set it as the wallpaper """ result = windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, pathToBmp, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE) if not result: raise Exception("Unable to set wallpaper.") def setWallPaper(pathToImage): """ Given a path to an image, convert it to bmp format and set it as the wallpaper""" bmpImage = Image.open(pathToImage) newPath = os.getcwd() newPath = os.path.join(newPath, 'pywallpaper.bmp') bmpImage.save(newPath, "BMP") setWallPaperFromBmp(newPath) def setWallPaperFromFileList(pathToDir): """ Given a directory choose an image from it and set it as a wallpaper """ # Image directories often contain Thumbs.db or other non-image # files or directories, try a few times to set a wallpaper, and then just give up. tries = 0 done = False while (not done) and tries < 3: try: files = os.listdir(pathToDir) image = random.choice(files) setWallPaper(os.path.join(pathToDir, image)) done = True except: tries += 1 return done def setWallPaperFromDirList(pathList): """ Given a list of directories choose a directory """ imageDir = random.choice(pathList) status = setWallPaperFromFileList(imageDir) # Don't really need to say anything if we couldn't set the # wallpaper, I think the user will notice def getImageDirectories(options): configFile = 'pywallpaper.conf' if options.configFile: configFile = options.configFile dirs = options.directories try: config = SafeConfigParser() config.readfp(open(configFile)) dirs += config.get('directories', 'paths').split('\n') except: pass if not dirs: # raise Exception("No directories defined") dirs = getDefaultDirs() return dirs def setWallPaperFromConfigDirs(options): setWallPaperFromDirList(getImageDirectories(options)) def getCommandLineOptions(): parser = OptionParser() parser.add_option("-t", "--time", dest="change_time", help = "Change wallpaper time in minutes (0 = change once and exit [default])", default = 0, type = "int") parser.add_option("-i", "--image", dest="singleImage", default = None, help = "Set wallpaper to this image and exit (overrides -d)") parser.add_option("-d", "--directory", dest="directories", default = [], action="append", type="string", help = "Add an image directory") parser.add_option("-c", "--config", dest="configFile", default = None, help = "path to alternate config file (default <working dir>/pywallpaper.conf)") parser.add_option("-w", "--workingdir", dest="cwd", default=".", help = "Working Directory (default .)") (options, args) = parser.parse_args() return (options, args) if __name__ == '__main__': options, args = getCommandLineOptions() if options.cwd and options.cwd != '.': os.cwd(cwd) if options.singleImage: setWallPaper(options.singleImage) elif not options.change_time: setWallPaperFromConfigDirs(options) else: dirs = getImageDirectories(options) sleepTime = options.change_time * 60.0 while True: setWallPaperFromDirList(dirs) time.sleep(sleepTime)