diff options
Diffstat (limited to 'multivimbroker/multivimbroker/pub/utils/fileutil.py')
-rw-r--r-- | multivimbroker/multivimbroker/pub/utils/fileutil.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/multivimbroker/multivimbroker/pub/utils/fileutil.py b/multivimbroker/multivimbroker/pub/utils/fileutil.py index 8eed583..40bf9df 100644 --- a/multivimbroker/multivimbroker/pub/utils/fileutil.py +++ b/multivimbroker/multivimbroker/pub/utils/fileutil.py @@ -13,14 +13,17 @@ import os import shutil import logging import traceback -import urllib2 +# import urllib2 +import urllib.request +import urllib.parse +import urllib.error logger = logging.getLogger(__name__) def make_dirs(path): if not os.path.exists(path): - os.makedirs(path, 0777) + os.makedirs(path, 0o777) def delete_dirs(path): @@ -29,7 +32,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) def download_file_from_http(url, local_dir, file_name): @@ -37,8 +40,8 @@ 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) + r = urllib.request.Request(url) + req = urllib.request.urlopen(r) save_file = open(local_file_name, 'wb') save_file.write(req.read()) save_file.close() |