diff options
Diffstat (limited to 'elivepatch_client/client/restful.py')
-rw-r--r-- | elivepatch_client/client/restful.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/elivepatch_client/client/restful.py b/elivepatch_client/client/restful.py index 1e5fea2..f6ee7f2 100644 --- a/elivepatch_client/client/restful.py +++ b/elivepatch_client/client/restful.py @@ -3,7 +3,7 @@ import json, base64 import requests from requests.auth import HTTPBasicAuth - +import time class ManaGer(object): def __init__(self, server_url): @@ -30,10 +30,19 @@ class ManaGer(object): print(r.json()) def get_livepatch(self): + from io import BytesIO url = self.server_url+'/elivepatch/api/v1.0/get_livepatch' payload = { 'KernelVersion': '4.10.16' } - r = requests.post(url, json=payload) - print(r.text) - print(r.json())
\ No newline at end of file + r = requests.get(url) + if r.status_code == requests.codes.ok: # livepatch returned ok + b= BytesIO(r.content) + with open('myfile.ko', 'wb') as out: + out.write(r.content) + r.close() + print(b) + else: + r.close() + time.sleep(5) + return self.get_livepatch() # try to get the livepatch again |