# Path: cloudbio/fabutils.py
# def quiet():
#     return settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True)
# 
# Path: cloudbio/fabutils.py
# def configure_runsudo(env):
#     """Setup env variable with safe_sudo and safe_run,
#     supporting non-privileged users and local execution.
#     """
#     env.is_local = env.hosts == ["localhost"]
#     if env.is_local:
#         env.safe_put = local_put
#         env.safe_sed = local_sed
#         env.safe_comment = local_comment
#         env.safe_contains = local_contains
#         env.safe_append = local_append
#         env.safe_exists = local_exists
#         env.safe_run = run_local()
#         env.safe_run_output = run_local(capture=True)
#     else:
#         env.safe_put = put
#         env.safe_sed = sed
#         env.safe_comment = comment
#         env.safe_contains = contains
#         env.safe_append = append
#         env.safe_exists = exists
#         env.safe_run = run
#         env.safe_run_output = run_output
#     if isinstance(getattr(env, "use_sudo", "true"), six.string_types):
#         if getattr(env, "use_sudo", "true").lower() in ["true", "yes"]:
#             env.use_sudo = True
#             if env.is_local:
#                 env.safe_sudo = run_local(True)
#             else:
#                 env.safe_sudo = sudo
#         else:
#             env.use_sudo = False
#             if env.is_local:
#                 env.safe_sudo = run_local()
#             else:
#                 env.safe_sudo = run


import os
import subprocess
from fabric.api import env
from cloudbio.fabutils import quiet
from cloudbio.fabutils import configure_runsudo
from cloudbio.custom import system
"""Configuration details for specific server types.

This module contains functions that help with initializing a Fabric environment
for standard server types.
"""



def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment.

    In low-level terms, this method attempts to populate various values in the fabric
    env data structure for use other places in CloudBioLinux.
    """
    if "distribution" not in env:
        env.distribution = "__auto__"
    if "dist_name" not in env:
        env.dist_name = "__auto__"
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()

# Path: cloudbio/fabutils.py
# def quiet():
#     return settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=True)
# 
# Path: cloudbio/fabutils.py
# def configure_runsudo(env):
#     """Setup env variable with safe_sudo and safe_run,
#     supporting non-privileged users and local execution.
#     """
#     env.is_local = env.hosts == ["localhost"]
#     if env.is_local:
#         env.safe_put = local_put
#         env.safe_sed = local_sed
#         env.safe_comment = local_comment
#         env.safe_contains = local_contains
#         env.safe_append = local_append
#         env.safe_exists = local_exists
#         env.safe_run = run_local()
#         env.safe_run_output = run_local(capture=True)
#     else:
#         env.safe_put = put
#         env.safe_sed = sed
#         env.safe_comment = comment
#         env.safe_contains = contains
#         env.safe_append = append
#         env.safe_exists = exists
#         env.safe_run = run
#         env.safe_run_output = run_output
#     if isinstance(getattr(env, "use_sudo", "true"), six.string_types):
#         if getattr(env, "use_sudo", "true").lower() in ["true", "yes"]:
#             env.use_sudo = True
#             if env.is_local:
#                 env.safe_sudo = run_local(True)
#             else:
#                 env.safe_sudo = sudo
#         else:
#             env.use_sudo = False
#             if env.is_local:
#                 env.safe_sudo = run_local()
#             else:
#                 env.safe_sudo = run


# Path: cloudbio/distribution.py
import os
import subprocess
from fabric.api import env
from cloudbio.fabutils import quiet
from cloudbio.fabutils import configure_runsudo
from cloudbio.custom import system

"""Configuration details for specific server types.

This module contains functions that help with initializing a Fabric environment
for standard server types.
"""



def _setup_distribution_environment(ignore_distcheck=False):
    """Setup distribution environment.

    In low-level terms, this method attempts to populate various values in the fabric
    env data structure for use other places in CloudBioLinux.
    """
    if "distribution" not in env:
        env.distribution = "__auto__"
    if "dist_name" not in env:
        env.dist_name = "__auto__"
    env.logger.info("Distribution %s" % env.distribution)

    if env.hosts == ["vagrant"]:
        _setup_vagrant_environment()
    elif env.hosts == ["localhost"]:
        _setup_local_environment()

    configure_runsudo(env)