Skip to content
Snippets Groups Projects
Commit 1ddff100 authored by Gaël de Chalendar's avatar Gaël de Chalendar
Browse files

Correct pkm access errors handling

parent d38a658b
No related branches found
No related tags found
No related merge requests found
Metadata-Version: 1.0
Name: pkm-python-client
Version: 0.1.5
Version: 0.1.7
Summary: A python client for the Decoder project's PKM server
Home-page: UNKNOWN
Author: Gaël de Chalendar
......
......@@ -3,6 +3,7 @@ import os
import requests
import sys
from datetime import datetime
from typing import Dict
# # TODO should not ignore this warning. Remove when the pkm certificate will
# # be corrected
......@@ -101,7 +102,10 @@ class PKMClient(object):
def now(self):
return datetime.now().strftime("%Y%m%d_%H%M%S")
def update_invocation(self, project_id, invocationId, status, resultsToAdd):
def update_invocation(self, project_id: str, invocationId: str, status: int,
resultsToAdd: Dict[str, str]):
"""
"""
invocationUpdate = dict()
invocationUpdate["invocationID"] = invocationId
......@@ -130,7 +134,7 @@ class Log(object):
def __init__(self, pkm: PKMClient, project: str,
tool: str, status: str = "",
details: dict = {}, nature: str = "Execution report",
max_msg_len=80):
max_msg_len=80, invocation_id=None):
self.pkm = pkm
self.project = project
# tool name/tag
......@@ -150,6 +154,7 @@ class Log(object):
self.errors = []
self.status = True
self.details = {}
self.invocation_id = invocation_id
def __del__(self):
status, result = self.pkm.call(method='POST',
......@@ -158,6 +163,11 @@ class Log(object):
if status != 0:
print(f"Logging {self.json()} failed with {status}: {result}",
file=sys.stderr)
elif self.invocation_id is not None:
newLogID = json.loads(result)[0]
self.pkm.update_invocation(
self.project, self.invocation_id, status,
dict(path=f"log/{self.project}"+str(newLogID), type="log"))
def _log_to(self, msg: str, dest: list):
dest.append(msg
......
[tool.poetry]
name = "pkm-python-client"
version = "0.1.4"
version = "0.1.7"
description = "A python client for the Decoder project's PKM server"
authors = ["Gaël de Chalendar <gael.de-chalendar@cea.fr>"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment