Coverage for apio/commands/apio_drivers_install.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 install' 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 drivers install ftdi 

23 

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

25APIO_DRIVERS_INSTALL_FTDI_HELP = """ 

26The command 'apio drivers install ftdi' installs on your system the FTDI \ 

27drivers required by some FPGA boards. 

28 

29Examples:[code] 

30 apio drivers install ftdi # Install the ftdi drivers.[/code] 

31""" 

32 

33 

34@click.command( 

35 name="ftdi", 

36 cls=ApioCommand, 

37 short_help="Install the ftdi drivers.", 

38 help=APIO_DRIVERS_INSTALL_FTDI_HELP, 

39) 

40def _ftdi_cli(): 

41 """Implements the 'apio drivers install 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 # -- Install. 

54 drivers.ftdi_install() 

55 

56 

57# -- apio driver install serial 

58 

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

60APIO_DRIVERS_INSTALL_SERIAL_HELP = """ 

61The command 'apio drivers install serial' installs the necessary serial \ 

62drivers on your system, as required by certain FPGA boards. 

63 

64Examples:[code] 

65 apio drivers install serial # Install the serial drivers.[/code] 

66""" 

67 

68 

69@click.command( 

70 name="serial", 

71 cls=ApioCommand, 

72 short_help="Install the serial drivers.", 

73 help=APIO_DRIVERS_INSTALL_SERIAL_HELP, 

74) 

75def _serial_cli(): 

76 """Implements the 'apio drivers install 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 # Install 

89 drivers.serial_install() 

90 

91 

92# --- apio drivers install 

93 

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

95APIO_DRIVERS_INSTALL_HELP = """ 

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

97install 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="install", 

114 cls=ApioGroup, 

115 subgroups=SUBGROUPS, 

116 short_help="Install drivers.", 

117 help=APIO_DRIVERS_INSTALL_HELP, 

118) 

119def cli(): 

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

121 

122 # pass