This has been fixed upstream in bzr. The new behaviour is that from now that in case of a permission error, images will be saved on desktop instead. $ bzr diff === modified file 'phatch/actions/save.py' --- phatch/actions/save.py 2009-04-14 22:29:45 +0000 +++ phatch/actions/save.py 2009-05-25 16:38:11 +0000 @@ -24,6 +24,11 @@ from core.translation import _t,new from imtools import get_quality, get_size +from core.lib.desktop import DESKTOP_FOLDER, USER_FOLDER +if DESKTOP_FOLDER == USER_FOLDER: + DESKTOP_FOLDER = os.path.expanduser('~/phatch') + + JPG = ['jpg','jpeg','jpe'] PNG = ['png'] TYPE = '<%s>'%_t('type') @@ -72,7 +77,17 @@ dpi = self.get_field('Resolution',info) #filename if setting('create_missing_folders'): - self.ensure_path(folder) + try: + self.ensure_path(folder) + except OSError, message: + base = os.path.basename(filename) + photo.log += 'Could not save "%s" in "%s":\n%s\n'\ + %(base,folder,message) + photo.log += 'Will try to save in "%s" instead.\n'\ + %DESKTOP_FOLDER + self.ensure_path(DESKTOP_FOLDER) + filename = os.path.join(DESKTOP_FOLDER,base) + #construct options options = {'dpi' : (dpi,dpi)} if self.is_type(typ,PNG): === added file 'phatch/core/lib/desktop.py' --- phatch/core/lib/desktop.py 1970-01-01 00:00:00 +0000 +++ phatch/core/lib/desktop.py 2009-05-25 16:10:46 +0000 @@ -0,0 +1,47 @@ +# Copyright (C) 2007-2008 www.stani.be +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/ + +"""Cross platform library to locate the desktop folder.""" + +import os +import re +import sys + +USER_FOLDER = os.path.expanduser('~') + +if sys.platform.startswith('win'): + # Windows + from win32com.shell import shell, shellcon + DESKTOP_FOLDER = shell.SHGetFolderPath(0, shellcon.CSIDL_DESKTOP, + None, 0) +elif sys.platform.startswith('darwin'): + # Mac: verify this! + DESKTOP_FOLDER = os.path.expanduser('~/Desktop') +else: + # Linux + user_dirs = os.path.expanduser('~/.config/user-dirs.dirs') + if os.path.exists(user_dirs): + DESKTOP_FOLDER = os.path.expanduser( + re.search('XDG_DESKTOP_DIR="(.*?)"',open(user_dirs).read())\ + .group(1).replace('$HOME','~')) + else: + DESKTOP_FOLDER = os.path.expanduser('~/Desktop') + del user_dirs + +if not os.path.isdir(DESKTOP_FOLDER): + DESKTOP_FOLDER = USER_FOLDER + +if __name__ == '__main__': + sys.stdout.write('Your desktop is: %s\n'%DESKTOP_FOLDER) $ bzr commit -m "save batched images on the desktop in case of a permission error" Committing to: /home/stani/sync/python/phatch/trunk/ modified phatch/actions/save.py added phatch/core/lib/desktop.py Committed revision 587.