From patchwork Mon Jan 16 19:50:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Braunwarth X-Patchwork-Id: 1727242 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbaabb66vs2pamgqer2yuqhi@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=WuaBo16a; dkim-atps=neutral Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NwjNb5JD7z23gx for ; Tue, 17 Jan 2023 06:52:30 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id v19-20020a2ea453000000b0028b7192e0f3sf1817568ljn.11 for ; Mon, 16 Jan 2023 11:52:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673898747; cv=pass; d=google.com; s=arc-20160816; b=Bsak6g40XVJM4mI3LJFfm0k6qC12qVbyrFAJEAIQ1gH7JQoa4A3ywSM9wILa/Mz855 O7o/seJU/0E7P4PXYdQO5cgroyHr6Q0sUt53WBh9aTB5Kg78PYIDFwrAQDpCP0wIR80W /JUc0fXGJd1j3xYlKORyXDBu9PuFYJCvYi4FoPZj8sOMW2v06ywHsVPueLiDTyCw+6jm WBP7U43aESXuroZiN0z8DfetC3VWqKYP0fYGxpB8XnS0gN93Dqti5+wYfNF8v/rMOgpX XtVdVFDmyRyyg+9umHBtC0KJIQ2Ieyh3El4A2zZXd3gKGOt/t+EX/kq8DEkHWOQ+ACnn lluA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=5s9iDsqw1eUchBPby7cFb9Nao2J/rh5+UctRqDt/amM=; b=eI72f9Q4Htr3evZpi8ESwJQPARYRVIr5jovHOofiRPOZ7rNFmC92B48WHGcDcAZfBH xX600p5xcO2H7EVm+Pegid7qerXPzX2VYLUFnBx/uAqUXW6bOq7hQvQ36lpydI2iMO/G e4TlhYx67RUzFLjifYvL9yxIjubULaDiT9zuT7NaU6ydgUAGWF1nj7I09UWMUAue0yMy LsWy919YGs7Pjhn8aLGgKuw75RREqPoKWyLNyqCuJKVuWB3hudU9nTQAKgumqW3ygTIu I1YTseAVHYIQ2ZopMdLz+oFO7Eh1hpdMAtM5Q2dsFV/1tRdZAnqtqjgUkVy6NwReVlJc 9TZw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of daniel@braunwarth.dev designates 185.26.156.157 as permitted sender) smtp.mailfrom=daniel@braunwarth.dev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=5s9iDsqw1eUchBPby7cFb9Nao2J/rh5+UctRqDt/amM=; b=WuaBo16a4TKcWQrHs4qdQp88en95B2AyFUME4UT0szlKY/uGf5iOMrIoszpZelMJil jjPZQADtYeBOENTUNswl9jktgpsLd2v5H70N3nI22U19m1E8shi/4jp165fyYEoaQq9F qWS9999jVPvWHAG3IHL3DsgQG17THD8+kFx1T3mBieJ7wO1xpqqGN+x98oiZfXBqw3Pq ty4kEQOnvhE4tw2dryDC5lArlIfo5vGdcL9mj9mNsVDnEyAfkqo2CG6ejrEuZgqlQuRN T/OZX2hil6VS0xRDQ31Dn+6BuIIyaksECz8cVqT94gmNcWtRiNvPW9OWmDez09oW5QeC CS3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=5s9iDsqw1eUchBPby7cFb9Nao2J/rh5+UctRqDt/amM=; b=P5vEc3tb0dmW0Hs0pwY86Mq5EIRRD1GaF30b49hF2kLQaNw/A0i7ZDUpNX5Eki10ax 3jvFKlfCqZYvTnmQj+EkVbCKdiVSpylQE959Onpt8fqlKe8hcYRpghxaLlvBhg/O7E8/ bXN3jfAFX9+w8ZmoTtO2o2Gfj8pXCcp/EFm5h+jG1q/zlqVTpWsAIHKXxRasXPbHiiWQ ggVzU1kfHKoDJ9umRlDOT73eQNwKDwzUpA4N1z08vyymfLDX9U4zolE3lFE/8RRxWtyJ mMsP8Oo42ew4ywLmkh2g70cISHM8Q4dSKDc2M8Y4GC4l9vi5HIDqKEtnSoX/aWV5ZWat QqIw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AFqh2kpmGYStZX/v9WFMOpHsKbhfNzaWzgVCTHax/50OTCXXjxjiCuWD 0Tj1Tikj2VlNo2YCAQ/mDpY= X-Google-Smtp-Source: AMrXdXsniKqHeitPeHxl4TCD/eb+Nl7hfyaUzvQa1b6/nUkKdhygaG0F8OfI6qsA04Sb17QwhdIYMg== X-Received: by 2002:ac2:511c:0:b0:4b6:e956:54a2 with SMTP id q28-20020ac2511c000000b004b6e95654a2mr14712lfb.663.1673898747441; Mon, 16 Jan 2023 11:52:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3244:b0:4d5:7ca1:c92f with SMTP id c4-20020a056512324400b004d57ca1c92fls1623773lfr.2.-pod-prod-gmail; Mon, 16 Jan 2023 11:52:26 -0800 (PST) X-Received: by 2002:a05:6512:3e29:b0:4b5:26f3:2247 with SMTP id i41-20020a0565123e2900b004b526f32247mr89416lfv.69.1673898746490; Mon, 16 Jan 2023 11:52:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673898746; cv=none; d=google.com; s=arc-20160816; b=A4cHc4wS4uUjyOoT4L8DikvgisPlNhoZd+ak5DbWIsuBl0vewVT4PQx1GXw0RpGdGQ vSUesTS9K3CE0LlYB6uUdaK4Bjco9GWjktq5PzXxOWee7PnfA/5iMRKUNmbK4Nq384qM wZIM1NiTQ5BBiwyDI/CQmmh4cJUP/1IMbtXQyH/fsFmaiJmZGJ50UpLqjZIFqy80KeId epdKZg758cRKduumN/wf2lHNDZ66h8E5CELXrAR66bDt36S6eViuJqMaMHwb39Y0anSY OxEl9vCrKZJpEqrShLvIYCB2O17LpmsgOMGc02fHTcJrVLxQPWhPRrh/yCik4aH/ZJvr TOhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=p/kDi/k1JHAoOmlZ7tvsBgjrNckgCs95cckSot8DgWY=; b=AXjajvsjx+4kXBMKMaXZCOCzFDjgsSvvM6Ugq2l+fy6DQsWvyM3scZCMlfhGutScon FGeYme040ejfF8szYq6eVDFFumOSodUHeCBfYq1akHZcuCtBGw9/EsARHGhGJtpk2Vkz R6450eWrUGPxH5kgBRCL2gfUy2PouU1ub1pK61j7iwwvg1k4ycbYZAAB7mMAkGbIrV4w BNWjdxfOMGN15T9avqj81JXVX0wcgCylQVYKY5UZYoVGpTZlTnfG4VfGnxpDFn6M4NJQ BEWbnbF5odpg1nejoGgZKsfvOlKxgAgYj9i4L/tUtmxkdAWtangOv459bl2EMEr7UtE6 +Odw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of daniel@braunwarth.dev designates 185.26.156.157 as permitted sender) smtp.mailfrom=daniel@braunwarth.dev Received: from bergelmir.uberspace.de (bergelmir.uberspace.de. [185.26.156.157]) by gmr-mx.google.com with ESMTPS id u5-20020a05651220c500b00492ce810d43si1330401lfr.10.2023.01.16.11.52.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jan 2023 11:52:26 -0800 (PST) Received-SPF: pass (google.com: domain of daniel@braunwarth.dev designates 185.26.156.157 as permitted sender) client-ip=185.26.156.157; Received: (qmail 5733 invoked by uid 989); 16 Jan 2023 19:52:25 -0000 From: Daniel Braunwarth To: swupdate@googlegroups.com Cc: daniel@braunwarth.dev Subject: [swupdate] [PATCH 4/5] examples/client: improve websocket message handling Date: Mon, 16 Jan 2023 20:50:58 +0100 Message-Id: <20230116195059.25744-5-daniel@braunwarth.dev> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116195059.25744-1-daniel@braunwarth.dev> References: <20230116195059.25744-1-daniel@braunwarth.dev> MIME-Version: 1.0 X-Rspamd-Bar: ----- X-Rspamd-Report: R_MISSING_CHARSET(0.5) MIME_GOOD(-0.1) REPLY(-4) MID_CONTAINS_FROM(1) BAYES_HAM(-2.999999) X-Rspamd-Score: -5.599999 Received: from unknown (HELO unkown) (::1) by bergelmir.uberspace.de (Haraka/2.8.28) with ESMTPSA; Mon, 16 Jan 2023 20:52:25 +0100 X-Original-Sender: daniel@braunwarth.dev X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of daniel@braunwarth.dev designates 185.26.156.157 as permitted sender) smtp.mailfrom=daniel@braunwarth.dev Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This patch maps the logging level used by SWUpdate to the logging levels used by Python and logs them with the actual level. Signed-off-by: Daniel Braunwarth --- examples/client/swupdate_client.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/client/swupdate_client.py b/examples/client/swupdate_client.py index 78e92f1..751a268 100755 --- a/examples/client/swupdate_client.py +++ b/examples/client/swupdate_client.py @@ -16,6 +16,14 @@ import requests import websockets +LOGGING_MAPPING = { + "3": logging.ERROR, + "4": logging.WARNING, + "6": logging.INFO, + "7": logging.DEBUG, +} + + class SWUpdater: """Python helper class for SWUpdate""" @@ -58,7 +66,10 @@ class SWUpdater: if data["type"] != "message": continue - self._logger.info(data["text"]) + self._logger.log( + LOGGING_MAPPING[data["level"]], + data["text"]) + if "SWUPDATE successful" in data["text"]: return True if "Installation failed" in data["text"]: