Beispiel #1
0
def get_backend_factory(uri, config):
    """get_backend_factory(uri, config)

    Parses a URI and creates the factory.

    TODO: crypto stuff are added by magic, and only s3 is supported.
          This should be configurable
    """
    type,ident = uri.split(':',1)
    if type == 's3':
        ret = lambda: s3backend.S3Backend(ident, config.to_dict())
    elif type == 'dir':
        ret = lambda: directorybackend.DirectoryBackend(ident,
                                                        config.to_dict())
    else:
        raise NotImplementedError('backend type %s not implemented' % (type))

    crypto_key = config.get_option('crypto-key').get_required()
    hash = config.get_option('hash').get_required()
    if True:
        ret2 = lambda: gpgcrypto.DataCryptoGPG(ret(), crypto_key)
    else:
        ret2 = ret
    if True:
        ret3 = lambda: gpgcrypto.NameCrypto(ret2(),
                                            crypto_key,
                                            hash_algorithm=hash)
    else:
        ret3 = ret2
    return ret3
Beispiel #2
0
def setLogLevel(config):
    logging.getLogger().setLevel(
        verbosity.to_level(config.get_option('verbosity').get_required()))
Beispiel #3
0
def _interpret_config_file(options, given_options, config):
    try:
        f = open(os.path.expanduser(
            config.get_option('config').get_required()))
    except IOError, e:
        logging.warning("shastity: can't open config file: %s", unicode(e))
Beispiel #4
0
    return (cmdname, args[1:], given_options, config)


def _interpret_config_file(options, given_options, config):
    try:
        f = open(os.path.expanduser(
            config.get_option('config').get_required()))
    except IOError, e:
        logging.warning("shastity: can't open config file: %s", unicode(e))
    else:
        for line in f:
            line = line.strip()
            k, v = line.split(' ', 1)
            if k not in given_options:
                try:
                    config.get_option(k).parse(v)
                except KeyError, e:
                    # config file option not valid with current command
                    pass


def setLogLevel(config):
    logging.getLogger().setLevel(
        verbosity.to_level(config.get_option('verbosity').get_required()))


def main():
    try:
        # TODO:
        # Boto assumes English locale. It will fail with others.
        # (Date field in S3 request)
Beispiel #5
0
def setLogLevel(config):
    logging.getLogger().setLevel(verbosity.to_level(config.get_option('verbosity').get_required()))
Beispiel #6
0
def _interpret_config_file(options, given_options, config):
    try:
        f = open(os.path.expanduser(config.get_option('config')
                                    .get_required()))
    except IOError, e:
        logging.warning("shastity: can't open config file: %s", unicode(e))
Beispiel #7
0
    return (cmdname, args[1:], given_options, config)

def _interpret_config_file(options, given_options, config):
    try:
        f = open(os.path.expanduser(config.get_option('config')
                                    .get_required()))
    except IOError, e:
        logging.warning("shastity: can't open config file: %s", unicode(e))
    else:
        for line in f:
            line = line.strip()
            k,v = line.split(' ',1)
            if k not in given_options:
                try:
                    config.get_option(k).parse(v)
                except KeyError, e:
                    # config file option not valid with current command
                    pass

def setLogLevel(config):
    logging.getLogger().setLevel(verbosity.to_level(config.get_option('verbosity').get_required()))

def main():
    try:
        # TODO:
        # Boto assumes English locale. It will fail with others.
        # (Date field in S3 request)
        # locale.setlocale(locale.LC_ALL, '')
        pass
    except locale.Error: