Unzip an archive file

def unzip(filepath, output_path):
    """
    Unzip an archive file
    """
    filename = os.path.split(filepath)[1]
    (name, extension) = os.path.splitext(filename)
    extension = extension[1:].lower()
    extension2 = os.path.splitext(name)[1][1:].lower()

    if extension not in ZIP_EXTENSIONS:
        raise Exception("Impossible to extract archive file %s" % filepath)

    extract_command = "unzip"
    output_args = "-d"
    if extension == 'bz2' and extension2 == 'tar':
        extract_command = "tar -xjf"
        output_args = "-C"
    elif extension == 'gz' and extension2 == 'tar':
        extract_command = "tar -xzf"
        output_args = "-C"
    elif extension == 'xz' and extension2 == 'tar':
        extract_command = "tar -xJf"
        output_args = "-C"
    elif extension == 'bz2':
        extract_command = "bunzip2 -dc "
        output_args = ">"
        output_path = os.path.join(output_path, name)
    elif extension == 'rar':
        extract_command = "unrar x"
        output_args = ""
    elif extension == 'gz':
        extract_command = "gunzip"
        output_args = ""
    elif extension == 'tar':
        extract_command = "tar -xf"
        output_args = "-C"
    elif extension == 'tbz2':
        extract_command = "tar -xjf"
        output_args = "-C"
    elif extension == 'tgz':
        extract_command = "tar -xzf"
        output_args = "-C"
    elif extension == 'zip':
        extract_command = "unzip"
        output_args = "-d"
    elif extension == 'Z':
        extract_command = "uncompress"
        output_args = ""
    elif extension == '7z':
        extract_command = "7z x"
        output_args = ""
    elif extension == 'xz':
        extract_command = "unxz"
        output_args = ""
    elif extension == 'ace':
        extract_command = "unace"
        output_args = ""
    elif extension == 'iso':
        extract_command = "7z x"
        output_args = ""
    elif extension == 'arj':
        extract_command = "7z x"
        output_args = ""

    command = """%(extract_command)s "%(filepath)s" %(output_args)s "%(output_folder)s" """
    params = {
        'extract_command': extract_command,
        'filepath': filepath,
        'output_folder': output_path,
        'output_args': output_args,
    }
    result = os.system(command % params)
    return result