Use mimetype to check if a file is to be cat|zcat|bzcat (instead of suffix) Need import standard lib module mimetypes
Signed-off-by: Jean Parpaillon <[email protected]> Signed-off-by: Amos Kong <[email protected]> --- client/bin/base_utils.py | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/bin/base_utils.py b/client/bin/base_utils.py index 96d1fc0..42b600a 100644 --- a/client/bin/base_utils.py +++ b/client/bin/base_utils.py @@ -7,7 +7,7 @@ Convenience functions for use by tests or whomever. Note that this file is mixed in by utils.py - note very carefully the precedence order defined there """ -import os, shutil, sys, signal, commands, pickle, glob, statvfs +import os, shutil, sys, signal, commands, pickle, glob, statvfs, mimetypes import math, re, string, fnmatch, logging from autotest_lib.client.common_lib import error, utils @@ -47,9 +47,9 @@ def cat_file_to_cmd(file, command, ignore_status=0, return_output=False): else: run_cmd = utils.system - if file.endswith('.bz2'): + if mimetypes.guess_type(file) == ('application/x-tar', 'bzip2'): cat = 'bzcat' - elif (file.endswith('.gz') or file.endswith('.tgz')): + elif mimetypes.guess_type(file) == ('application/x-tar', 'gzip'): cat = 'zcat' else: cat = 'cat' -- 1.6.3.3 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
