Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cockpit-ci: Update container to 2024-12-08 #21410

Merged
2 changes: 1 addition & 1 deletion containers/flatpak/add-release
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def element(tag, text=None, children=(), **kwargs):


def points_from_body(body):
for text in re.split('^ *-', body, flags=re.MULTILINE):
for text in re.split(r'^ *-', body, flags=re.MULTILINE):
if point := ' '.join(text.split()).strip():
yield element('li', point)

Expand Down
8 changes: 4 additions & 4 deletions pkg/storaged/btrfs/btrfs-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_subvolume_info(mp):
lines = subprocess.check_output(["btrfs", "subvolume", "list", "-apuq", mp]).splitlines()
subvols = []
for line in lines:
match = re.match(b"ID (\\d+).*parent (\\d+).*parent_uuid (.*)uuid (.*) path (<FS_TREE>/)?(.*)", line)
match = re.match(rb"ID (\d+).*parent (\d+).*parent_uuid (.*)uuid (.*) path (<FS_TREE>/)?(.*)", line)
if match:
pathname = match[6].decode(errors='replace')
# Ignore podman btrfs subvolumes, they are an implementation detail.
Expand All @@ -169,13 +169,13 @@ def get_subvolume_info(mp):
'uuid': match[4].decode(),
'parent_uuid': None if match[3][0] == ord("-") else match[3].decode().strip()
}
]
]
return subvols


def get_default_subvolume(mp):
output = subprocess.check_output(["btrfs", "subvolume", "get-default", mp])
match = re.match(b"ID (\\d+).*", output)
match = re.match(rb"ID (\d+).*", output)
if match:
return int(match[1])
else:
Expand All @@ -186,7 +186,7 @@ def get_usages(uuid):
output = subprocess.check_output(["btrfs", "filesystem", "show", "--raw", uuid])
usages = {}
for line in output.splitlines():
match = re.match(b".*used\\s+(\\d+)\\s+path\\s+([\\w/]+).*", line)
match = re.match(rb".*used\s+(\d+)\s+path\s+([\w/]+).*", line)
if match:
usages[match[2].decode()] = int(match[1])
return usages
Expand Down
6 changes: 3 additions & 3 deletions pkg/storaged/crypto/luksmeta-monitor-hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ def info(dev):
in_luks2_token_section = True

if in_luks2_slot_section:
match = re.match(b" ([0-9]+): luks2$", line)
match = re.match(rb" ([0-9]+): luks2$", line)
else:
match = re.match(b"Key Slot ([0-9]+): ENABLED$", line)
match = re.match(rb"Key Slot ([0-9]+): ENABLED$", line)
if match:
slot = int(match.group(1))
entry = {"Index": {"v": slot}}
Expand All @@ -93,7 +93,7 @@ def info(dev):
slots[slot] = entry

if in_luks2_token_section:
match = re.match(b" ([0-9]+): clevis$", line)
match = re.match(rb" ([0-9]+): clevis$", line)
if match:
try:
token = subprocess.check_output(["cryptsetup", "token", "export",
Expand Down
8 changes: 4 additions & 4 deletions pkg/storaged/nfs/nfs-mounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def event(_wd, mask, name):


def field_escape(field):
return field.replace("\\", "\\134").replace(" ", "\\040").replace("\t", "\\011")
return field.replace("\\", r"\134").replace(" ", r"\040").replace("\t", r"\011")


def field_unescape(field):
return re.sub("\\\\([0-7]{1,3})", lambda m: chr(int(m.group(1), 8)), field)
return re.sub(r"\\([0-7]{1,3})", lambda m: chr(int(m.group(1), 8)), field)


def parse_tab(name):
Expand All @@ -50,7 +50,7 @@ def parse_tab(name):
sline = line.strip()
if sline == "" or sline[0] == "#":
continue
fields = list(map(field_unescape, re.split("[ \t]+", sline)))
fields = list(map(field_unescape, re.split(r"[ \t]+", sline)))
if len(fields) > 2 and ":" in fields[0] and fields[2].startswith("nfs"):
entries.append(fields)
return entries
Expand All @@ -75,7 +75,7 @@ def modify_tab(name, modify):
if sline == "" or sline[0] == "#":
new_lines.append(line)
else:
fields = list(map(field_unescape, re.split("[ \t]+", sline)))
fields = list(map(field_unescape, re.split(r"[ \t]+", sline)))
if len(fields) > 0 and ":" in fields[0]:
new_fields = modify(fields)
if new_fields:
Expand Down
2 changes: 1 addition & 1 deletion src/build_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def build_sdist(sdist_directory: str,
# We do this manually to avoid adding timestamps. See https://bugs.python.org/issue31526
with gzip.GzipFile(f'{sdist_directory}/{sdist_filename}', mode='w', mtime=0) as gz:
# https://github.com/python/typeshed/issues/5491
with tarfile.open(fileobj=gz, mode='w|', dereference=True) as sdist: # type: ignore[arg-type]
with tarfile.open(fileobj=gz, mode='w|', dereference=True) as sdist: # type: ignore[arg-type,call-overload]
for filename in sorted(find_sources(srcpkg=True)):
sdist.add(filename, arcname=f'{PACKAGE}/{filename}', )
return sdist_filename
Expand Down
4 changes: 2 additions & 2 deletions src/cockpit/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ def send_text(self, data: str) -> bool:
"""
return self.send_bytes(data.encode())

def send_json(self, _msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> bool:
pretty = self.json_encoder.encode(create_object(_msg, kwargs)) + '\n'
def send_json(self, msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> bool:
pretty = self.json_encoder.encode(create_object(msg, kwargs)) + '\n'
return self.send_text(pretty)

def do_pong(self, message):
Expand Down
2 changes: 1 addition & 1 deletion src/cockpit/channels/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from .dbus import DBusChannel
from .filesystem import FsInfoChannel, FsListChannel, FsReadChannel, FsReplaceChannel, FsWatchChannel
from .http import HttpChannel
from .http_channel import HttpChannel
from .metrics import InternalMetricsChannel
from .packages import PackagesChannel
from .pcp import PcpMetricsChannel
Expand Down
15 changes: 9 additions & 6 deletions src/cockpit/channels/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ def my_umask() -> int:
return (match and int(match.group(1), 8)) or 0o077


def tag_from_stat(buf):
def tag_from_stat(buf) -> str:
return f'1:{buf.st_ino}-{buf.st_mtime}-{buf.st_mode:o}-{buf.st_uid}-{buf.st_gid}'


def tag_from_path(path):
def tag_from_path(path) -> 'str | None':
try:
return tag_from_stat(os.stat(path))
except FileNotFoundError:
Expand All @@ -70,7 +70,7 @@ def tag_from_path(path):
return None


def tag_from_fd(fd):
def tag_from_fd(fd) -> 'str | None':
try:
return tag_from_stat(os.fstat(fd))
except OSError:
Expand Down Expand Up @@ -151,7 +151,8 @@ def do_yield_data(self, options: JsonObject) -> Generator[bytes, None, JsonObjec
return {'tag': tag_from_stat(buf)}

except FileNotFoundError:
return {'tag': '-'}
# Using `yield` and `return {value}` generator, but GeneratorChannel does expect this
return {'tag': '-'} # noqa: B901
except PermissionError as exc:
raise ChannelError('access-denied') from exc
except OSError as exc:
Expand All @@ -168,7 +169,9 @@ def delete(self, path: str, tag: 'str | None') -> str:
os.unlink(path)
return '-'

async def set_contents(self, path: str, tag: 'str | None', data: 'bytes | None', size: 'int | None') -> str:
async def set_contents(
self, path: str, tag: 'str | None', data: 'bytes | None', size: 'int | None'
) -> 'str | None':
dirname, basename = os.path.split(path)
tmpname: str | None
fd, tmpname = tempfile.mkstemp(dir=dirname, prefix=f'.{basename}-')
Expand Down Expand Up @@ -261,7 +264,7 @@ async def run(self, options: JsonObject) -> JsonObject:

class FsWatchChannel(Channel, PathWatchListener):
payload = 'fswatch1'
_tag = None
_tag: 'str | None' = None
_watch = None

# The C bridge doesn't send the initial event, and the JS calls read()
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cockpit/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def ensure_scanned(self) -> None:
self.translations[f'{basename}.js'][lower_locale] = name
else:
# strip out trailing '.gz' components
basename = re.sub('.gz$', '', name)
basename = re.sub(r'.gz$', '', name)
logger.debug('Adding content %r -> %r', basename, name)
self.files[basename] = name

Expand Down
3 changes: 1 addition & 2 deletions src/cockpit/polyfills.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ def install():

# introduced in 3.9
if not hasattr(socket, 'recv_fds'):
import array

import _socket
import array

def recv_fds(sock, bufsize, maxfds, flags=0):
fds = array.array("i")
Expand Down
10 changes: 5 additions & 5 deletions src/cockpit/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class CockpitProblem(Exception):
"""
attrs: JsonObject

def __init__(self, problem: str, _msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
def __init__(self, problem: str, msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
kwargs['problem'] = problem
self.attrs = create_object(_msg, kwargs)
self.attrs = create_object(msg, kwargs)
super().__init__(get_str(self.attrs, 'message', problem))

def get_attrs(self) -> JsonObject:
Expand Down Expand Up @@ -179,10 +179,10 @@ def write_channel_data(self, channel: str, payload: bytes) -> None:
else:
logger.debug('cannot write to closed transport')

def write_control(self, _msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
def write_control(self, msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
"""Write a control message. See jsonutil.create_object() for details."""
logger.debug('sending control message %r %r', _msg, kwargs)
pretty = json.dumps(create_object(_msg, kwargs), indent=2) + '\n'
logger.debug('sending control message %r %r', msg, kwargs)
pretty = json.dumps(create_object(msg, kwargs), indent=2) + '\n'
self.write_channel_data('', pretty.encode())

def data_received(self, data: bytes) -> None:
Expand Down
12 changes: 6 additions & 6 deletions src/cockpit/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def send_channel_data(self, channel: str, data: bytes) -> None:
self.router.write_channel_data(channel, data)

def send_channel_control(
self, channel: str, command: str, _msg: 'JsonObject | None', **kwargs: JsonValue
self, channel: str, command: str, msg: 'JsonObject | None', **kwargs: JsonValue
) -> None:
self.router.write_control(_msg, channel=channel, command=command, **kwargs)
self.router.write_control(msg, channel=channel, command=command, **kwargs)
if command == 'close':
self.router.endpoints[self].remove(channel)
self.router.drop_channel(channel)

def shutdown_endpoint(self, _msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
self.router.shutdown_endpoint(self, _msg, **kwargs)
def shutdown_endpoint(self, msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
self.router.shutdown_endpoint(self, msg, **kwargs)


class RoutingError(CockpitProblem):
Expand Down Expand Up @@ -168,11 +168,11 @@ def add_endpoint(self, endpoint: Endpoint) -> None:
self.endpoints[endpoint] = set()
self.no_endpoints.clear()

def shutdown_endpoint(self, endpoint: Endpoint, _msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
def shutdown_endpoint(self, endpoint: Endpoint, msg: 'JsonObject | None' = None, **kwargs: JsonValue) -> None:
channels = self.endpoints.pop(endpoint)
logger.debug('shutdown_endpoint(%s, %s) will close %s', endpoint, kwargs, channels)
for channel in channels:
self.write_control(_msg, command='close', channel=channel, **kwargs)
self.write_control(msg, command='close', channel=channel, **kwargs)
self.drop_channel(channel)

if not self.endpoints:
Expand Down
2 changes: 1 addition & 1 deletion test/common/lcov.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def is_interesting_line(text):
# Don't complain about lines that contain only punctuation, or
# nothing but "else". We don't seem to get reliable
# information for them.
if not re.search('[a-zA-Z0-9]', text.replace("else", "")):
if not re.search(r'[a-zA-Z0-9]', text.replace("else", "")):
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion test/common/netlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def cleanupDevs():

ver = self.machine.execute(
"busctl --system get-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Version || true")
ver_match = re.match('s "(.*)"', ver)
ver_match = re.match(r's "(.*)"', ver)
if ver_match:
self.networkmanager_version = [int(x) for x in ver_match.group(1).split(".")]
else:
Expand Down
2 changes: 1 addition & 1 deletion test/common/packagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def createPackage(self, name, version, release, install=False,
else:
self.createRpm(name, version, release, depends, postinst, install, content, arch, provides)
if updateinfo:
self.updateInfo[(name, version, release)] = updateinfo
self.updateInfo[name, version, release] = updateinfo

def createDeb(self, name, version, depends, postinst, install, content, arch, provides):
"""Create a dummy deb in repo_dir on self.machine
Expand Down
2 changes: 1 addition & 1 deletion test/common/storagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def setUp(self):
super().setUp()

ver = self.machine.execute("busctl --system get-property org.freedesktop.UDisks2 /org/freedesktop/UDisks2/Manager org.freedesktop.UDisks2.Manager Version || true")
m = re.match('s "(.*)"', ver)
m = re.match(r's "(.*)"', ver)
if m:
self.storaged_version = list(map(int, m.group(1).split(".")))
else:
Expand Down
4 changes: 2 additions & 2 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2489,13 +2489,13 @@ def jsquote(js: object) -> str:
return json.dumps(js)


def get_decorator(method: object, _class: object, name: str, default: Any = None) -> Any:
def get_decorator(method: object, class_: object, name: str, default: Any = None) -> Any:
"""Get decorator value of a test method or its class

Return None if the decorator was not set.
"""
attr = "_testlib__" + name
return getattr(method, attr, getattr(_class, attr, default))
return getattr(method, attr, getattr(class_, attr, default))


###########################
Expand Down
4 changes: 2 additions & 2 deletions test/common/typecheck
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def show_error(lines):


def consider(lines, js_error_codes):
m = re.match("([^:]*)\\(.*\\): error ([^:]*): .*", lines[0])
m = re.match(r"([^:]*)\(.*\): error ([^:]*): .*", lines[0])
if m and not should_ignore(m[1]):
relaxed = is_relaxed(m[1])
is_js = m[1].endswith(('.js', '.jsx'))
Expand All @@ -165,7 +165,7 @@ except FileNotFoundError:
sys.exit(77)

cur = []
js_error_codes = Counter()
js_error_codes: Counter = Counter()
parser = argparse.ArgumentParser(description="Run tsc as a typechecker with an allowlist of errors for JavaScript and TypeScript files")
parser.add_argument("--stats", action="store_true", help="Display stats of the most common TypeScript errors in JavaScript files")
args = parser.parse_args()
Expand Down
4 changes: 2 additions & 2 deletions test/pytest/mocktransport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ async def assert_empty(self):
await asyncio.sleep(0.1)
assert self.queue.qsize() == 0

def send_json(self, _channel: str, **kwargs) -> None:
def send_json(self, channel_: str, **kwargs) -> None:
# max_read_size is one of our special keys which uses underscores
msg = {k.replace('_', '-') if k != "max_read_size" else k: v for k, v in kwargs.items()}
self.send_data(_channel, json.dumps(msg).encode('ascii'))
self.send_data(channel_, json.dumps(msg).encode('ascii'))

def send_data(self, channel: str, data: bytes) -> None:
msg = channel.encode('ascii') + b'\n' + data
Expand Down
12 changes: 6 additions & 6 deletions test/verify/check-packagekit
Original file line number Diff line number Diff line change
Expand Up @@ -1425,19 +1425,19 @@ class TestAutoUpdates(NoSubManCase):
else:
raise NotImplementedError(self.backend)

def assertTypeDnf(_type):
if _type == "all":
def assertTypeDnf(type_):
if type_ == "all":
match = '= default'
elif _type == "security":
elif type_ == "security":
match = '= security'
else:
raise ValueError(_type)
raise ValueError(type_)

self.assertIn(match, m.execute(f"grep upgrade_type {self.config}"))

def assertType(_type):
def assertType(type_):
if "dnf" in self.backend:
assertTypeDnf(_type)
assertTypeDnf(type_)
else:
raise NotImplementedError(self.backend)

Expand Down
2 changes: 2 additions & 0 deletions test/verify/check-pages
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ OnCalendar=daily
with b.wait_timeout(60):
b.wait_js_func("ph_plot_data_plateau", "pmcd", mem_avail * 0.85, mem_avail * 1.15, 15, "mem")

@testlib.skipBrowser("Headless chromium is missing the synthetic mouseenter", "chromium")
def testPageStatus(self):
b = self.browser

Expand All @@ -766,6 +767,7 @@ OnCalendar=daily
b.mouse("#development-info", "mouseenter")
b.wait_in_text(".pf-v5-c-tooltip", "My Little Page Status")
b.mouse("#development-info", "mouseleave")
b.wait_not_present(".pf-v5-c-tooltip")

b.go("/playground/notifications-receiver")
b.enter_page("/playground/notifications-receiver")
Expand Down
8 changes: 8 additions & 0 deletions test/verify/check-shell-host-switching
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ class TestHostSwitching(testlib.MachineCase, HostSwitcherHelpers):
b.wait_not_present("#nav-system.interact")
b.set_layout("desktop")

# this looks different (focused) when the mouse is inside (default 0,0 possition), so move it away
# chromium is stubborn here, we *have* to move the real mouse, not just do this with synthetic MouseEvents
b.bidi("input.performActions", context=b.driver.context, actions=[{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only affects chrome, then we could gate it? But lets get CI green again

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could make it conditional on .browser == chromium, but we don't run pixel tests on Firefox anyway, so it's no practical difference.

"id": "move-away",
"type": "pointer",
"parameters": {"pointerType": "mouse"},
"actions": [{"type": "pointerMove", "x": 200, "y": 200, "origin": "viewport"}]
}])
b.assert_pixels("#hosts-sel", "hosts-sel-closed")

b.click("#hosts-sel button")
Expand Down
Loading