aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-18 18:39:29 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-18 18:39:29 +0900
commit1ddbf5593e3385efa622ddca406d16f9b5a6ea92 (patch)
treed8bc83923e4bec30d646b7712a36f8eec5d532be
parentadded docstrings (diff)
downloadelivepatch-1ddbf5593e3385efa622ddca406d16f9b5a6ea92.tar.gz
elivepatch-1ddbf5593e3385efa622ddca406d16f9b5a6ea92.tar.bz2
elivepatch-1ddbf5593e3385efa622ddca406d16f9b5a6ea92.zip
fixed variable name
getting as argument fullpath instead of splitting it each time
-rw-r--r--elivepatch_client/client/checkers.py26
-rw-r--r--elivepatch_client/client/restful.py8
2 files changed, 17 insertions, 17 deletions
diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py
index f4dbb9c..2f9dfcc 100644
--- a/elivepatch_client/client/checkers.py
+++ b/elivepatch_client/client/checkers.py
@@ -49,7 +49,7 @@ class Kernel(object):
:return: void
"""
path, file = (os.path.split(self.config_fullpath))
- f_action = FileAction(path, file)
+ f_action = FileAction(self.config_fullpath)
# check the configuration file
if re.findall("[.]gz\Z", self.config_fullpath):
print('gz extension')
@@ -62,11 +62,10 @@ class Kernel(object):
self.rest_manager.set_kernel_version(self.kernel_version)
print('debug: kernel version = ' + self.rest_manager.get_kernel_version())
- path, patch_filename = (os.path.split(self.patch_fullpath))
send_api = '/elivepatch/api/v1.0/get_files'
- # send uncompressed config and patch files
- self.rest_manager.send_file(self.config_fullpath, self.patch_fullpath, file, patch_filename, send_api)
+ # send uncompressed config and patch files fullpath
+ self.rest_manager.send_file(self.config_fullpath, self.patch_fullpath, send_api)
def build_livepatch(self):
self.rest_manager.build_livepatch()
@@ -96,9 +95,8 @@ class FileAction(object):
"""
Work with files
"""
- def __init__(self, path, filename):
- self.path = path
- self.filename = filename
+ def __init__(self, full_path):
+ self.full_path = full_path
pass
def ungz(self):
@@ -106,21 +104,21 @@ class FileAction(object):
Uncompress gzipped configuration
:return: Uncompressed configuration file path
"""
- path_to_store = None
- path_gz_file = os.path.join(self.path, self.filename)
- temporary_path_uncompressed_file = os.path.join('/tmp', self.filename)
+ uncompressed_file_fullpath = None
+ path, filename = os.path.split(self.full_path)
+ path_gz_file = os.path.join(path, filename)
+ temporary_path_uncompressed_file = os.path.join('/tmp', 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 = temporary_path_uncompressed_file[:-3] # remove the filename extension
- with open(path_to_store, 'wb') as f:
+ uncompressed_file_fullpath = temporary_path_uncompressed_file[:-3] # remove the filename extension
+ with open(uncompressed_file_fullpath, 'wb') as f:
f.write(s)
print('working')
- path, uncompressed_file = (os.path.split(path_to_store))
- return path, uncompressed_file
+ return uncompressed_file_fullpath
def config_kernel_version(self, uncompressed_config_file):
"""
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py
index 59f3e3a..3670e19 100644
--- a/elivepatch_client/client/restful.py
+++ b/elivepatch_client/client/restful.py
@@ -37,7 +37,7 @@ class ManaGer(object):
r = requests.get(url)
print(r.json())
- def send_file(self, config_send_file, patch_send_file, config_file_name, patch_file_name, api):
+ def send_file(self, config_fullpath, patch_fullpath, api):
url = self.server_url+ api
# we are sending the file and the UUID
# The server is dividing user by UUID
@@ -47,8 +47,10 @@ class ManaGer(object):
'KernelVersion' : self.kernel_version,
'UUID': self.uuid
}
- files = {'patch': (patch_file_name, open(patch_send_file, 'rb'), 'multipart/form-data', {'Expires': '0'}),
- 'config': (config_file_name, open(config_send_file, 'rb'), 'multipart/form-data', {'Expires': '0'})}
+ patch_filename = (os.path.split(patch_fullpath))[1]
+ config_filename = (os.path.split(config_fullpath))[1]
+ files = {'patch': (patch_filename, open(patch_fullpath, 'rb'), 'multipart/form-data', {'Expires': '0'}),
+ 'config': (config_filename, open(config_fullpath, 'rb'), 'multipart/form-data', {'Expires': '0'})}
print(str(files))
r = requests.post(url, files=files, headers=headers)
print('send file: ' + str(r.json()))