66import shlex
77import yaml
88
9+ from modules .console import Console
10+
911'''
1012Creation and compilation of the MeshCentral nodes list (list of all nodes available to the user in the configuration) is handled in the following section.
1113'''
@@ -48,7 +50,7 @@ async def compile_book(meshbook_file: str) -> dict:
4850 return meshbook
4951
5052 @staticmethod
51- async def gather_targets (args : argparse . Namespace ,
53+ async def gather_targets (silent : bool ,
5254 meshbook : dict ,
5355 group_list : dict [str , list [dict ]],
5456 os_categories : dict ) -> dict :
@@ -99,19 +101,19 @@ async def process_group_helper(group):
99101 await process_group_helper (group_list [pseudo_target ])
100102
101103 elif pseudo_target not in group_list :
102- console . nice_print (
103- args ,
104- console .text_color .yellow + "Targeted group not found on the MeshCentral server."
104+ Console . print_text (
105+ silent ,
106+ Console .text_color .yellow + "Targeted group not found on the MeshCentral server."
105107 )
106108 elif isinstance (pseudo_target , list ):
107- console . nice_print (
108- args ,
109- console .text_color .yellow + "Please use groups (Notice the plural with 'S') for multiple groups."
109+ Console . print_text (
110+ silent ,
111+ Console .text_color .yellow + "Please use groups (Notice the plural with 'S') for multiple groups."
110112 )
111113 else :
112- console . nice_print (
113- args ,
114- console .text_color .yellow + "The 'group' key is being used, but an unknown data type was found, please check your values."
114+ Console . print_text (
115+ silent ,
116+ Console .text_color .yellow + "The 'group' key is being used, but an unknown data type was found, please check your values."
115117 )
116118
117119 case {"groups" : pseudo_target }:
@@ -124,43 +126,43 @@ async def process_group_helper(group):
124126 for group in group_list .values ():
125127 await process_group_helper (group )
126128 elif isinstance (pseudo_target , str ):
127- console . nice_print (
128- args ,
129- console .text_color .yellow + "The 'groups' key is being used, but only one string is given. Did you mean 'group'?"
129+ Console . print_text (
130+ silent ,
131+ Console .text_color .yellow + "The 'groups' key is being used, but only one string is given. Did you mean 'group'?"
130132 )
131133 else :
132- console . nice_print (
133- args ,
134- console .text_color .yellow + "The 'groups' key is being used, but an unknown data type was found, please check your values."
134+ Console . print_text (
135+ silent ,
136+ Console .text_color .yellow + "The 'groups' key is being used, but an unknown data type was found, please check your values."
135137 )
136138
137139 case {"device" : pseudo_target }:
138140 if isinstance (pseudo_target , str ):
139141 await process_device_helper (pseudo_target )
140142 elif isinstance (pseudo_target , list ):
141- console . nice_print (
142- args ,
143- console .text_color .yellow + "Please use devices (Notice the plural with 'S') for multiple devices."
143+ Console . print_text (
144+ silent ,
145+ Console .text_color .yellow + "Please use devices (Notice the plural with 'S') for multiple devices."
144146 )
145147 else :
146- console . nice_print (
147- args ,
148- console .text_color .yellow + "The 'device' key is being used, but an unknown data type was found, please check your values."
148+ Console . print_text (
149+ silent ,
150+ Console .text_color .yellow + "The 'device' key is being used, but an unknown data type was found, please check your values."
149151 )
150152
151153 case {"devices" : pseudo_target }:
152154 if isinstance (pseudo_target , list ):
153155 for sub_device in pseudo_target :
154156 await process_device_helper (sub_device )
155157 elif isinstance (pseudo_target , str ):
156- console . nice_print (
157- args ,
158- console .text_color .yellow + "The 'devices' key is being used, but only one string is given. Did you mean 'device'?"
158+ Console . print_text (
159+ silent ,
160+ Console .text_color .yellow + "The 'devices' key is being used, but only one string is given. Did you mean 'device'?"
159161 )
160162 else :
161- console . nice_print (
162- args ,
163- console .text_color .yellow + "The 'devices' key is being used, but an unknown data type was found, please check your values."
163+ Console . print_text (
164+ silent ,
165+ Console .text_color .yellow + "The 'devices' key is being used, but an unknown data type was found, please check your values."
164166 )
165167
166168 return {"target_list" : target_list , "offline_list" : offline_list }
0 commit comments