Coverage for apio/commands/apio_drivers_install.py: 65%

23 statements  

« 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 install' command""" 

9 

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 

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 exit_code = drivers.ftdi_install() 

55 sys.exit(exit_code) 

56 

57 

58# -- apio driver install serial 

59 

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

61APIO_DRIVERS_INSTALL_SERIAL_HELP = """ 

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

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

64 

65Examples:[code] 

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

67""" 

68 

69 

70@click.command( 

71 name="serial", 

72 cls=ApioCommand, 

73 short_help="Install the serial drivers.", 

74 help=APIO_DRIVERS_INSTALL_SERIAL_HELP, 

75) 

76def _serial_cli(): 

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

90 exit_code = drivers.serial_install() 

91 sys.exit(exit_code) 

92 

93 

94# --- apio drivers install 

95 

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

97APIO_DRIVERS_INSTALL_HELP = """ 

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

99install system drivers that are used to upload designs to FPGA boards. 

100""" 

101 

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] 

112 

113 

114@click.command( 

115 name="install", 

116 cls=ApioGroup, 

117 subgroups=SUBGROUPS, 

118 short_help="Install drivers.", 

119 help=APIO_DRIVERS_INSTALL_HELP, 

120) 

121def cli(): 

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

123 

124 # pass