aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Ferrazzi <alicef@gentoo.org>2017-07-05 09:51:26 +0900
committerAlice Ferrazzi <alicef@gentoo.org>2017-07-05 09:51:26 +0900
commita459295548278e56538980ab3072ee9566f90e8d (patch)
treeed1399924da8f5ee3a5406a29514e4216efa4788
parentsmall fix (diff)
downloadelivepatch-a459295548278e56538980ab3072ee9566f90e8d.tar.gz
elivepatch-a459295548278e56538980ab3072ee9566f90e8d.tar.bz2
elivepatch-a459295548278e56538980ab3072ee9566f90e8d.zip
Getting kernel version from config file
add kernel version in send_file function
-rw-r--r--elivepatch_client/client/checkers.py15
-rw-r--r--elivepatch_client/client/restful.py2
2 files changed, 16 insertions, 1 deletions
diff --git a/elivepatch_client/client/checkers.py b/elivepatch_client/client/checkers.py
index 0afb364..5a046de 100644
--- a/elivepatch_client/client/checkers.py
+++ b/elivepatch_client/client/checkers.py
@@ -51,6 +51,8 @@ class Kernel(object):
path, file = f_action.ungz()
# if the file is .gz the configuration path is the tmp folder uncompressed config file
self.config = os.path.join(path,file)
+ self.kernel_version = f_action.config_kernel_version(self.config)
+
# check userID
data_store = shelve.open('userid')
@@ -160,3 +162,16 @@ class FileAction(object):
print('working')
path, uncompressed_file = (os.path.split(path_to_store))
return path, uncompressed_file
+
+ def config_kernel_version(self, uncompressed_config_file):
+ with open(uncompressed_config_file) as f:
+ i = 0
+ while i < 2:
+ f.readline()
+ if i == 1:
+ kernel_line = f.readline()
+ i += 1
+ kernel_version_raw = (kernel_line.split(' ')[2])
+ kernel_version = kernel_version_raw.split(('-'))[0]
+ return kernel_version
+
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py
index 25be666..beadd4f 100644
--- a/elivepatch_client/client/restful.py
+++ b/elivepatch_client/client/restful.py
@@ -34,7 +34,7 @@ class ManaGer(object):
# UserID is generated with python UUID
# TODO: add the UserID in the json location instead of headers
headers = {
- 'KernelVersion' : 'aaaa',
+ 'KernelVersion' : self.kernel_version,
'UserID': self.user_id
}
files = {'file': (name_file, open(send_file, 'rb'), 'multipart/form-data', {'Expires': '0'})}