Ejemplo n.º 1
0
def getFileType(file):
    try:
        file_type = magic.from_file(file)
    except:
        try:
            import subprocess
            file_process = subprocess.Popen(['file', '-b', file],
                                            stdout=subprocess.PIPE)
            file_type = file_process.stdout.read().strip()
        except:
            return None

    file_type = file_type.split(' ')[0]
    file_type = file_type.replace("/", "_")
    return file_type
Ejemplo n.º 2
0
def getFileType(file):
    try:
        file_type = magic.from_file(file)
    except:
        try:
            import subprocess
            file_process = subprocess.Popen(['file', '-b', file],
                                            stdout=subprocess.PIPE)
            file_type = file_process.stdout.read().strip()
        except:
            return None

    file_type = file_type.split(' ')[0]
    file_type = file_type.replace("/", "_")
    return file_type
Ejemplo n.º 3
0
def getFileType(file_path):
    """Get MIME file type.
    @return: file type.
    """
    try:
        file_type = magic.from_file(file_path)
    except:
        try:
            import subprocess
            file_process = subprocess.Popen(['file', '-b', file_path],
                                            stdout=subprocess.PIPE)
            file_type = file_process.stdout.read().strip()
        except:
            return None

    file_type = file_type.split(' ')[0]

    return file_type
Ejemplo n.º 4
0
def getFileType(file_path):
    """Get MIME file type.
    @return: file type.
    """
    try:
        file_type = magic.from_file(file_path)
    except:
        try:
            import subprocess
            file_process = subprocess.Popen(['file', '-b', file_path],
                                            stdout=subprocess.PIPE)
            file_type = file_process.stdout.read().strip()
        except:
            return None

    file_type = file_type.split(' ')[0]
    
    return file_type