Coverage for apio/commands/apio_drivers_uninstall.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-07 05:08 +0000

1# This file is part of the Apio project 

2# (C) 2016-present FPGAwars 

3# Project authors: 

4# * Jesús Arroyo (Jesus89) (2016-2019) 

5# * Juan Gonzalez (obijuan) (2019-2024) 

6# * The Apio Team (2024-present) 

7# License: GPLv2 

8 

9"""Implementation of 'apio drivers uninstall' command""" 

10 

11# import sys 

12import click 

13from apio.managers.drivers import Drivers 

14from apio.apio_context import ( 

15 ApioContext, 

16 PackagesPolicy, 

17 ProjectPolicy, 

18 RemoteConfigPolicy, 

19) 

20from apio.utils.cmd_util import ApioGroup, ApioSubgroup, ApioCommand 

21 

22 

23# -- apio driver uninstall ftdi 

24 

25# -- Text in the rich-text format of the python rich library. 

26APIO_DRIVERS_UNINSTALL_FTDI_HELP = """ 

27The command 'apio drivers uninstall ftdi' removes the FTDI drivers that may \ 

28have been installed earlier. 

29 

30Examples:[code] 

31 apio drivers uninstall ftdi # Uninstall the ftdi drivers.[/code] 

32""" 

33 

34 

35@click.command( 

36 name="ftdi", 

37 cls=ApioCommand, 

38 short_help="Uninstall the ftdi drivers.", 

39 help=APIO_DRIVERS_UNINSTALL_FTDI_HELP, 

40) 

41def _ftdi_cli(): 

42 """Implements the 'apio drivers uninstall ftdi' command.""" 

43 

44 # -- Create the apio context. 

45 apio_ctx = ApioContext( 

46 project_policy=ProjectPolicy.NO_PROJECT, 

47 remote_config_policy=RemoteConfigPolicy.CACHED_OK, 

48 packages_policy=PackagesPolicy.ENSURE_PACKAGES, 

49 ) 

50 

51 # -- Create the drivers manager. 

52 drivers = Drivers(apio_ctx) 

53 

54 # -- Uninstall 

55 drivers.ftdi_uninstall() 

56 

57 

58# -- apio drivers uninstall serial 

59 

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. 

64 

65Examples:[code] 

66 apio drivers uninstall serial # Uninstall the serial drivers.[/code] 

67""" 

68 

69 

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.""" 

78 

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 ) 

85 

86 # -- Create the drivers manager. 

87 drivers = Drivers(apio_ctx) 

88 

89 # -- Uninstall 

90 drivers.serial_uninstall() 

91 

92 

93# --- apio drivers uninstall 

94 

95# -- Text in the rich-text format of the python rich library. 

96APIO_DRIVERS_UNINSTALL_HELP = """ 

97The command group 'apio drivers uninstall' includes subcommands that that \ 

98uninstall system drivers that are used to upload designs to FPGA boards. 

99""" 

100 

101# -- We have only a single group with the title 'Subcommands'. 

102SUBGROUPS = [ 

103 ApioSubgroup( 

104 "Subcommands", 

105 [ 

106 _ftdi_cli, 

107 _serial_cli, 

108 ], 

109 ) 

110] 

111 

112 

113@click.command( 

114 name="uninstall", 

115 cls=ApioGroup, 

116 subgroups=SUBGROUPS, 

117 short_help="Uninstall drivers.", 

118 help=APIO_DRIVERS_UNINSTALL_HELP, 

119) 

120def cli(): 

121 """Implements the 'apio drivers uninstall' command.""" 

122 

123 # pass