Skip to content

Commit

Permalink
Remove unused send_event and util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
xjules committed Oct 20, 2023
1 parent cca7fc8 commit c883921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 45 deletions.
18 changes: 1 addition & 17 deletions src/_ert_job_runner/client.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import asyncio
import logging
import ssl
from typing import Any, AnyStr, Dict, Optional, Union
from typing import Any, AnyStr, Optional, Union

import cloudevents
from typing_extensions import Self
from websockets.client import WebSocketClientProtocol, connect
from websockets.datastructures import Headers
Expand Down Expand Up @@ -127,18 +126,3 @@ async def _send(self, msg: AnyStr) -> None:

def send(self, msg: AnyStr) -> None:
self.loop.run_until_complete(self._send(msg))

def send_event(
self, ev_type: str, ev_source: str, ev_data: Optional[Dict[str, Any]] = None
) -> None:
if ev_data is None:
ev_data = {}
event = cloudevents.http.CloudEvent(
{
"type": ev_type,
"source": ev_source,
"datacontenttype": "application/json",
},
ev_data,
)
self.send(cloudevents.conversion.to_json(event).decode())
31 changes: 3 additions & 28 deletions src/_ert_job_runner/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
import os


def read_os_release(pfx="LSB_"):
fname = "/etc/os-release"
if not os.path.isfile(fname):
return {}

def processline(ln):
return ln.strip().replace('"', "")

def splitline(ln, pfx=""):
if ln.count("=") == 1:
k, v = ln.split("=")
return pfx + k, v
return None

props = {}
with open(fname, "r", encoding="utf-8") as f:
for line in f:
kv = splitline(processline(line), pfx=pfx)
if kv:
props[kv[0]] = kv[1]
return props


def pad_nonexisting(path, pad="-- "):
return path if os.path.exists(path) else pad + path
"""
util contains helping functions to create job statuses.
"""

0 comments on commit c883921

Please sign in to comment.