Exemplo n.º 1
0
def gallery():
    images = []
    user = session.get('username')
    image_names = db.select_all_images(user)
    for name in image_names:
        image_data = s3.get_object("eli.samek.image-gallery", name[0])["Body"].read()
        image = base64.b64encode(image_data).decode("utf-8")
        images.append(image)
    return render_template('gallery.html', images=images)
Exemplo n.º 2
0
    def test_get_document_succeeded(self, m_boto3):
        file_body = Mock()
        file_body.read.return_value = "abcdefghij".encode()

        aws_response = {"Body": file_body}
        m_boto3.client.return_value.get_object.return_value = aws_response
        response = s3.get_object("bar", "baz")

        self.assertIsNotNone(response)
        m_boto3.client.return_value.get_object.assert_called_once()
Exemplo n.º 3
0
    def test_get_document_exception(self, m_boto3):
        m_boto3.client.return_value.get_object.side_effect = Exception()

        response = s3.get_object("bar", "baz")
        self.assertIsNone(response)
def get_telegram_chats() -> dict:
    config_object = s3.get_object('telegram-chats.json')
    return json.loads(config_object)
Exemplo n.º 5
0
def get_telegram_token():
    telegram_credentials = json.loads(s3.get_object('telegram-creds.json'))
    return telegram_credentials['credentials']
Exemplo n.º 6
0
def get_google_credentials() -> ServiceAccountCredentials:
    google_creds_json = json.loads(s3.get_object('zavetchurch-google-creds.json'))

    scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
    credentials = ServiceAccountCredentials.from_json_keyfile_dict(google_creds_json, scope)
    return credentials