From 32dfe6567c8b7ebecc589156941d68a6d9f39683 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Thu, 29 Dec 2005 10:40:17 +0000 Subject: [PATCH] When saving a file to a FAT filesystem, the chmod would fail. Log a warning instead of aborting (Thomas Leonard; reported by QS Computing). git-svn-id: https://rox.svn.sourceforge.net/svnroot/rox/trunk/ROX-Lib2@4278 66de3db3-b00d-0410-b41b-f4738ad19bea --- Help/Changes | 5 +++++ python/rox/saving.py | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Help/Changes b/Help/Changes index af3dc7b..8502e9f 100644 --- a/Help/Changes +++ b/Help/Changes @@ -3,6 +3,11 @@ by Thomas Leonard http://rox.sourceforge.net +29-Dec-2005 +~~~~~~~~~~~ +When saving a file to a FAT filesystem, the chmod would fail. Log a warning +instead of aborting (Thomas Leonard; reported by QS Computing). + 25-Nov-2005 ~~~~~~~~~~~ Better detection of the MIME-types/MIME-thumb location when installing diff --git a/python/rox/saving.py b/python/rox/saving.py index 0a39d59..101e7c2 100644 --- a/python/rox/saving.py +++ b/python/rox/saving.py @@ -15,6 +15,17 @@ gdk = g.gdk TARGET_XDS = 0 TARGET_RAW = 1 +def _chmod(path, mode): + """Like os.chmod, except that permission denied errors are not fatal + (for FAT partitions).""" + try: + os.chmod(path, mode) + except OSError, ex: + if ex.errno != 1: + raise + # Log the error and continue. + print >>sys.stderr, "Warning: Failed to set permissions:", ex + def _write_xds_property(context, value): win = context.source_window if value: @@ -175,11 +186,11 @@ class Saveable: save_mode = self.save_mode if save_mode is not None: - os.chmod(path, save_mode) + _chmod(path, save_mode) else: mask = os.umask(0077) # Get the current umask os.umask(mask) # Set it back how it was - os.chmod(path, 0666 & ~mask) + _chmod(path, 0666 & ~mask) def save_done(self): """Time to close the savebox. Default method does nothing.""" -- 2.11.4.GIT