def connect_to_s3(): boto_kwargs = {} try: with open(CONFIG_FILE, 'r') as f: p = Properties() p.load(f) access_key = p.get('accessKey') if access_key: logger.debug('Reading access key from {0}'.format(CONFIG_FILE)) boto_kwargs['aws_access_key_id'] = access_key secret_key = p.get('secretKey') if secret_key: logger.debug('Reading access key from {0}'.format(CONFIG_FILE)) boto_kwargs['aws_secret_access_key'] = secret_key except IOError: logger.debug('Could not load {0}, using ENV vars'.format(CONFIG_FILE)) config = Config(connect_timeout=4, read_timeout=4) return boto3.resource('s3', config=config, **boto_kwargs)
def __setattr__(self, name, value): # For each property assigned to the instance object, we write it to the #file, If it doesn't exist we add it. app_properties = Properties() with open(APP_PROP_FILE, "r") as app_property_file: app_properties.load(app_property_file) current_properties = app_properties.propertyNames() if name not in current_properties or value != app_properties.get(name): with open(APP_PROP_FILE, "w") as app_property_file: app_properties[name] = value app_properties.store(app_property_file) super(MyAppProperties, self).__setattr__(name, value)