diff options
author | hongyuzhao <zhao.hongyu@zte.com.cn> | 2019-06-28 09:51:33 +0800 |
---|---|---|
committer | hongyuzhao <zhao.hongyu@zte.com.cn> | 2019-07-03 11:19:09 +0800 |
commit | 46ad7c172411214c5432ed93fda4271288077447 (patch) | |
tree | 74adb32f9cdfe575184e67068faac9bc6c2117b7 /lcm/lcm/pub/utils/fileutil.py | |
parent | 37b1ae2386c365293249421595f0722c25bc8e8d (diff) |
vfclcm upgrade from python2 to python3
Change-Id: Ia55ae38ec64fc3d821d1e7e1c0cbe48b572a0dd4
Issue-ID: VFC-1429
Signed-off-by: hongyuzhao <zhao.hongyu@zte.com.cn>
Diffstat (limited to 'lcm/lcm/pub/utils/fileutil.py')
-rw-r--r-- | lcm/lcm/pub/utils/fileutil.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lcm/lcm/pub/utils/fileutil.py b/lcm/lcm/pub/utils/fileutil.py index e99b9d47..9a9ea5dd 100644 --- a/lcm/lcm/pub/utils/fileutil.py +++ b/lcm/lcm/pub/utils/fileutil.py @@ -16,14 +16,15 @@ import os import shutil import logging import traceback -import urllib2 +import urllib.request + logger = logging.getLogger(__name__) def make_dirs(path): if not os.path.exists(path): - os.makedirs(path, 0777) + os.makedirs(path, 777) def delete_dirs(path): @@ -32,7 +33,7 @@ def delete_dirs(path): shutil.rmtree(path) except Exception as e: logger.error(traceback.format_exc()) - logger.error("Failed to delete %s:%s", path, e.message) + logger.error("Failed to delete %s:%s", path, e.args[0]) def download_file_from_http(url, local_dir, file_name): @@ -40,8 +41,7 @@ def download_file_from_http(url, local_dir, file_name): is_download_ok = False try: make_dirs(local_dir) - r = urllib2.Request(url) - req = urllib2.urlopen(r) + req = urllib.request.urlopen(url) save_file = open(local_file_name, 'wb') save_file.write(req.read()) save_file.close() |