Merge lp://staging/~mascha/sbackup/trunkFixFor632605 into lp://staging/sbackup

Proposed by Martin Schaaf
Status: Merged
Merged at revision: 196
Proposed branch: lp://staging/~mascha/sbackup/trunkFixFor632605
Merge into: lp://staging/sbackup
Diff against target: 111 lines (+28/-7)
5 files modified
src/sbackup/ar_backend/tar.py (+3/-5)
src/sbackup/fs_backend/_fuse_utils.py (+7/-1)
src/sbackup/fs_backend/_gio_utils.py (+9/-1)
src/sbackup/util/exceptions.py (+5/-0)
src/sbackup/util/interfaces.py (+4/-0)
To merge this branch: bzr merge lp://staging/~mascha/sbackup/trunkFixFor632605
Reviewer Review Type Date Requested Status
Jean-Peer Lorenz Approve
Martin Schaaf Pending
Review via email: mp+38763@code.staging.launchpad.net

This proposal supersedes a proposal from 2010-10-04.

To post a comment you must log in.
Revision history for this message
Jean-Peer Lorenz (peer.loz) wrote : Posted in a previous version of this proposal

Thank you so much. I really appreciate your help.

Before merging your branch I've a few comments that need fixing though:

* don't import sys. Please use (more simple and intuitive):
...
except FileAccessError, error:
    log.error(_("message: %s" % error)

* use logger.error instead of logger.warning

* please re-raise an exception within the close_stream methods. Use the same exception in both backends. Purpose is to decide outside (i.e. when using close_stream) whether or not we want to ignore errors, how to handle them etc. This could be done by translating *some* caught errors into well defined one. Maybe it's worth to declare a new custom exception. Just have a look into 'utils.exception' at the FileAccessError section and propose one. E.g. in fuse_utils:

...
except (IOError, OSError), error:
    raise FileAccessError(_("Error while closing stream: %s") % error)

Similar for gio_utils (gio.Error and glib.Error). Just have a look at similar methods.

* please don't catch *all* exceptions. This is bad style. Catch only exceptions meaningful in the specific context. That is IOError and OSError in fuse backend and gio.Error and glib.Error in gio backend.

* catch according exception in module tar (line ~820) and log a message. I really don't like the idea of catching errors on stream closing in general.

* be sure your code complys to Python conventions: spaces instead of tabs, variable names at least 3 characters long, no camel case (I know, there are lots of not compliant LOC though I try to improve code quality whenever possible.) Use pylint if you want.

review: Needs Fixing
Revision history for this message
Martin Schaaf (mascha) wrote : Posted in a previous version of this proposal

Hej Jean-Peer,

the patch should now follow your advices. Please have a look.

Bye,
martin.

review: Needs Resubmitting
Revision history for this message
Martin Schaaf (mascha) : Posted in a previous version of this proposal
review: Abstain
Revision history for this message
Jean-Peer Lorenz (peer.loz) wrote : Posted in a previous version of this proposal

Hi Martin,
the patch looks great. Before I'll merge it into trunk I'd suggest a few changes:

1. make the warning in tar.py more verbose/descriptive e.g.
"Error (was ignored) while closing snapshot file: %s"
2. make this string translatable
3. revert the debug.error back into debug.warning (was my bad, of course it's a warning rather an error if we ignore the underlying error)
4. rename the exception FileAlreadyClosedException into FileAlreadyClosedError in order to follow Python's convention
4. in _fuse_utils: also throw a FileAlreadyClosedError and make the error message the same as in _gio_utils:
_("Error while closing stream: %s") % error (the method name isn't required since it has no value for users and is contained in the traceback)
5. make the error message here: raise FileAccessException(get_gio_errmsg(error, "Error in 'close_stream'"))
also look the same (get_gio_errmsg(error, _("Error while closing stream"))
6. add 'close_stream' to the interface class IOperations in util.interfaces

Thanks a lot.

review: Needs Fixing
202. By Martin Schaaf

* do not import exceptions twice

203. By Martin Schaaf

* prefix errors with module name

Revision history for this message
Jean-Peer Lorenz (peer.loz) wrote :

Thanks for your effort and contribution.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches