Determine Stacker environment file name.
161049
def get_stacker_env_file(path, environment, region):
    """"""
    for name in gen_stacker_env_files(environment, region):
        if os.path.isfile(os.path.join(path, name)):
            return name
    return "%s-%s.env" % (environment, region)
796954
protected function determineLocalFileName()
    {
        // First: try to convert server argv 0 to a real path first (absolute path to a phar).
        if (false !== ($localFilename = realpath($_SERVER['argv'][0]))) {
            return $localFilename;
        }

        // Second: try the currently running phar file now.
        if ($localFilename = \Phar::running(false)) {
            return $localFilename;
        }

        // Fall back to server argv 0 (retaining relative path) and hope best.
        return $_SERVER['argv'][0];
    }
909696
def _root_path(self):
        """'"""
        if self.ROOT_PATH_FOR_DYNACONF is not None:
            return self.ROOT_PATH_FOR_DYNACONF
        elif self._loaded_files:  # called once
            root_path = os.path.dirname(self._loaded_files[0])
            self.set("ROOT_PATH_FOR_DYNACONF", root_path)
            return root_path
7738
def pkg_resources_env(self, platform_str):
    """"""
    os_name = ''
    platform_machine = ''
    platform_release = ''
    platform_system = ''
    platform_version = ''
    sys_platform = ''

    if 'win' in platform_str:
      os_name = 'nt'
      platform_machine = 'AMD64' if '64' in platform_str else 'x86'
      platform_system = 'Windows'
      sys_platform = 'win32'
    elif 'linux' in platform_str:
      os_name = 'posix'
      platform_machine = 'x86_64' if '64' in platform_str else 'i686'
      platform_system = 'Linux'
      sys_platform = 'linux2' if self._version[0] == 2 else 'linux'
    elif 'macosx' in platform_str:
      os_name = 'posix'
      platform_str = platform_str.replace('.', '_')
      platform_machine = platform_str.split('_', 3)[-1]
      # Darwin version are macOS version + 4
      platform_release = '{}.0.0'.format(int(platform_str.split('_')[2]) + 4)
      platform_system = 'Darwin'
      platform_version = 'Darwin Kernel Version {}'.format(platform_release)
      sys_platform = 'darwin'

    return {
      'implementation_name': self.interpreter.lower(),
      'implementation_version': self.version_str,
      'os_name': os_name,
      'platform_machine': platform_machine,
      'platform_release': platform_release,
      'platform_system': platform_system,
      'platform_version': platform_version,
      'python_full_version': self.version_str,
      'platform_python_implementation': self.interpreter,
      'python_version': self.version_str[:3],
      'sys_platform': sys_platform,
    }
447398
def ensure_stacker_compat_config(config_filename):
    """"""
    try:
        with open(config_filename, 'r') as stream:
            yaml.safe_load(stream)
    except yaml.constructor.ConstructorError as yaml_error:
        if yaml_error.problem.startswith(
                'could not determine a constructor for the tag \'!'):
            LOGGER.error('"%s" appears to be a CloudFormation template, '
                         'but is located in the top level of a module '
                         'alongside the CloudFormation config files (i.e. '
                         'the file or files indicating the stack names & '
                         'parameters). Please move the template to a '
                         'subdirectory.',
                         config_filename)
            sys.exit(1)
552164
def get_environment_vars(filename):
    """"""
    if sys.platform == "linux" or sys.platform == "linux2":
        return {
            'LD_PRELOAD': path.join(LIBFAKETIME_DIR, "libfaketime.so.1"),
            'FAKETIME_SKIP_CMDS': 'nodejs',     # node doesn't seem to work in the current version.
            'FAKETIME_TIMESTAMP_FILE': filename,
        }
    elif sys.platform == "darwin":
        return {
            'DYLD_INSERT_LIBRARIES': path.join(LIBFAKETIME_DIR, "libfaketime.1.dylib"),
            'DYLD_FORCE_FLAT_NAMESPACE': '1',
            'FAKETIME_TIMESTAMP_FILE': filename,
        }
    else:
        raise RuntimeError("libfaketime does not support '{}' platform".format(sys.platform))
573266
def _find_file(self, load):
        '''
        
        '''
        path = load.get('path')
        if not path:
            return {'path': '',
                    'rel': ''}
        tgt_env = load.get('saltenv', 'base')
        return self.find_file(path, tgt_env)
564940
def _get_conf_value(suffix):
    """"""
    pymp_name = "PYMP_" + suffix
    omp_name = "OMP_" + suffix
    value = None
    for env_name in [pymp_name, omp_name]:
        # pylint: disable=no-member
        if env_name in _os.environ:
            _LOGGER.debug(
                "Using %s environment variable: %s.", env_name, _os.environ[env_name]
            )
            value = _os.environ[env_name]
            break
    return value
655437
def echo_detected_environment(env_name, env_vars):
    """"""
    env_override_name = 'DEPLOY_ENVIRONMENT'
    LOGGER.info("")
    if env_override_name in env_vars:
        LOGGER.info("Environment \"%s\" was determined from the %s environment variable.",
                    env_name,
                    env_override_name)
        LOGGER.info("If this is not correct, update "
                    "the value (or unset it to fall back to the name of "
                    "the current git branch or parent directory).")
    else:
        LOGGER.info("Environment \"%s\" was determined from the current "
                    "git branch or parent directory.",
                    env_name)
        LOGGER.info("If this is not the environment name, update the branch/folder name or "
                    "set an override value via the %s environment variable",
                    env_override_name)
    LOGGER.info("")
1141778
def get_config_filename(metadata):
    
    envvar = "{}__SETTINGS".format(underscore(metadata.name).upper())
    try:
        return environ[envvar]
    except KeyError:
        return None
38268
def system_config_dir():
    
    """
    if LINUX or SUNOS:
        path = '/etc'
    elif BSD or MACOS:
        path = '/usr/local/etc'
    else:
        path = os.environ.get('APPDATA')
    if path is None:
        path = ''
    else:
        path = os.path.join(path, 'glances')

    return path
563613
def generate_sample_stacker_module(env_root, module_dir=None):
    """"""
    if module_dir is None:
        module_dir = os.path.join(env_root,
                                  'runway-sample-tfstate.cfn')
    generate_sample_module(module_dir)
    for i in ['stacks.yaml', 'dev-us-east-1.env']:
        shutil.copyfile(
            os.path.join(ROOT,
                         'templates',
                         'stacker',
                         i),
            os.path.join(module_dir, i)
        )
    os.mkdir(os.path.join(module_dir, 'tfstate_blueprints'))
    for i in ['__init__.py', 'tf_state.py']:
        shutil.copyfile(
            os.path.join(ROOT,
                         'templates',
                         'stacker',
                         'tfstate_blueprints',
                         i),
            os.path.join(module_dir, 'tfstate_blueprints', i)
        )
    os.chmod(  # make blueprint executable
        os.path.join(module_dir, 'tfstate_blueprints', 'tf_state.py'),
        os.stat(os.path.join(module_dir,
                             'tfstate_blueprints',
                             'tf_state.py')).st_mode | 0o0111
    )
    LOGGER.info("Sample Stacker module created at %s",
                module_dir)
423771
def set_env_variables(stack, grid, platform = grid)
      ENV['STACK'] = stack
      ENV['GRID'] = grid
      ENV['PLATFORM'] = platform
    end
618956
def _nix_env():
    '''
    
    '''
    nixhome = os.path.join(os.path.expanduser('~{0}'.format(__opts__['user'])), '.nix-profile/bin/')
    return [os.path.join(nixhome, 'nix-env')]
497975
def _get_or_create_stack(name):
  """"""
  stack = getattr(_LOCAL_STACKS, name, None)
  if stack is None:
    stack = []
    setattr(_LOCAL_STACKS, name, stack)
  return stack
1329615
def get_environment(name):
    """"""
    if name == "_default":
        return env_from_template(name)
    filename = os.path.join("environments", name + ".json")
    try:
        with open(filename) as f:
            try:
                return json.loads(f.read())
            except ValueError as e:
                msg = 'LittleChef found the following error in'
                msg += ' "{0}":\n                {1}'.format(filename, str(e))
                abort(msg)
    except IOError:
        raise FileNotFoundError('File {0} not found'.format(filename))
149626
def _get_key_file_path():
        """"""
        if os.getenv(USER_HOME) is not None and os.access(os.getenv(USER_HOME),
                                                          os.W_OK):
            return os.path.join(os.getenv(USER_HOME), KEY_FILE_NAME)

        return os.path.join(os.getcwd(), KEY_FILE_NAME)