Adrien Delhorme has proposed merging lp:~adrien-delhorme/duplicity/hubic into lp:duplicity.
Requested reviews: duplicity-team (duplicity-team) For more details, see: https://code.launchpad.net/~adrien-delhorme/duplicity/hubic/+merge/240539 Add Hubic support through pyrax and a custom pyrax_identity module. -- https://code.launchpad.net/~adrien-delhorme/duplicity/hubic/+merge/240539 Your team duplicity-team is requested to review the proposed merge of lp:~adrien-delhorme/duplicity/hubic into lp:duplicity.
=== added file 'duplicity/backends/hubicbackend.py' --- duplicity/backends/hubicbackend.py 1970-01-01 00:00:00 +0000 +++ duplicity/backends/hubicbackend.py 2014-11-04 06:43:10 +0000 @@ -0,0 +1,82 @@ +# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- +# +# Copyright 2013 J.P. Krauss <[email protected]> +# +# This file is part of duplicity. +# +# Duplicity 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 2 of the License, or (at your +# option) any later version. +# +# Duplicity 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 duplicity; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import os + +import duplicity.backend +from duplicity import log +from duplicity import util +from duplicity.errors import BackendException +from ._cf_pyrax import PyraxBackend + + +class HubicBackend(PyraxBackend): + """ + Backend for Hubic using Pyrax + """ + def __init__(self, parsed_url): + try: + import pyrax + except ImportError: + raise BackendException("This backend requires the pyrax " + "library available from Rackspace.") + + # Inform Pyrax that we're talking to Hubic + pyrax.set_setting("identity_type", "duplicity.backends.pyrax_identity.hubic.HubicIdentity") + + CREDENTIALS_FILE = os.path.expanduser("~/.pyrax_cloud_credentials") + if os.path.exists(CREDENTIALS_FILE): + try: + pyrax.set_credential_file(CREDENTIALS_FILE) + except Exception as e: + log.FatalError("Connection failed, please check your credentials: %s %s" + % (e.__class__.__name__, util.uexc(e)), + log.ErrorCode.connection_failed) + + else: + conn_kwargs = {} + + if 'CLOUDFILES_USERNAME' not in os.environ: + raise BackendException('CLOUDFILES_USERNAME environment variable' + 'not set.') + + if 'CLOUDFILES_APIKEY' not in os.environ: + raise BackendException('CLOUDFILES_APIKEY environment variable not set.') + + conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME'] + conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY'] + + if 'CLOUDFILES_REGION' in os.environ: + conn_kwargs['region'] = os.environ['CLOUDFILES_REGION'] + + try: + pyrax.set_credentials(**conn_kwargs) + except Exception as e: + log.FatalError("Connection failed, please check your credentials: %s %s" + % (e.__class__.__name__, util.uexc(e)), + log.ErrorCode.connection_failed) + + container = parsed_url.path.lstrip('/') + + self.client_exc = pyrax.exceptions.ClientException + self.nso_exc = pyrax.exceptions.NoSuchObject + self.container = pyrax.cloudfiles.create_container(container) + +duplicity.backend.register_backend("hubic", HubicBackend) === modified file 'setup.py' --- setup.py 2014-10-27 02:27:36 +0000 +++ setup.py 2014-11-04 06:43:10 +0000 @@ -132,6 +132,7 @@ url="http://duplicity.nongnu.org/index.html", packages = ['duplicity', 'duplicity.backends', + 'duplicity.backends.pyrax_identity', 'testing', 'testing.functional', 'testing.overrides',
_______________________________________________ Mailing list: https://launchpad.net/~duplicity-team Post to : [email protected] Unsubscribe : https://launchpad.net/~duplicity-team More help : https://help.launchpad.net/ListHelp

