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

20 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-23 03:53 +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""" 

9 

10# import 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 

20 

21 

22# -- apio driver uninstall ftdi 

23 

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. 

28 

29Examples:[code] 

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

31""" 

32 

33 

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

42 

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 ) 

49 

50 # -- Create the drivers manager. 

51 drivers = Drivers(apio_ctx) 

52 

53 # -- Uninstall 

54 drivers.ftdi_uninstall() 

55 

56 

57# -- apio drivers uninstall serial 

58 

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

60APIO_DRIVERS_UNINSTALL_SERIAL_HELP = """ 

61The command 'apio drivers uninstall serial' removes the serial drivers that \ 

62you may have installed earlier. 

63 

64Examples:[code] 

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

66""" 

67 

68 

69@click.command( 

70 name="serial", 

71 cls=ApioCommand, 

72 short_help="Uninstall the serial drivers.", 

73 help=APIO_DRIVERS_UNINSTALL_SERIAL_HELP, 

74) 

75def _serial_cli(): 

76 """Implements the 'apio drivers uninstall serial' command.""" 

77 

78 # -- Create the apio context. 

79 apio_ctx = ApioContext( 

80 project_policy=ProjectPolicy.NO_PROJECT, 

81 remote_config_policy=RemoteConfigPolicy.CACHED_OK, 

82 packages_policy=PackagesPolicy.ENSURE_PACKAGES, 

83 ) 

84 

85 # -- Create the drivers manager. 

86 drivers = Drivers(apio_ctx) 

87 

88 # -- Uninstall 

89 drivers.serial_uninstall() 

90 

91 

92# --- apio drivers uninstall 

93 

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

95APIO_DRIVERS_UNINSTALL_HELP = """ 

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

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

98""" 

99 

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

101SUBGROUPS = [ 

102 ApioSubgroup( 

103 "Subcommands", 

104 [ 

105 _ftdi_cli, 

106 _serial_cli, 

107 ], 

108 ) 

109] 

110 

111 

112@click.command( 

113 name="uninstall", 

114 cls=ApioGroup, 

115 subgroups=SUBGROUPS, 

116 short_help="Uninstall drivers.", 

117 help=APIO_DRIVERS_UNINSTALL_HELP, 

118) 

119def cli(): 

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

121 

122 # pass