[elbe-devel] [PATCH 04/21] elbepack: soapclient: make wait_busy a method on ElbeSoapClient
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Tue Aug 6 11:18:02 CEST 2024
This is useful functionality that should be usable without going through
"elbe control".
Make it a library function that can be called from other parts of elbe
and call it from "elbe control".
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/commands/control.py | 35 +----------------------------------
elbepack/soapclient.py | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index 6d042c1fe270..e7a15471bf3d 100644
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -8,7 +8,6 @@ import fnmatch
import os
import socket
import sys
-import time
from http.client import BadStatusLine
from urllib.error import URLError
@@ -252,39 +251,7 @@ def _get_files(client, args):
@_add_project_dir_argument
def _wait_busy(client, args):
- while True:
- try:
- msg = client.service.get_project_busy(args.project_dir)
- # TODO the root cause of this problem is unclear. To enable a
- # get more information print the exception and retry to see if
- # the connection problem is just a temporary problem. This
- # code should be reworked as soon as it's clear what is going on
- # here
- except socket.error as e:
- print(str(e), file=sys.stderr)
- print('socket error during wait busy occured, retry..',
- file=sys.stderr)
- continue
-
- if not msg:
- time.sleep(0.1)
- continue
-
- if msg == 'ELBE-FINISH':
- break
-
- print(msg)
-
- # exited the while loop -> the project is not busy anymore,
- # check, whether everything is ok.
-
- prj = client.service.get_project(args.project_dir)
- if prj.status != 'build_done':
- print(
- 'Project build was not successful, current status: '
- f'{prj.status}',
- file=sys.stderr)
- sys.exit(191)
+ client.wait_busy(args.project_dir)
@_add_project_dir_argument
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index c5a69032eedb..1c59032340ec 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -13,9 +13,13 @@ from urllib.error import URLError
from suds.client import Client
+from elbepack.cli import CliError
from elbepack.version import elbe_version
+_logger = logging.getLogger(__name__)
+
+
class ElbeVersionMismatch(RuntimeError):
def __init__(self, client_version, server_version):
self.client_version = client_version
@@ -118,3 +122,32 @@ class ElbeSoapClient:
fp.write(binascii.a2b_base64(ret))
part = part + 1
+
+ def wait_busy(self, project_dir):
+ while True:
+ try:
+ msg = self.service.get_project_busy(project_dir)
+ # TODO the root cause of this problem is unclear. To enable a
+ # get more information print the exception and retry to see if
+ # the connection problem is just a temporary problem. This
+ # code should be reworked as soon as it's clear what is going on
+ # here
+ except socket.error:
+ _logger.warn('socket error during wait busy occured, retry..', exc_info=True)
+ continue
+
+ if not msg:
+ time.sleep(0.1)
+ continue
+
+ if msg == 'ELBE-FINISH':
+ break
+
+ _logger.info(msg)
+
+ # exited the while loop -> the project is not busy anymore,
+ # check, whether everything is ok.
+
+ prj = self.service.get_project(project_dir)
+ if prj.status != 'build_done':
+ raise CliError(191, f'Project build was not successful, current status: {prj.status}')
--
2.46.0
More information about the elbe-devel
mailing list