当前位置: 首页>>代码示例>>Python>>正文


Python dotenv.load_dotenv方法代码示例

本文整理汇总了Python中dotenv.load_dotenv方法的典型用法代码示例。如果您正苦于以下问题:Python dotenv.load_dotenv方法的具体用法?Python dotenv.load_dotenv怎么用?Python dotenv.load_dotenv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dotenv的用法示例。


在下文中一共展示了dotenv.load_dotenv方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def __init__(self, add_default_commands=True, create_app=None,
                 add_version_option=True, load_dotenv=True, **extra):
        params = list(extra.pop('params', None) or ())

        if add_version_option:
            params.append(version_option)

        AppGroup.__init__(self, params=params, **extra)
        self.create_app = create_app
        self.load_dotenv = load_dotenv

        if add_default_commands:
            self.add_command(run_command)
            self.add_command(shell_command)
            self.add_command(routes_command)

        self._loaded_plugin_commands = False 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:19,代码来源:cli.py

示例2: main

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def main(self, *args, **kwargs):
        # Set a global flag that indicates that we were invoked from the
        # command line interface. This is detected by Flask.run to make the
        # call into a no-op. This is necessary to avoid ugly errors when the
        # script that is loaded here also attempts to start a server.
        os.environ['FLASK_RUN_FROM_CLI'] = 'true'

        if get_load_dotenv(self.load_dotenv):
            load_dotenv()

        obj = kwargs.get('obj')

        if obj is None:
            obj = ScriptInfo(create_app=self.create_app)

        kwargs['obj'] = obj
        kwargs.setdefault('auto_envvar_prefix', 'FLASK')
        return super(FlaskGroup, self).main(*args, **kwargs) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:cli.py

示例3: __init__

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def __init__(self, add_default_commands=True, create_app=None,
                 add_version_option=True, load_dotenv=True,
                 set_debug_flag=True, **extra):
        params = list(extra.pop('params', None) or ())

        if add_version_option:
            params.append(version_option)

        AppGroup.__init__(self, params=params, **extra)
        self.create_app = create_app
        self.load_dotenv = load_dotenv
        self.set_debug_flag = set_debug_flag

        if add_default_commands:
            self.add_command(run_command)
            self.add_command(shell_command)
            self.add_command(routes_command)

        self._loaded_plugin_commands = False 
开发者ID:PacktPublishing,项目名称:Building-Recommendation-Systems-with-Python,代码行数:21,代码来源:cli.py

示例4: main

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def main(self, *args, **kwargs):
        # Set a global flag that indicates that we were invoked from the
        # command line interface. This is detected by Flask.run to make the
        # call into a no-op. This is necessary to avoid ugly errors when the
        # script that is loaded here also attempts to start a server.
        os.environ['FLASK_RUN_FROM_CLI'] = 'true'

        if get_load_dotenv(self.load_dotenv):
            load_dotenv()

        obj = kwargs.get('obj')

        if obj is None:
            obj = ScriptInfo(create_app=self.create_app,
                             set_debug_flag=self.set_debug_flag)

        kwargs['obj'] = obj
        kwargs.setdefault('auto_envvar_prefix', 'FLASK')
        return super(FlaskGroup, self).main(*args, **kwargs) 
开发者ID:PacktPublishing,项目名称:Building-Recommendation-Systems-with-Python,代码行数:21,代码来源:cli.py

示例5: resolve_dotenv_file

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def resolve_dotenv_file(path, stage=None):
    '''
    Resolve dotenv file and load environment vars if it exists.
    If stage parameter is provided, then stage specific .env file is resolved,
    for instance .env.production if stage=production etc.
    If stage is None, just .env file is resolved.
    '''
    filename = '.env' + ('' if not stage else '.{}'.format(stage))
    dotenv_path = os.path.join(path, filename)
    fallback_path = os.path.join(path, '.env')

    if fs.exists(dotenv_path):
        info('Resolving env file: {}'.format(cyan(dotenv_path)))
        dotenv.load_dotenv(dotenv_path)

    elif fs.exists(fallback_path):
        info('Resolving env file: {}'.format(cyan(fallback_path)))
        dotenv.load_dotenv(fallback_path) 
开发者ID:kabirbaidhya,项目名称:boss,代码行数:20,代码来源:config.py

示例6: load_dot_env

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def load_dot_env():
    """Loads .env file into sys.environ."""
    if not environments.PIPENV_DONT_LOAD_ENV:
        # If the project doesn't exist yet, check current directory for a .env file
        project_directory = project.project_directory or "."
        dotenv_file = environments.PIPENV_DOTENV_LOCATION or os.sep.join(
            [project_directory, ".env"]
        )

        if os.path.isfile(dotenv_file):
            click.echo(
                crayons.normal(fix_utf8("Loading .env environment variables…"), bold=True),
                err=True,
            )
        else:
            if environments.PIPENV_DOTENV_LOCATION:
                click.echo(
                    "{0}: file {1}={2} does not exist!!\n{3}".format(
                        crayons.red("Warning", bold=True),
                        crayons.normal("PIPENV_DOTENV_LOCATION", bold=True),
                        crayons.normal(environments.PIPENV_DOTENV_LOCATION, bold=True),
                        crayons.red("Not loading environment variables.", bold=True),
                    ),
                    err=True,
                )
        dotenv.load_dotenv(dotenv_file, override=True)
        six.moves.reload_module(environments) 
开发者ID:pypa,项目名称:pipenv,代码行数:29,代码来源:core.py

示例7: PrepareEnvironmentVars

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def PrepareEnvironmentVars(environmentName, action):
    # Reads the .env file from the repository
    # Returns an array with all the env vars, inclduing modificatoins per env
    devwebsport = 'DEV_WEB_GUEST_SECURE_PORT'
    dotenv.load_dotenv()
    envArray = os.environ.copy()
    envArray['RUN_BY_PYTHON'] = 'yes'
    envArray['ENVIRONMENT'] = environmentName
    envArray['HOMEPATH'] = '/home'
    if (environmentName == 'dev'):
        envArray['WEB_HOST_PORT'] = envArray['DEV_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['DEV_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['DEV_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
    if (environmentName == 'stage'):
        envArray['WEB_HOST_PORT'] = envArray['STAGE_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['STAGE_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['STAGE_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
        envArray['AWS_S3_BUCKET'] = envArray['STAGE_AWS_S3_BUCKET']
    if (environmentName == 'prod'):
        envArray['WEB_HOST_PORT'] = envArray['PROD_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['PRDO_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['PROD_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
        envArray['AWS_S3_BUCKET'] = envArray['PROD_AWS_S3_BUCKET']
    return envArray 
开发者ID:devopsloft,项目名称:devopsloft,代码行数:32,代码来源:spin-docker.py

示例8: PrepareEnvironmentVars

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def PrepareEnvironmentVars(environment, action):
    devwebsport = 'DEV_WEB_GUEST_SECURE_PORT'
    dotenv.load_dotenv()
    envArray = os.environ.copy()
    envArray['RUN_BY_PYTHON'] = 'yes'
    envArray['ENVIRONMENT'] = environment
    envArray['HOMEPATH'] = '/home'
    if (environment == 'dev'):
        envArray['WEB_HOST_PORT'] = envArray['DEV_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['DEV_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['DEV_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
    if (environment == 'stage'):
        envArray['WEB_HOST_PORT'] = envArray['STAGE_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['STAGE_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['STAGE_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
        envArray['AWS_S3_BUCKET'] = envArray['STAGE_AWS_S3_BUCKET']
    if (environment == 'prod'):
        envArray['WEB_HOST_PORT'] = envArray['PROD_WEB_HOST_PORT']
        envArray['WEB_GUEST_PORT'] = envArray['PRDO_WEB_GUEST_PORT']
        envArray['WEB_HOST_SECURE_PORT'] = \
            envArray['PROD_WEB_HOST_SECURE_PORT']
        envArray['WEB_GUEST_SECURE_PORT'] = envArray[devwebsport]
        envArray['AWS_S3_BUCKET'] = envArray['PROD_AWS_S3_BUCKET']
    return envArray 
开发者ID:devopsloft,项目名称:devopsloft,代码行数:30,代码来源:ecs.py

示例9: bootstrap_app

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def bootstrap_app() -> App:
    """This is bootstrap function independent from the context.

    This should be used for Web, CLI, or worker context."""
    config_path = os.environ.get(
        "CONFIG_PATH", os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, ".env_file")
    )
    dotenv.load_dotenv(config_path)
    settings = {
        "payments.login": os.environ["PAYMENTS_LOGIN"],
        "payments.password": os.environ["PAYMENTS_PASSWORD"],
        "email.host": os.environ["EMAIL_HOST"],
        "email.port": os.environ["EMAIL_PORT"],
        "email.username": os.environ["EMAIL_USERNAME"],
        "email.password": os.environ["EMAIL_PASSWORD"],
        "email.from.name": os.environ["EMAIL_FROM_NAME"],
        "email.from.address": os.environ["EMAIL_FROM_ADDRESS"],
        "redis.host": os.environ["REDIS_HOST"],
    }

    engine = create_engine(os.environ["DB_DSN"])
    connection_provider = ThreadlocalConnectionProvider(engine)
    dependency_injector = _setup_dependency_injection(settings, connection_provider)
    _setup_orm_events(dependency_injector)

    _create_db_schema(engine)  # TEMPORARY

    return App(connection_provider, dependency_injector) 
开发者ID:Enforcer,项目名称:clean-architecture,代码行数:30,代码来源:__init__.py

示例10: if_exists_load_env

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def if_exists_load_env(name):
    inspect_file = inspect.getfile(inspect.currentframe())
    env_path = os.path.dirname(os.path.abspath(inspect_file))
    env_file = "{env_path}/{name}".format(env_path=env_path, name=name)

    if os.path.exists(env_file):
        dotenv.load_dotenv(env_file) 
开发者ID:Frojd,项目名称:Wagtail-Pipit,代码行数:9,代码来源:manage.py

示例11: load_dotenv

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def load_dotenv():
    current_path = os.path.abspath(os.path.dirname(__file__))
    dotenv_file = os.path.join(current_path, ".env")
    if os.path.isfile(dotenv_file):
        dotenv.load_dotenv(dotenv_file) 
开发者ID:habitissimo,项目名称:myaas,代码行数:7,代码来源:__init__.py

示例12: get_workspace

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def get_workspace():
    dotenv.load_dotenv()
    workspace_name = os.environ.get("WORKSPACE")
    resource_group = os.environ.get("RESOURCE_GROUP")
    subscription_id = os.environ.get("SUBSCRIPTION_ID")
    tenant_id = os.environ.get("TENANT_ID")
    app_id = os.environ.get("SP_APP_ID")
    app_secret = os.environ.get("SP_APP_SECRET")

    service_principal = ServicePrincipalAuthentication(
        tenant_id=tenant_id,
        service_principal_id=app_id,
        service_principal_password=app_secret)

    try:
        aml_workspace = Workspace.get(
            name=workspace_name,
            subscription_id=subscription_id,
            resource_group=resource_group,
            auth=service_principal)

        return aml_workspace
    except Exception as caught_exception:
        print("Error while retrieving Workspace...")
        print(str(caught_exception))
        sys.exit(1) 
开发者ID:rsethur,项目名称:MLOps,代码行数:28,代码来源:AzureMLUtils.py

示例13: init

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def init():
    global model
    print("GPU USAGE: ", tf.test.is_gpu_available())
    model_path = Model.get_model_path(MODEL_FILE_NAME)
    dotenv.load_dotenv()
    print("model_path: ", model_path)
    # deserialize the model file back into a sklearn model
    model = keras.models.load_model(model_path)
    print("Model Loaded") 
开发者ID:rsethur,项目名称:MLOps,代码行数:11,代码来源:batch_score.py

示例14: main

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def main():

    model_name, dataset_name = getRuntimeArgs()
    dotenv.load_dotenv()

    run = Run.get_context()

    if run._run_id.startswith("_OfflineRun"):
        run = None

    credit_data_df = None

    #Load data from Dataset or from local file(for offline runs)
    if run is None:
        dataset_filename = os.environ.get("DATASET_FILE_NAME", )
        credit_data_df = pd.read_csv("dataset/" +dataset_filename)
    else:
        dataset = Dataset.get_by_name(workspace=run.experiment.workspace, name=dataset_name)
        #dataset = run.input_datasets[dataset_name]
        credit_data_df = dataset.to_pandas_dataframe()

    clf = model_train(credit_data_df, run)

    #copying to "outputs" directory, automatically uploads it to azure ml
    output_dir = './outputs/'
    os.makedirs(output_dir, exist_ok=True)
    joblib.dump(value=clf, filename=output_dir+model_name)

    #run.upload_file(name="./outputs/" + model_file_name, path_or_stream=model_file_name) 
开发者ID:rsethur,项目名称:MLOps,代码行数:31,代码来源:train.py

示例15: _reload_env

# 需要导入模块: import dotenv [as 别名]
# 或者: from dotenv import load_dotenv [as 别名]
def _reload_env(self):
        import dotenv
        dotenv.load_dotenv(".env") 
开发者ID:texta-tk,项目名称:texta,代码行数:5,代码来源:mlp_lite.py


注:本文中的dotenv.load_dotenv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。