From: Yu Watanabe Date: Sun, 17 May 2026 17:48:35 +0000 (+0900) Subject: fake-imds: apply "ruff format" and "ruff check --fix" X-Git-Tag: v261-rc1~126^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a0eaff3a77f74f53211acaf356542932d7b2ccd;p=thirdparty%2Fsystemd.git fake-imds: apply "ruff format" and "ruff check --fix" --- diff --git a/test/integration-tests/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/fake-imds.py b/test/integration-tests/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/fake-imds.py index e0a28ca766b..4eb3c95836a 100755 --- a/test/integration-tests/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/fake-imds.py +++ b/test/integration-tests/TEST-74-AUX-UTILS/TEST-74-AUX-UTILS.units/fake-imds.py @@ -1,15 +1,17 @@ #!/usr/bin/python3 # SPDX-License-Identifier: LGPL-2.1-or-later -import os, socket +import os +import socket from http.server import BaseHTTPRequestHandler, HTTPServer + def sd_notify(state: str) -> bool: - notify_socket = os.environ.get("NOTIFY_SOCKET") + notify_socket = os.environ.get('NOTIFY_SOCKET') if not notify_socket: return False - if notify_socket.startswith("@"): - notify_socket = "\0" + notify_socket[1:] + if notify_socket.startswith('@'): + notify_socket = '\0' + notify_socket[1:] try: with socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) as sock: sock.sendto(state.encode(), notify_socket) @@ -18,34 +20,36 @@ def sd_notify(state: str) -> bool: return True + class Handler(BaseHTTPRequestHandler): def do_GET(self): - if self.path == "/userdata": - body = b"{\"systemd.credentials\":[{\"name\":\"acredtest\",\"text\":\"avalue\"}]}" + if self.path == '/userdata': + body = b'{"systemd.credentials":[{"name":"acredtest","text":"avalue"}]}' self.send_response(200) - self.send_header("Content-Type", "text/plain") - self.send_header("Content-Length", len(body)) + self.send_header('Content-Type', 'text/plain') + self.send_header('Content-Length', len(body)) self.end_headers() self.wfile.write(body) - elif self.path == "/hostname": - body = b"piff" + elif self.path == '/hostname': + body = b'piff' self.send_response(200) - self.send_header("Content-Type", "text/plain") - self.send_header("Content-Length", len(body)) + self.send_header('Content-Type', 'text/plain') + self.send_header('Content-Length', len(body)) self.end_headers() self.wfile.write(body) else: self.send_error(404) def log_message(self, fmt, *args): - print(f"{self.address_string()} - {fmt % args}") + print(f'{self.address_string()} - {fmt % args}') + -PORT=8088 +PORT = 8088 -server = HTTPServer(("", PORT), Handler) -print(f"Serving on http://localhost:{PORT}/") +server = HTTPServer(('', PORT), Handler) +print(f'Serving on http://localhost:{PORT}/') try: - sd_notify("READY=1") + sd_notify('READY=1') server.serve_forever() except KeyboardInterrupt: - print("\nStopped.") + print('\nStopped.')