From: Gui Chen Date: Fri, 25 Apr 2014 06:13:28 +0000 (-0400) Subject: avoid to compress/decompress a non-file object X-Git-Tag: released-tools-18.01.7~79^2~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b462ca98c51a48b455e89ae1c2c6b9126ce331c5;p=tools%2Fmic.git avoid to compress/decompress a non-file object Change-Id: I0c43f449175325ba9314e56151a822b3aee0ec21 Signed-off-by: Gui Chen --- diff --git a/mic/archive.py b/mic/archive.py index 4f0e915..f25175b 100644 --- a/mic/archive.py +++ b/mic/archive.py @@ -175,6 +175,9 @@ def compress(file_path, compress_format): @compress_format: the compression format @retval: the path of the compressed file """ + if not os.path.isfile(file_path): + raise OSError, "can't compress a file not existed: '%s'" % file_path + try: func = _COMPRESS_FORMATS[compress_format] except KeyError: @@ -188,6 +191,9 @@ def decompress(file_path, decompress_format=None): @decompress_format: the format for decompression, None for auto detection @retval: the path of the decompressed file """ + if not os.path.isfile(file_path): + raise OSError, "can't decompress a file not existed: '%s'" % file_path + try: func = _COMPRESS_FORMATS[decompress_format] except KeyError: