(target, default='')
return output.decode('latin-1')
Interface to the system's file command.

        The function uses the -b option of the file command to have it
        omit the filename in its output. Follow the symlinks. It returns
        default in case the command should fail.
Interface to the system's file command.
Interface to the system s file command .
def _syscmd_file(target, default=''):

    """ Interface to the system's file command.

        The function uses the -b option of the file command to have it
        omit the filename in its output. Follow the symlinks. It returns
        default in case the command should fail.

    """
    if sys.platform in ('dos', 'win32', 'win16'):
        # XXX Others too ?
        return default

    import subprocess
    target = _follow_symlinks(target)
    # "file" output is locale dependent: force the usage of the C locale
    # to get deterministic behavior.
    env = dict(os.environ, LC_ALL='C')
    try:
        # -b: do not prepend filenames to output lines (brief mode)
        output = subprocess.check_output(['file', '-b', target],
                                         stderr=subprocess.DEVNULL,
                                         env=env)
    except (OSError, subprocess.CalledProcessError):
        return default
    if not output:
        return default
    # With the C locale, the output should be mostly ASCII-compatible.
    # Decode from Latin-1 to prevent Unicode decode error.
    return output.decode('latin-1')
def _syscmd_file ( target , default = '' ) : if sys . platform in ( 'dos' , 'win32' , 'win16' ) : # XXX Others too ? return default import subprocess target = _follow_symlinks ( target ) # "file" output is locale dependent: force the usage of the C locale # to get deterministic behavior. env = dict ( os . environ , LC_ALL = 'C' ) try : # -b: do not prepend filenames to output lines (brief mode) output = subprocess . check_output ( [ 'file' , '-b' , target ] , stderr = subprocess . DEVNULL , env = env ) except ( OSError , subprocess . CalledProcessError ) : return default if not output : return default # With the C locale, the output should be mostly ASCII-compatible. # Decode from Latin-1 to prevent Unicode decode error. return output . decode ( 'latin-1' )