def get_instance_home_by_instance_name(shell, instance_name):
    user_home = get_userhome_by_username(shell, instance_name)
    if not user_home:
        pathtool = file_system.getPathToolByShell(shell)
        user_home = file_system.Path(r'/home/%s' % instance_name, pathtool)

    return compose_instance_home_by_userhome(user_home)
def get_userhome_by_username(shell, username):
    r'shellutils.Shell, basestring -> file_system.Path?'
    pathtool = file_system.getPathToolByShell(shell)
    safe_executor = fptools.safeFunc(
        base_shell_discoverer.get_command_executor(shell))
    return safe_executor(
        base_shell_discoverer.GetUserHomeOnUnix(username, pathtool))
def get_instance_home_by_instance_name(shell, instance_name):
    user_home = get_userhome_by_username(shell, instance_name)
    if not user_home:
        pathtool = file_system.getPathToolByShell(shell)
        user_home = file_system.Path(r'/home/%s' % instance_name, pathtool)

    return compose_instance_home_by_userhome(user_home)
def discover_default_pf(shell, pf_path, system_name):
    '''
    Discover DEFAULT.PFL for particular system based on any profile path of
    this system.
    @return: pair of profile path and its parsed content
    @types: shellutils.Shell, str, str -> (File?, sap_discoverer.IniDocument?)
    '''
    _info = (system_name, pf_path)
    logger.info("Discover DEFAULT.pl for %s system based on %s" % _info)
    pathtool = file_system.getPathToolByShell(shell)
    root_path = sap_discoverer.findSystemBasePath(pf_path, system_name)
    sys_layout = sap_discoverer.Layout(pathtool, root_path, system_name)
    default_pf_path = sys_layout.getDefaultProfileFilePath()
    logger.info("Default profile path found: %s" % default_pf_path)
    return read_pf(shell, default_pf_path)
def discover_default_pf(shell, pf_path, system_name):
    '''
    Discover DEFAULT.PFL for particular system based on any profile path of
    this system.
    @return: pair of profile path and its parsed content
    @types: shellutils.Shell, str, str -> (File?, sap_discoverer.IniDocument?)
    '''
    _info = (system_name, pf_path)
    logger.info("Discover DEFAULT.pl for %s system based on %s" % _info)
    pathtool = file_system.getPathToolByShell(shell)
    root_path = sap_discoverer.findSystemBasePath(pf_path, system_name)
    sys_layout = sap_discoverer.Layout(pathtool, root_path, system_name)
    default_pf_path = sys_layout.getDefaultProfileFilePath()
    logger.info("Default profile path found: %s" % default_pf_path)
    return read_pf(shell, default_pf_path)
def get_userhome_by_username(shell, username):
    r'shellutils.Shell, basestring -> file_system.Path?'
    pathtool = file_system.getPathToolByShell(shell)
    safe_executor = fptools.safeFunc(base_shell_discoverer.get_command_executor(shell))
    return safe_executor(base_shell_discoverer.GetUserHomeOnUnix(username,
                                                                 pathtool))