Example #1
0
    def from_env(cls):
        env = envparse.Env()
        env.read_envfile()

        return cls(phone=env.str('VK_PHONE'),
                   password=env.str('VK_PASSWORD'),
                   session=None)
Example #2
0
def create_dataclass_inputs_from_env(schema):
    env = envparse.Env(**schema)
    result = {}
    for key in schema.keys():
        result[key.lower()] = env(key)
    return result
Example #3
0
import time
import uuid

import envparse

import yaml

from flask import Flask, Response, request

DB_POOL_SIZE = 5
MAX_OLD_DBS = 2
MAX_DB_SIZE = 10000000  # Bytes
CONFIG_REFRESH_TIME = 5  # Seconds

app = Flask(__name__)
env = envparse.Env()


class DB(object):
    """Database manager."""

    def __init__(self, base, num):
        self.name = 'db/{}-{}.db'.format(base, num)
        self.db = None

    def create_db(self):
        """Create sqlite3 database and requests table."""

        if not self.db:
            self.db = sqlite3.connect(self.name)
            self.db.execute(
Example #4
0
def read_secret():
    env = envparse.Env()
    env.read_envfile('../backend/.env')
    return env('DATABASE_SECRET')
Example #5
0
import smtplib
from email.encoders import encode_base64
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formatdate, make_msgid

import envparse


env = envparse.Env(
    TINYSMTP_SERVER=str,
    TINYSMTP_PORT=dict(cast=int, default=25),
    TINYSMTP_USERNAME=str,
    TINYSMTP_PASSWORD=str,
    TINYSMTP_SSL=dict(cast=bool, default=False),
    TINYSMTP_TLS=dict(cast=bool, default=False),
    TINYSMTP_DEBUG=dict(cast=bool, default=False)
)


class Connection(object):
    def __init__(self, hostname=None, port=None, username=None, password=None,
                 ssl=False, tls=False, debug=False):
        self.hostname = hostname or env('TINYSMTP_SERVER')
        self.port = env('TINYSMTP_PORT', default=25)
        self.username = username or env('TINYSMTP_USERNAME')
        self.password = password or env('TINYSMTP_PASSWORD')
        self.ssl = ssl or env('TINYSMTP_SSL')
        self.tls = tls or env('TINYSMTP_TLS')
        self.debug = debug or env('TINYSMTP_DEBUG')
Example #6
0
 def from_env(cls) -> BotConfig:
     env = envparse.Env()
     return cls(TOKEN=env.str('ARTEM_BOT_TOKEN'))
Example #7
0
 def from_env(cls) -> AirtableConfig:
     env = envparse.Env()
     return cls(API_URL=env.str('AIRTABLE_API_URL'),
                API_SECRET=env.str('AIRTABLE_API_SECRET'))
Example #8
0
import smtplib
from email.encoders import encode_base64
from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formatdate, make_msgid

import envparse

env = envparse.Env(TINYSMTP_SERVER=str,
                   TINYSMTP_PORT=(int, 25),
                   TINYSMTP_USERNAME=str,
                   TINYSMTP_PASSWORD=str,
                   TINYSMTP_SSL=(bool, False),
                   TINYSMTP_TLS=(bool, False),
                   TINYSMTP_DEBUG=(bool, False))


class Connection(object):
    def __init__(self,
                 hostname=None,
                 port=None,
                 username=None,
                 password=None,
                 ssl=False,
                 tls=False,
                 debug=False):
        self.hostname = hostname or env('TINYSMTP_SERVER')
        self.port = env('TINYSMTP_PORT', default=25)
        self.username = username or env('TINYSMTP_USERNAME')
        self.password = password or env('TINYSMTP_PASSWORD')
Example #9
0
import envparse
import nsq
import nsq.protocol
import nsq.sync

env = envparse.Env(NSQ_TCP_ADDRESS=str, NSQ_TOPIC=str)


def lambda_handler(event, _):
    host, port = env.str('NSQ_TCP_ADDRESS').split(':')
    topic = env.str('NSQ_TOPIC')

    conn = nsq.sync.SyncConn()
    conn.connect(host, port)

    messages = [rec['kinesis']['data'].encode('utf-8')
                for rec in event['Records']]

    conn.send(nsq.protocol.mpub(topic, messages))