<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def gen_shell(opts, **kwargs):
    '''
    Return the correct shell interface for the target system
    '''
    if kwargs['winrm']:
        try:
            import saltwinshell
            shell = saltwinshell.Shell(opts, **kwargs)
        except ImportError:
            log.error('The saltwinshell library is not available')
            sys.exit(salt.defaults.exitcodes.EX_GENERIC)
    else:
        shell = Shell(opts, **kwargs)
    return shell