示例#1
0
    def __init__(self, config=None):
        super(ArchiveSession, self).__init__()
        config = internetarchive.config.get_config(config)
        self.cookies = requests.cookies.cookiejar_from_dict(
            config.get('cookies', {}))
        if 'logged-in-user' not in self.cookies:
            self.cookies['logged-in-user'] = os.environ.get(
                'IA_LOGGED_IN_USER')
        if 'logged-in-sig' not in self.cookies:
            self.cookies['logged-in-sig'] = os.environ.get('IA_LOGGED_IN_SIG')

        self.config = config
        self.secure = config.get('secure', False)

        s3_config = self.config.get('s3', {})
        self.access_key = s3_config.get(('access_key'),
                                        os.environ.get('IAS3_ACCESS_KEY'))
        self.secret_key = s3_config.get(('secret_key'),
                                        os.environ.get('IAS3_SECRET_KEY'))

        self.logging_config = config.get('logging', {})
        if self.logging_config:
            _level = self.log_level[self.logging_config.get('level', 'NOTSET')]
            log_file = 'internetarchive.log'
            self.set_file_logger(_level, log_file)
示例#2
0
    def __init__(self, config=None):
        super(ArchiveSession, self).__init__()
        config = internetarchive.config.get_config(config)
        self.cookies = requests.cookies.cookiejar_from_dict(config.get('cookies', {}))
        if 'logged-in-user' not in self.cookies:
            self.cookies['logged-in-user'] = os.environ.get('IA_LOGGED_IN_USER')
        if 'logged-in-sig' not in self.cookies:
            self.cookies['logged-in-sig'] = os.environ.get('IA_LOGGED_IN_SIG')

        self.config = config
        self.secure = config.get('secure', False)

        s3_config = self.config.get('s3', {})
        self.access_key = s3_config.get(('access_key'), os.environ.get('IAS3_ACCESS_KEY'))
        self.secret_key = s3_config.get(('secret_key'), os.environ.get('IAS3_SECRET_KEY'))

        self.logging_config = config.get('logging', {})
        if self.logging_config:
            _level = self.log_level[self.logging_config.get('level', 'NOTSET')]
            log_file = 'internetarchive.log'
            self.set_file_logger(_level, log_file)
示例#3
0
    def __init__(self, config=None):
        super(ArchiveSession, self).__init__()
        config = internetarchive.config.get_config(config)
        self.cookies = requests.cookies.cookiejar_from_dict(config.get('cookies', {}))
        if not 'logged-in-user' in self.cookies:
            self.cookies['logged-in-user'] = os.environ.get('IA_LOGGED_IN_USER')
        if not 'logged-in-sig' in self.cookies:
            self.cookies['logged-in-sig'] = os.environ.get('IA_LOGGED_IN_SIG')

        self.config = config
        self.secure = config.get('secure', False)

        s3_config = self.config.get('s3', {})
        self.access_key = s3_config.get(('access_key'), os.environ.get('IAS3_ACCESS_KEY', os.environ.get('AWS_ACCESS_KEY_ID')))
        self.secret_key = s3_config.get(('secret_key'), os.environ.get('IAS3_SECRET_KEY', os.environ.get('AWS_SECRET_ACCESS_KEY')))

        # If access/secret keys are not in config or defined set
        # IAS3_* env variables, check for AWS_* env variables, and warn
        # about pending deprecation of AWS_* env variables.
        warnings.simplefilter('once')
        if not self.access_key:
            self.access_key = os.environ.get('AWS_ACCESS_KEY_ID')
            if self.access_key:
                warnings.warn('AWS_ACCESS_KEY_ID will soon be deprecated, Please use '
                              'IAS3_ACCESS_KEY.', PendingDeprecationWarning)
        if not self.secret_key:
            self.secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY')
            if self.secret_key:
                warnings.warn('AWS_SECRET_ACCESS_KEY will soon be deprecated, Please use '
                              'IAS3_SECRET_KEY.', PendingDeprecationWarning)

        self.logging_config = config.get('logging', {})
        if self.logging_config:
            _level = self.log_level[self.logging_config.get('level', 'NOTSET')]
            log_file = 'internetarchive.log'
            self.set_file_logger(_level, log_file)