4
4
import sys
5
5
from pathlib import Path
6
6
7
- from rich import print
8
- from rich .console import Console
9
- from rich .table import Table
10
-
11
7
import click
12
8
import inquirer
13
9
import yaml
10
+ from rich import print
11
+ from rich .console import Console
12
+ from rich .table import Table
14
13
15
14
from resources .scenarios .ln_framework .ln import Policy
16
15
17
16
from .constants import (
17
+ DEFAULT_IMAGE_REPO ,
18
18
DEFAULT_TAG ,
19
- SUPPORTED_TAGS ,
20
19
FORK_OBSERVER_RPCAUTH ,
21
- DEFAULT_IMAGE_REPO ,
20
+ SUPPORTED_TAGS ,
22
21
)
23
22
24
23
@@ -49,7 +48,7 @@ def custom_graph(
49
48
index = 0
50
49
51
50
for entry in tanks :
52
- for i in range (int (entry ["count" ])):
51
+ for _ in range (int (entry ["count" ])):
53
52
if ":" in entry ["version" ] and "/" in entry ["version" ]:
54
53
repo , tag = entry ["version" ].split (":" )
55
54
image = {"repository" : repo , "tag" : tag }
@@ -98,11 +97,10 @@ def custom_graph(
98
97
"repository" : DEFAULT_IMAGE_REPO ,
99
98
"pullPolicy" : "IfNotPresent" ,
100
99
},
101
- "defaultConfig" :
102
- f"rpcauth={ FORK_OBSERVER_RPCAUTH } \n " +
103
- "rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n " +
104
- "rpcwhitelistdefault=0\n " +
105
- "debug=rpc\n "
100
+ "defaultConfig" : f"rpcauth={ FORK_OBSERVER_RPCAUTH } \n "
101
+ + "rpcwhitelist=forkobserver:getchaintips,getblockheader,getblockhash,getblock,getnetworkinfo\n "
102
+ + "rpcwhitelistdefault=0\n "
103
+ + "debug=rpc\n " ,
106
104
}
107
105
108
106
# Configure logging
@@ -118,12 +116,15 @@ def custom_graph(
118
116
119
117
120
118
def inquirer_create_network (project_path : Path ):
121
- network_name_prompt = inquirer .prompt ([
122
- inquirer .Text (
123
- "network_name" ,
124
- message = click .style ("Enter your network name" , fg = "blue" , bold = True ),
125
- validate = lambda _ , x : len (x ) > 0 ,
126
- )])
119
+ network_name_prompt = inquirer .prompt (
120
+ [
121
+ inquirer .Text (
122
+ "network_name" ,
123
+ message = click .style ("Enter your network name" , fg = "blue" , bold = True ),
124
+ validate = lambda _ , x : len (x ) > 0 ,
125
+ )
126
+ ]
127
+ )
127
128
if not network_name_prompt :
128
129
click .secho ("Setup cancelled by user." , fg = "yellow" )
129
130
return False
@@ -140,81 +141,108 @@ def inquirer_create_network(project_path: Path):
140
141
141
142
Console ().print (table )
142
143
143
- add_more_prompt = inquirer .prompt ([
144
- inquirer .List (
145
- "add_more" ,
146
- message = click .style (f"How many nodes to add? (0 = done)" , fg = "blue" , bold = True ),
147
- choices = ["0" , "4" , "8" , "12" , "20" , "50" , "other" ],
148
- default = "12" )])
144
+ add_more_prompt = inquirer .prompt (
145
+ [
146
+ inquirer .List (
147
+ "add_more" ,
148
+ message = click .style ("How many nodes to add? (0 = done)" , fg = "blue" , bold = True ),
149
+ choices = ["0" , "4" , "8" , "12" , "20" , "50" , "other" ],
150
+ default = "12" ,
151
+ )
152
+ ]
153
+ )
149
154
if not add_more_prompt :
150
155
click .secho ("Setup cancelled by user." , fg = "yellow" )
151
156
return False
152
157
if add_more_prompt ["add_more" ].startswith ("0" ):
153
158
break
154
159
155
160
if add_more_prompt ["add_more" ] == "other" :
156
- how_many_prompt = inquirer .prompt ([
157
- inquirer .Text (
158
- "how_many" ,
159
- message = click .style ("Enter the number of nodes" , fg = "blue" , bold = True ),
160
- validate = lambda _ , x : int (x ) > 0 )])
161
+ how_many_prompt = inquirer .prompt (
162
+ [
163
+ inquirer .Text (
164
+ "how_many" ,
165
+ message = click .style ("Enter the number of nodes" , fg = "blue" , bold = True ),
166
+ validate = lambda _ , x : int (x ) > 0 ,
167
+ )
168
+ ]
169
+ )
161
170
if not how_many_prompt :
162
171
click .secho ("Setup cancelled by user." , fg = "yellow" )
163
172
return False
164
173
how_many = how_many_prompt ["how_many" ]
165
174
else :
166
175
how_many = add_more_prompt ["add_more" ]
167
176
168
- tank_details_prompt = inquirer .prompt ([
169
- inquirer .List (
170
- "version" ,
171
- message = click .style ("Which version would you like to add to network?" , fg = "blue" , bold = True ),
172
- choices = ["other" ] + SUPPORTED_TAGS ,
173
- default = DEFAULT_TAG ,
177
+ tank_details_prompt = inquirer .prompt (
178
+ [
179
+ inquirer .List (
180
+ "version" ,
181
+ message = click .style (
182
+ "Which version would you like to add to network?" , fg = "blue" , bold = True
183
+ ),
184
+ choices = ["other" ] + SUPPORTED_TAGS ,
185
+ default = DEFAULT_TAG ,
174
186
),
175
- inquirer .List (
176
- "connections" ,
177
- message = click .style (
178
- "How many connections would you like each of these nodes to have?" ,
179
- fg = "blue" ,
180
- bold = True ,
187
+ inquirer .List (
188
+ "connections" ,
189
+ message = click .style (
190
+ "How many connections would you like each of these nodes to have?" ,
191
+ fg = "blue" ,
192
+ bold = True ,
193
+ ),
194
+ choices = ["0" , "1" , "2" , "8" , "12" , "other" ],
195
+ default = "8" ,
181
196
),
182
- choices = ["0" , "1" , "2" , "8" , "12" , "other" ],
183
- default = "8" ,
184
- )])
197
+ ]
198
+ )
185
199
if not tank_details_prompt :
186
200
click .secho ("Setup cancelled by user." , fg = "yellow" )
187
201
return False
188
202
break
189
203
if tank_details_prompt ["version" ] == "other" :
190
- custom_version_prompt = inquirer .prompt ([
191
- inquirer .Text (
192
- "version" ,
193
- message = click .style ("Provide dockerhub repository/image:tag" , fg = "blue" , bold = True ),
194
- validate = lambda _ , x : "/" in x and ":" in x )])
204
+ custom_version_prompt = inquirer .prompt (
205
+ [
206
+ inquirer .Text (
207
+ "version" ,
208
+ message = click .style (
209
+ "Provide dockerhub repository/image:tag" , fg = "blue" , bold = True
210
+ ),
211
+ validate = lambda _ , x : "/" in x and ":" in x ,
212
+ )
213
+ ]
214
+ )
195
215
if not custom_version_prompt :
196
216
click .secho ("Setup cancelled by user." , fg = "yellow" )
197
217
return False
198
218
tank_details_prompt ["version" ] = custom_version_prompt ["version" ]
199
219
200
220
if tank_details_prompt ["connections" ] == "other" :
201
- how_many_conn_prompt = inquirer .prompt ([
202
- inquirer .Text (
203
- "how_many_conn" ,
204
- message = click .style ("Enter the number of connections" , fg = "blue" , bold = True ),
205
- validate = lambda _ , x : int (x ) > 0 )])
221
+ how_many_conn_prompt = inquirer .prompt (
222
+ [
223
+ inquirer .Text (
224
+ "how_many_conn" ,
225
+ message = click .style (
226
+ "Enter the number of connections" , fg = "blue" , bold = True
227
+ ),
228
+ validate = lambda _ , x : int (x ) > 0 ,
229
+ )
230
+ ]
231
+ )
206
232
if not how_many_conn_prompt :
207
233
click .secho ("Setup cancelled by user." , fg = "yellow" )
208
234
return False
209
235
how_many_conn = how_many_conn_prompt ["how_many_conn" ]
210
236
else :
211
237
how_many_conn = tank_details_prompt ["connections" ]
212
238
213
- tanks .append ({
214
- "version" : tank_details_prompt ["version" ],
215
- "count" : how_many ,
216
- "connections" : how_many_conn
217
- })
239
+ tanks .append (
240
+ {
241
+ "version" : tank_details_prompt ["version" ],
242
+ "count" : how_many ,
243
+ "connections" : how_many_conn ,
244
+ }
245
+ )
218
246
219
247
fork_observer = click .prompt (
220
248
click .style (
0 commit comments