File: enable_coverage.py

package info (click to toggle)
cloud-init 25.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,412 kB
  • sloc: python: 135,894; sh: 3,883; makefile: 141; javascript: 30; xml: 22
file content (28 lines) | stat: -rw-r--r-- 813 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from pathlib import Path

services = [
    "cloud-init-local.service",
    "cloud-init-network.service",
    "cloud-config.service",
    "cloud-final.service",
]
service_dir = Path("/lib/systemd/system/")

# Check for the existence of the service files
for service in services:
    if not (service_dir / service).is_file():
        print(f"Error: {service} does not exist in {service_dir}")
        exit(1)

# Prepend the ExecStart= line with 'python3 -m coverage run'
for service in services:
    file_path = service_dir / service
    content = file_path.read_text()
    content = content.replace(
        "ExecStart=/usr",
        (
            "ExecStart=python3 -m coverage run "
            "--source=/usr/lib/python3/dist-packages/cloudinit --append /usr"
        ),
    )
    file_path.write_text(content)