diff options
author | 2017-07-18 14:40:07 +0900 | |
---|---|---|
committer | 2017-07-18 14:40:07 +0900 | |
commit | 8e47ec3989531fa014d2383692acf6bd24fda3b6 (patch) | |
tree | 0bc5d84547260bb68358515e9f2d5defff583706 | |
parent | used os.path.join (diff) | |
download | elivepatch-8e47ec3989531fa014d2383692acf6bd24fda3b6.tar.gz elivepatch-8e47ec3989531fa014d2383692acf6bd24fda3b6.tar.bz2 elivepatch-8e47ec3989531fa014d2383692acf6bd24fda3b6.zip |
refactored ungz and send_files function
-rw-r--r-- | elivepatch_client/client/checkers.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py index bce9895..f5fad5b 100644 --- a/elivepatch_client/client/checkers.py +++ b/elivepatch_client/client/checkers.py @@ -44,9 +44,14 @@ class Kernel(object): self.patch_fullpath = patch_fullpath def send_files(self): - # check the configuration file + """ + Send config and patch files + + :return: void + """ path, file = (os.path.split(self.config_fullpath)) f_action = FileAction(path, file) + # check the configuration file if re.findall("[.]gz\Z", self.config_fullpath): print('gz extension') path, file = f_action.ungz() @@ -95,14 +100,15 @@ class FileAction(object): def ungz(self): path_to_store = None - get_file_path = os.path.join(self.path, self.filename) - store_file_path = os.path.join('/tmp', self.filename) - print('get_file_path: '+ get_file_path + ' store_file_path: ' + store_file_path) - if not os.path.isdir(get_file_path): - with gzip.open(get_file_path, 'rb') as in_file: + path_gz_file = os.path.join(self.path, self.filename) + temporary_path_uncompressed_file = os.path.join('/tmp', self.filename) + print('path_gz_file: '+ path_gz_file + ' temporary_path_uncompressed_file: ' + + temporary_path_uncompressed_file) + if not os.path.isdir(path_gz_file): + with gzip.open(path_gz_file, 'rb') as in_file: s = in_file.read() # Store uncompressed file - path_to_store = store_file_path[:-3] # remove the filename extension + path_to_store = temporary_path_uncompressed_file[:-3] # remove the filename extension with open(path_to_store, 'wb') as f: f.write(s) print('working') |