def testOnlyMixedFull(self): ''' Mix all png and jpeg in a single dir ''' src = join(self.tempdir, 'mixedFull') mkdir(src) for d in [self.jpgsDir, self.pngDir]: # the first file is the .svn dir ... start at 1, big hack for f in listdir(d)[1:]: copy(join(d, f), src) main(self.albumName, self.topDir, self.xmlData, self.strip_originals, 'scry', fromDir = src)
def testOnlyMixedSimple(self): ''' I am happy I wrote this one because I found a bug :) Only take two picture of the jpeg and png sets ''' src = join(self.tempdir, 'mixedSimple') mkdir(src) for d in [self.jpgsDir, self.pngDir]: # the first file is the .svn dir ... start at 1, big hack for f in listdir(d)[1:3]: copy(join(d, f), src) main(self.albumName, self.topDir, self.xmlData, self.strip_originals, 'james', fromDir = src)
def testOnlyPNG(self): main(self.albumName, self.topDir, self.xmlData, self.strip_originals, 'scry', fromDir = self.pngDir)
def testOnlyJPG(self): main(self.albumName, self.topDir, self.xmlData, self.strip_originals, 'james', fromDir = self.jpgsDir)
def main(self): # init the config file conf = configHandler() if not conf.ok: _err_exit('Problem with the config file') libraryPath, xmlFileName, outputDir = \ conf.getValuesAndUpdateFromUser(self.libraryPath, self.xmlFileName, self.outputDir) ## # get iPhoto datas or flat dir pictures list if self.fb: logger.info('generate gallery from photos in %s dir' % self.fromDir) xmlData = None self.albumName = 'My Facebook pictures' self.fromDir = '/tmp/fb_files' facebook_download(self.fromDir, self.fb_uid) # sys.exit(0) elif not self.fromDir: try: adp = AlbumDataParser(libraryPath, xmlFileName) xmlData = adp.maybeLoadFromXML(conf) except(AlbumDataParserError): _err_exit("Problem parsing AlbumData.xml") else: logger.info('generate gallery from photos in %s dir' % self.fromDir) xmlData = None # FIXME: this '/' may not be portable ... self.albumName = basename(rstrip(self.fromDir, '/')) logger.info('albumName is %s' % self.albumName) # FIXME: remove the output dir if a problem occur up = 'pytof' topDir = join(self.outputDir, up, self.albumName) try: if not exists(topDir): os.makedirs(topDir) except (os.error): _err_exit('Cannot create %s' %(topDir)) echo('output dir is %s' % (topDir)) try: if self.info: for a in xmlData.getAlbumList(): try: print a.encode('utf8') except UnicodeDecodeError: print a else: if self.fs: makefs.main(self.albumName, topDir, xmlData) else: makepage.main(self.albumName, topDir, xmlData, self.stripOriginals, self.style, self.fromDir, self.progress) archive = None if self.Zip or self.tar: archive = mkarchive(fn = join(outputDir, up, self.albumName), prefix = join(outputDir, up), mainDir = self.albumName, files = [], Zip = self.Zip, tar = self.tar) echo('output archive is %s' % (archive)) if not self.info and not self.fs: import webbrowser url = 'file:///' url += '/'.join(topDir.split(sep)) + '/' url += '/'.join(['..', 'index.html']) webbrowser.open(url) if self.ftp: ftpPush(conf, archive, topDir, self.fs) except (KeyboardInterrupt): if not self.info: if not self.fs: # os.remove(makepage.cssfile) # we should remove the css file if there aren't # any other exported albums left... hard to know, # may be stored in the rc file, under the Internal section. # => if that's the only file in the pytof dir we should be good to go. pass if exists(topDir): rmtree(topDir) _err_exit("\nAborted by user")