class GitHubAppIntegrationConfig: """GitHub App auth related config.""" app_id = environ.var( None, name='GITHUB_APP_IDENTIFIER', validator=validate_is_not_none_if_app, ) private_key = environ.var( None, name='GITHUB_PRIVATE_KEY', converter=SecretStr, validator=validate_is_not_none_if_app, ) webhook_secret = environ.var( None, name='GITHUB_WEBHOOK_SECRET', converter=lambda s: SecretStr(s) if s is not None else s, ) @property def user_agent(self): # noqa: D401 """The User-Agent value to use when hitting GitHub API.""" name = RUNTIME_CONTEXT.config.runtime.app_name version = RUNTIME_CONTEXT.config.runtime.app_version url = RUNTIME_CONTEXT.config.runtime.app_url return f'{name}/{version} (+{url})'
class RestFramework: parser_classes = environ.var("rest_framework.parsers.JSONParser", converter=csv_converter) renderer_classes = environ.var( "rest_framework.renderers.JSONRenderer", converter=csv_converter, )
class Configuration: # pylint: disable=too-few-public-methods """Application configuration from environmental variables.""" max_content_length = environ.var( converter=int, default=50000, # 50 Mb help="The maximum request content size to accept, in bytes.", ) responders = environ.var( converter=_classes_from_comma_delimited_import_paths, default="", help= "The full import paths to classes which implement the responder interface", ) handlers = environ.var( converter=_classes_from_comma_delimited_import_paths, default="", help= "The full import paths to classes which implement the handler interface", ) port = environ.var(converter=int, default=8080, help="The port for the ledge server to listen on.") thread_pool_size = environ.var( converter=_none_or_int, default=None, help="The size of the threadpool ledge will use to run handlers. If not " "supplied the default from Twisted will be used.", )
class OIDC: endpoint = environ.var( default="https://samples.auth0.com/", converter=str, help="This defines the endpoint of the OIDC provider") client_id = environ.var( default='sipam', converter=str, help= "This defines the allowed azp definition == client_id in keycloak." ) allowed_groups = environ.var( default='', converter=list_converter, help="This defines allowed values in the groups_claim") groups_claim = environ.var( default='aks', converter=str, help="This defines the key for the claim to use for groups.") bearer_auth_header_prefix = environ.var( default='OPENID', converter=str, help= "This defines the Authorization Header prefix to look for when using OIDC." )
class ConfigGradCAM: """ Config of the scripts. """ # BASIC PARAMETERS save_key: str = environ.var(name="SAVE_KEY", converter=str, default="default", help="Used as a log file name.") log_level: int = environ.var(name="LOG_LEVEL", converter=logger.get_log_level_from_name, default="INFO") use_gpu: int = environ.var(name="USE_GPU", converter=bool, default=False, help="1 if use GPU otherwise 0") # DATASET and TARGET of VISUALIZATION wnid: str = environ.var( name="WNID", default="n02113799", help= "Category Id of ImageNet for downloading. It should be a specific class of ImageNet." ) target_cls_idx: int = environ.var( name="TARGET_CLS_INDEX", converter=int, default=267, help="Specify which index of GT class corresponds to wnid.")
class Email: host = environ.var( default='mxf9a9.netcup.net', converter=str, help="The SMTP Hostname to use to send emails through." ) port = environ.var( default=587, converter=int, help="The SMTP Port to use to send emails through." ) tls = environ.bool_var( default=True, help="SMTP use TLS or not.") timeout = environ.var( default=60, converter=int, help="The Default Timeout for SMTP Connection establishment." ) backend = environ.var( default='django.core.mail.backends.smtp.EmailBackend', converter=str, help="The EMAIL Backend to use for django." ) user = environ.group(User)
class BotGroup: token = environ.var( None, help = 'The log-in token for the Discord bot account ' \ '(mutually exclusive with DFB_BOT_TOKEN_FILE)' ) token_file = environ.var( None, help = 'The path to a file containing the log-in token ' \ '(mutually exclusive with DFB_BOT_TOKEN)' ) @token.validator def _token_valid(self, attribute, value): if self.token is None and self.token_file is None: raise ValueError( 'One of DFB_BOT_TOKEN or DFB_BOT_TOKEN_FILE is required') if self.token is not None and self.token_file is not None: raise ValueError( 'Only one of DFB_BOT_TOKEN or DFB_BOT_TOKEN_FILE may be set') async def read_token(self): """Read the token from the config, possibly from the filesystem.""" return await _read_file_or_immediate_value(self.token_file, self.token)
class GitHubActionConfig: # pylint: disable=too-few-public-methods """GitHub Action config.""" workflow = environ.var( None, name='GITHUB_WORKFLOW', ) action = environ.var( None, name='GITHUB_ACTION', ) actor = environ.var( None, name='GITHUB_ACTOR', ) repository = environ.var( None, name='GITHUB_REPOSITORY', ) event_name = environ.var( None, name='GITHUB_EVENT_NAME', ) event_path = environ.var( None, converter=lambda p: p if p is None else Path(p), name='GITHUB_EVENT_PATH', ) workspace = environ.var( None, name='GITHUB_WORKSPACE', ) sha = environ.var( None, name='GITHUB_SHA', ) ref = environ.var( None, name='GITHUB_REF', ) token = environ.var( None, name='GITHUB_TOKEN', converter=lambda t: t if t is None else SecretStr(t), )
class Cfg(object): @environ.config class Sub(object): y = environ.var() x = environ.var() y = environ.var() sub = environ.group(Sub)
class FlaskConfig: # pylint: disable=R0903 """Flask specific configuration.""" SECRET_KEY = environ.var(_gen_secret_key()) DEBUG = environ.bool_var(False) TESTING = environ.bool_var(False) SQLALCHEMY_DATABASE_URI = environ.var("sqlite://") SQLALCHEMY_TRACK_MODIFICATIONS = environ.bool_var(False)
class Cfg(object): @environ.config(frozen=True) class Sub(object): z = environ.var() x = environ.var() y = environ.var() sub = environ.group(Sub)
class User: name = environ.var(converter=str, default='sipam', help="The Username to use.") password = environ.var( default='sipam', converter=str, help="The Password for the user to use.", )
class AppConfig: db_uri = environ.var() listen_uri = environ.var("tcp://*:5001") @environ.config class Unprivileged: ratelimit = environ.group(Ratelimit) unprivileged = environ.group(Unprivileged)
class AppConfig(): """ Конфигурация приложения """ env = environ.var() lang = environ.var(name="LANG") folder = environ.var(name="FOLDER")
class User: name = environ.var( converter=str, help="The Username to use." ) password = environ.var( default=None, converter=string_none_converter, help="The Password for the user to use.", )
class Database: host = environ.var(default='postgres', converter=str, help="The RDBMS Hostname to use to connect to.") port = environ.var(default=5432, converter=int, help="The RDBMS Port to use to connect to.") name = environ.var( default='sipam', converter=str, help="The Name of the RDBMS Database to use to connect to.") user = environ.group(User)
class APIConfig: scheme = environ.var('http') host = environ.var('0.0.0.0') port = environ.var('8000') @property def absolute_url(self): absolute_url = URL.build(scheme=self.scheme, host=self.host, port=self.port) if absolute_url.is_default_port(): absolute_url = absolute_url.with_port(None) return absolute_url
class SimplePay: class Environment(enum.Enum): SANDBOX = "sandbox" LIVE = "live" merchant = environ.var() secret_key = environ.var() ipn_url = environ.var() use_live = environ.var(default=False) environment = environ.var(name="SIMPLEPAY_ENVIRONMENT", converter=Environment) def __attrs_post_init__(self): self.use_live = self.environment is NoeConfig.SimplePay.Environment.LIVE
class Serial: port = environ.var('') baudrate = environ.var(115200, converter=int) bytesize = environ.var(7, converter=int) parity = environ.var('N') stopbits = environ.var(1, converter=int) timeout = environ.var(2, converter=float) vid = environ.var('') pid = environ.var('') serial = environ.var('')
class Config: @environ.config() class Bind: host = environ.var(default="localhost") port = environ.var(default="80", converter=int) bind = environ.group(Bind) database_uri = environ.var() encryption_key = environ.var() schedule_interval = environ.var( name="SCHEDULE_INTERVAL_SECONDS", converter=lambda value: timedelta(seconds=int(value)), default=50)
class Static: url = environ.var( default="/static/", help=( "URL path generated for static files. " "If you change this, backend won't serve static files with WhiteNoise anymore." ), ) root = environ.var( default="/project_noe/static_root", help=( "Where manage.py collectstatic put all static files. " "The default value is where the static files are in the Docker container" ), )
class RuntimeConfig: # pylint: disable=too-few-public-methods """Config of runtime env.""" debug = environ.bool_var(False, name='DEBUG') env = environ.var( 'prod', name='ENV', validator=attr.validators.in_(('dev', 'prod')), ) mode = environ.var( 'auto', name='OCTOMACHINERY_APP_MODE', converter=lambda val: detect_env_mode() if val == 'auto' else val, validator=attr.validators.in_(('app', 'action')), )
class Config(object): @environ.config class Twitter(object): consumer_key=environ.var() consumer_secret=environ.var() access_token=environ.var() access_token_secret=environ.var() twitter = environ.group(Twitter) @environ.config class LDA(object): num_topics=environ.var(10, converter=int) num_top_words=environ.var(20, converter=int) lda = environ.group(LDA) @environ.config class S3(object): access_key=environ.var() secret_key=environ.var() bucket=environ.var() s3 = environ.group(S3) sample_size = environ.var(5000, converter=int)
class Captcha: score = environ.var( default=0.85, converter=float, help="Captcha required score to reach for human users." + " (higher more complicated captcha)" ) private_key = environ.var( default='6LfUFukUAAAAANboVLwQASuXQrw6ayFsfwFFQtRq', converter=str, help="A private captcha key (https://www.google.com/recaptcha/intro/v3.html)" ) public_key = environ.var( default='6LfUFukUAAAAAASAapQwhYeERyh532DDYQHHHER7', converter=str, help="A public captcha key (https://www.google.com/recaptcha/intro/v3.html)" )
class AppConfig: env = environ.var(default="dev") @environ.config(frozen=True) class Ghibli: films_url = environ.var(default="https://ghibliapi.herokuapp.com/films") people_url = environ.var(default="https://ghibliapi.herokuapp.com/people") film_data_cache_key = "film_data" ghibli = environ.group(Ghibli)
class Nested(object): """A nested configuration example.""" @environ.config class Sub(object): y = environ.var() x = environ.var() sub = environ.group(Sub)
class GitHubAppIntegrationConfig: # pylint: disable=too-few-public-methods """GitHub App auth related config.""" app_id = environ.var( None, name='GITHUB_APP_IDENTIFIER', validator=validate_is_not_none_if_app, ) private_key = environ.var( None, name='GITHUB_PRIVATE_KEY', converter=lambda raw_data: None if raw_data is None else GitHubPrivateKey(raw_data.encode()), validator=validate_is_not_none_if_app, ) private_key_fingerprint = environ.var( None, name='GITHUB_PRIVATE_KEY_FINGERPRINT', validator=validate_fingerprint_if_present, ) webhook_secret = environ.var( None, name='GITHUB_WEBHOOK_SECRET', converter=lambda s: SecretStr(s) if s is not None else s, ) app_name = environ.var(None, name='OCTOMACHINERY_APP_NAME') app_version = environ.var(None, name='OCTOMACHINERY_APP_VERSION') app_url = environ.var(None, name='OCTOMACHINERY_APP_URL') @property def user_agent(self): # noqa: D401 """The User-Agent value to use when hitting GitHub API.""" return f'{self.app_name}/{self.app_version} (+{self.app_url})'
class PyNuts: input_cls = environ.var("serialiec62056", converter=convInputPlugin) input_name = environ.var("power") input_tz = environ.var("Europe/Amsterdam", converter=pytz.timezone) output_cls = environ.var("influxdb", converter=convOutputPlugin) output_name = environ.var("influxdb") loglevel = environ.var("INFO", converter=convLoglevel) influxdb_bucket = environ.var('pynuts', name='INFLUXDB_V2_BUCKET') # bit awkward, but if we put it under sub-config-class we cannot get this nice envvar @environ.config class Serial: port = environ.var('') baudrate = environ.var(115200, converter=int) bytesize = environ.var(7, converter=int) parity = environ.var('N') stopbits = environ.var(1, converter=int) timeout = environ.var(2, converter=float) vid = environ.var('') pid = environ.var('') serial = environ.var('') serial = environ.group(Serial) @environ.config class Counter: filename = environ.var('/sys/class/gpio/gpio71/value') # On Pine A64 this is PC7 / pin 11 on Pi2 header increase = environ.var(0.5, converter=float) key = environ.var('volume') interval = environ.var(0.1) counter = environ.group(Counter)
class BackendConfig(object): for name, clsobj in base.BackendRegistry.iter_(): # We have to use a magic attribute name here since `config`s don't have # a specific mixin or type we can check for try: locals()[name] = environ.group(clsobj.Config, optional=True) except AttributeError: pass module_class = environ.var(None)
class Config: @staticmethod def from_environ(environ) -> 'Config': ... cors_origin: str = environ.var(default='') mongo_connection_string: str = environ.var() google_credentials: Optional[str] = environ.var(default=None) google_application_project_name: str = environ.var() google_storage_bucket_name: str = environ.var() rabbitmq_hostname: str = environ.var(default='localhost') rabbitmq_vhost: str = environ.var(default='/') rabbitmq_port: int = environ.var(default=5672) rabbitmq_username: Optional[str] = environ.var(default=None) rabbitmq_password: Optional[str] = environ.var(default=None)