Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Add property returncode to WSClient #160

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions stream/ws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

from kubernetes.client.rest import ApiException

import select
import certifi
import time
import collections
from websocket import WebSocket, ABNF, enableTrace
import six
import select
import ssl
import time

import six
import yaml

from six.moves.urllib.parse import urlencode, quote_plus, urlparse, urlunparse

from websocket import WebSocket, ABNF, enableTrace

STDIN_CHANNEL = 0
STDOUT_CHANNEL = 1
STDERR_CHANNEL = 2
Expand Down Expand Up @@ -203,6 +207,21 @@ def run_forever(self, timeout=None):
else:
while self.is_open():
self.update(timeout=None)
@property
def returncode(self):
"""
The return code, A None value indicates that the process hasn't
terminated yet.
"""
if self.is_open():
return None
else:
err = self.read_channel(ERROR_CHANNEL)
err = yaml.safe_load(err)
if err['status'] == "Success":
return 0
return int(err['details']['causes'][0]['message'])


def close(self, **kwargs):
"""
Expand Down