Very good bug report, thanks! Luckily it was only for metadata saving, not for regular actions.
$ bzr diff === modified file 'phatch/core/api.py' --- phatch/core/api.py 2009-06-08 18:55:29 +0000 +++ phatch/core/api.py 2009-06-09 14:43:36 +0000 @@ -291,8 +291,14 @@ def flush_metadata(photo,image_file,result): try: photo.flush_metadata() + result['skip'] = False + result['abort'] = False + #log non fatal errors/warnings + flush_log(photo, image_file) + return photo, result except Exception, details: - folder, image = os.path.split(ensure_unicode(image_file)) + photo.metadata = {} + folder, image = os.path.split(ensure_unicode(image_file)) reason = exception_to_unicode(details) message = u'%s\n%s\n\n%s'%( _("Can not write metadata to image '%s' in folder:")%image, @@ -301,7 +307,6 @@ ) return process_error(photo,message,image_file,action=None, result=result,ignore=True) - flush_log(photo, image_file)
def apply_action(action,photo,setting,cache,image_file,result): @@ -321,8 +326,8 @@ folder, reason, ) - ignore = True - return process_error(photo,message,image_file,action,result,ignore) + return process_error(photo,message,image_file,action, + result,ignore=True)
def apply_actions(actions,settings,paths=None,drop=False): """Do all the actions.""" @@ -407,7 +412,10 @@ #do the actions for action_index, action in enumerate(actions): if action.flush_metadata_before: - flush_metadata(photo,image_file,result) + photo, result = flush_metadata(photo,image_file,result) + if result['abort']: return + elif result['skip']: + break #update progress progress_result = {} send.progress_update_index(progress_result,image_index,action_index) @@ -421,9 +429,9 @@ if result['abort']: return elif result['skip']: break - flush_metadata(photo,image_file,result) - flush_log(photo, image_file, action) + photo, result = flush_metadata(photo,image_file,result) del photo, progress_result, action_index, action + if result['abort']: return send.progress_close() #mention amount of photos and duration delta = time.time()-start
=== modified file 'phatch/core/lib/_pyexiv2.py' --- phatch/core/lib/_pyexiv2.py 2009-06-09 13:56:09 +0000 +++ phatch/core/lib/_pyexiv2.py 2009-06-09 14:02:24 +0000 @@ -145,7 +145,7 @@ if ext: format = ext.upper() if (format and not(format in WRITE_EXIF+WRITE_IPTC)): - return 'pyexiv2: writing metadata to %s is not supported'%format + raise Exception('pyexiv2: writing metadata to %s is not supported'%format) image = pyexiv2.Image(path) image.readMetadata() warnings = []
=== modified file 'phatch/core/pil.py' --- phatch/core/pil.py 2009-06-09 04:21:16 +0000 +++ phatch/core/pil.py 2009-06-09 13:58:48 +0000 @@ -434,7 +434,8 @@ #throw an error if pyexiv2 is not installed if not exif: raise ImportError(NEEDS_PYEXIV2) - self.log += exif.flush(self.info['path'],self.metadata) + self.log += exif.flush(self.info['path'],self.metadata, + self.info['Pil.Format']) #as metadata has changed, use new source self.metadata = {}
$ bzr commit -m "fixing error dialog buttons for metadata" Committing to: /home/stani/sync/python/phatch/trunk/ modified phatch/core/api.py modified phatch/core/pil.py modified phatch/core/lib/_pyexiv2.py Committed revision 709.
Very good bug report, thanks! Luckily it was only for metadata saving, not for regular actions.
$ bzr diff core/api. py' photo,image_ file,result) :
photo. flush_metadata( ) split(ensure_ unicode( image_file) ) split(ensure_ unicode( image_file) ) to_unicode( details) error(photo, message, image_file, action= None,
result= result, ignore= True)
=== modified file 'phatch/
--- phatch/core/api.py 2009-06-08 18:55:29 +0000
+++ phatch/core/api.py 2009-06-09 14:43:36 +0000
@@ -291,8 +291,14 @@
def flush_metadata(
try:
+ result['skip'] = False
+ result['abort'] = False
+ #log non fatal errors/warnings
+ flush_log(photo, image_file)
+ return photo, result
except Exception, details:
- folder, image = os.path.
+ photo.metadata = {}
+ folder, image = os.path.
reason = exception_
message = u'%s\n%s\n\n%s'%(
_("Can not write metadata to image '%s' in folder:")%image,
@@ -301,7 +307,6 @@
)
return process_
- flush_log(photo, image_file)
def apply_action( action, photo,setting, cache,image_ file,result) :
folder,
reason, error(photo, message, image_file, action, result, ignore) error(photo, message, image_file, action,
@@ -321,8 +326,8 @@
)
- ignore = True
- return process_
+ return process_
+ result,ignore=True)
def apply_actions( actions, settings, paths=None, drop=False) : flush_metadata_ before: photo,image_ file,result) photo,image_ file,result)
# update progress
progress_ result = {}
send. progress_ update_ index(progress_ result, image_index, action_ index)
break photo,image_ file,result) photo,image_ file,result) progress_ close()
"""Do all the actions."""
@@ -407,7 +412,10 @@
#do the actions
for action_index, action in enumerate(actions):
if action.
- flush_metadata(
+ photo, result = flush_metadata(
+ if result['abort']: return
+ elif result['skip']:
+ break
@@ -421,9 +429,9 @@
if result['abort']: return
elif result['skip']:
- flush_metadata(
- flush_log(photo, image_file, action)
+ photo, result = flush_metadata(
del photo, progress_result, action_index, action
+ if result['abort']: return
send.
#mention amount of photos and duration
delta = time.time()-start
=== modified file 'phatch/ core/lib/ _pyexiv2. py' core/lib/ _pyexiv2. py 2009-06-09 13:56:09 +0000 core/lib/ _pyexiv2. py 2009-06-09 14:02:24 +0000 WRITE_IPTC) ): readMetadata( )
--- phatch/
+++ phatch/
@@ -145,7 +145,7 @@
if ext:
format = ext.upper()
if (format and not(format in WRITE_EXIF+
- return 'pyexiv2: writing metadata to %s is not supported'%format
+ raise Exception('pyexiv2: writing metadata to %s is not supported'%format)
image = pyexiv2.Image(path)
image.
warnings = []
=== modified file 'phatch/ core/pil. py' NEEDS_PYEXIV2) self.info[ 'path'] ,self.metadata) self.info[ 'path'] ,self.metadata, 'Pil.Format' ])
self. metadata = {}
--- phatch/core/pil.py 2009-06-09 04:21:16 +0000
+++ phatch/core/pil.py 2009-06-09 13:58:48 +0000
@@ -434,7 +434,8 @@
#throw an error if pyexiv2 is not installed
if not exif:
raise ImportError(
- self.log += exif.flush(
+ self.log += exif.flush(
+ self.info[
#as metadata has changed, use new source
$ bzr commit -m "fixing error dialog buttons for metadata" sync/python/ phatch/ trunk/ core/lib/ _pyexiv2. py
Committing to: /home/stani/
modified phatch/core/api.py
modified phatch/core/pil.py
modified phatch/
Committed revision 709.