~antmak/duplicity/0.7-par2-fix

« back to all changes in this revision

Viewing changes to duplicity/backends/sshbackend.py

  • Committer: Kenneth Loafman
  • Date: 2014-04-29 15:35:47 UTC
  • mfrom: (978.2.10 backend-unification)
  • Revision ID: kenneth@loafman.com-20140429153547-to2j1tyyl0ps1hi6
* Merged in lp:~mterry/duplicity/backend-unification
  - Reorganize and simplify backend code.  Specifically:
    - Formalize the expected API between backends and duplicity.  See the new
      file duplicity/backends/README for the instructions I've given authors.
    - Add some tests for our backend wrapper class as well as some tests for
      individual backends.  For several backends that have some commands do all
      the heavy lifting (hsi, tahoe, ftp), I've added fake little mock commands
      so that we can test them locally.  This doesn't truly test our integration
      with those commands, but at least lets us test the backend glue code.
    - Removed a lot of duplicate and unused code which backends were using (or
      not using).  This branch drops 700 lines of code (~20%)
      in duplicity/backends!
    - Simplified expectations of backends.  Our wrapper code now does all the
      retrying, and all the exception handling.  Backends can 'fire and forget'
      trusting our wrappers to give the user a reasonable error message.
      Obviously, backends can also add more details and make nicer error
      messages.  But they don't *have* to.
    - Separate out the backend classes from our wrapper class.  Now there is no
      possibility of namespace collision.  All our API methods use one
      underscore.  Anything else (zero or two underscores) are for the backend
      class's use.
    - Added the concept of a 'backend prefix' which is used by par2 and gio
      backends to provide generic support for "schema+" in urls -- like par2+
      or gio+.  I've since marked the '--gio' flag as deprecated, in favor of
      'gio+'.  Now you can even nest such backends like
      par2+gio+file://blah/blah.
    - The switch to control which cloudfiles backend had a typo.  I fixed this,
      but I'm not sure I should have?  If we haven't had complaints, maybe we
      can just drop the old backend.
    - I manually tested all the backends we have (except hsi and tahoe -- but
      those are simple wrappers around commands and I did test those via mocks
      per above).  I also added a bunch more manual backend tests to
      ./testing/manual/backendtest.py, which can now be run like the above to
      test all the files you have configured in config.py or you can pass it a
      URL which it will use for testing (useful for backend authors).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# along with duplicity; if not, write to the Free Software Foundation,
19
19
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
20
 
 
21
import duplicity.backend
21
22
from duplicity import globals, log
22
23
 
23
24
def warn_option(option, optionvar):
26
27
 
27
28
if (globals.ssh_backend and
28
29
    globals.ssh_backend.lower().strip() == 'pexpect'):
29
 
    from . import _ssh_pexpect
 
30
    from ._ssh_pexpect import SSHPExpectBackend as SSHBackend
30
31
else:
31
32
    # take user by the hand to prevent typo driven bug reports
32
33
    if globals.ssh_backend.lower().strip() != 'paramiko':
33
34
        log.Warn(_("Warning: Selected ssh backend '%s' is neither 'paramiko nor 'pexpect'. Will use default paramiko instead.") % globals.ssh_backend)
34
35
    warn_option("--scp-command", globals.scp_command)
35
36
    warn_option("--sftp-command", globals.sftp_command)
36
 
    from . import _ssh_paramiko
 
37
    from ._ssh_paramiko import SSHParamikoBackend as SSHBackend
 
38
 
 
39
duplicity.backend.register_backend("sftp", SSHBackend)
 
40
duplicity.backend.register_backend("scp", SSHBackend)
 
41
duplicity.backend.register_backend("ssh", SSHBackend)