Coverage for apio/commands/apio_drivers_uninstall.py: 65%
23 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-06 10:20 +0000
1# -*- coding: utf-8 -*-
2# -- This file is part of the Apio project
3# -- (C) 2016-2024 FPGAwars
4# -- Authors
5# -- * Jesús Arroyo (2016-2019)
6# -- * Juan Gonzalez (obijuan) (2019-2024)
7# -- License GPLv2
8"""Implementation of 'apio drivers uninstall' command"""
10import sys
11import click
12from apio.managers.drivers import Drivers
13from apio.apio_context import (
14 ApioContext,
15 PackagesPolicy,
16 ProjectPolicy,
17 RemoteConfigPolicy,
18)
19from apio.utils.cmd_util import ApioGroup, ApioSubgroup, ApioCommand
22# -- apio driver uninstall ftdi
24# -- Text in the rich-text format of the python rich library.
25APIO_DRIVERS_UNINSTALL_FTDI_HELP = """
26The command 'apio drivers uninstall ftdi' removes the FTDI drivers that may \
27have been installed earlier.
29Examples:[code]
30 apio drivers uninstall ftdi # Uninstall the ftdi drivers.[/code]
31"""
34@click.command(
35 name="ftdi",
36 cls=ApioCommand,
37 short_help="Uninstall the ftdi drivers.",
38 help=APIO_DRIVERS_UNINSTALL_FTDI_HELP,
39)
40def _ftdi_cli():
41 """Implements the 'apio drivers uninstall ftdi' command."""
43 # -- Create the apio context.
44 apio_ctx = ApioContext(
45 project_policy=ProjectPolicy.NO_PROJECT,
46 remote_config_policy=RemoteConfigPolicy.CACHED_OK,
47 packages_policy=PackagesPolicy.ENSURE_PACKAGES,
48 )
50 # -- Create the drivers manager.
51 drivers = Drivers(apio_ctx)
53 # -- Uninstall
54 exit_code = drivers.ftdi_uninstall()
55 sys.exit(exit_code)
58# -- apio drivers uninstall serial
60# -- Text in the rich-text format of the python rich library.
61APIO_DRIVERS_UNINSTALL_SERIAL_HELP = """
62The command 'apio drivers uninstall serial' removes the serial drivers that \
63you may have installed earlier.
65Examples:[code]
66 apio drivers uninstall serial # Uninstall the serial drivers.[/code]
67"""
70@click.command(
71 name="serial",
72 cls=ApioCommand,
73 short_help="Uninstall the serial drivers.",
74 help=APIO_DRIVERS_UNINSTALL_SERIAL_HELP,
75)
76def _serial_cli():
77 """Implements the 'apio drivers uninstall serial' command."""
79 # -- Create the apio context.
80 apio_ctx = ApioContext(
81 project_policy=ProjectPolicy.NO_PROJECT,
82 remote_config_policy=RemoteConfigPolicy.CACHED_OK,
83 packages_policy=PackagesPolicy.ENSURE_PACKAGES,
84 )
86 # -- Create the drivers manager.
87 drivers = Drivers(apio_ctx)
89 # -- Uninstall
90 exit_code = drivers.serial_uninstall()
91 sys.exit(exit_code)
94# --- apio drivers uninstall
96# -- Text in the rich-text format of the python rich library.
97APIO_DRIVERS_UNINSTALL_HELP = """
98The command group 'apio drivers uninstall' includes subcommands that that \
99uninstall system drivers that are used to upload designs to FPGA boards.
100"""
102# -- We have only a single group with the title 'Subcommands'.
103SUBGROUPS = [
104 ApioSubgroup(
105 "Subcommands",
106 [
107 _ftdi_cli,
108 _serial_cli,
109 ],
110 )
111]
114@click.command(
115 name="uninstall",
116 cls=ApioGroup,
117 subgroups=SUBGROUPS,
118 short_help="Uninstall drivers.",
119 help=APIO_DRIVERS_UNINSTALL_HELP,
120)
121def cli():
122 """Implements the 'apio drivers uninstall' command."""
124 # pass