From a459295548278e56538980ab3072ee9566f90e8d Mon Sep 17 00:00:00 2001 From: Alice Ferrazzi Date: Wed, 5 Jul 2017 09:51:26 +0900 Subject: Getting kernel version from config file add kernel version in send_file function --- elivepatch_client/client/checkers.py | 15 +++++++++++++++ elivepatch_client/client/restful.py | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) 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'})} -- cgit v1.2.3-65-gdbad