MCPcopy Create free account
hub / github.com/ExpressLRS/ExpressLRS / ask_for_firmware

Function ask_for_firmware

src/python/binary_configurator.py:122–150  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

120 return x
121
122def ask_for_firmware(args):
123 moduletype = 'tx' if args.tx else 'rx'
124 with open('hardware/targets.json') as f:
125 targets = json.load(f)
126 products = []
127 if args.target is not None:
128 target = args.target
129 config = jmespath.search('.'.join(map(lambda s: f'"{s}"', args.target.split('.'))), targets)
130 if config is None and args.fdir is not None:
131 with open(os.path.join(args.fdir, 'hardware/targets.json')) as f:
132 targets = json.load(f)
133 config = jmespath.search('.'.join(map(lambda s: f'"{s}"', args.target.split('.'))), targets)
134 else:
135 i = 0
136 for k in jmespath.search(f'*.["{moduletype}_2400","{moduletype}_900","{moduletype}_dual"][].*[]', targets):
137 i += 1
138 products.append(k)
139 print(f"{i}) {k['product_name']}")
140 print('Choose a configuration to flash')
141 choice = input()
142 if choice != "":
143 config = products[int(choice)-1]
144 for v in targets:
145 for t in targets[v]:
146 if t != 'name':
147 for m in targets[v][t]:
148 if targets[v][t][m]['product_name'] == config['product_name']:
149 target = f'{v}.{t}.{m}'
150 return target, config
151
152class readable_dir(argparse.Action):
153 def __call__(self, parser, namespace, values, option_string=None):

Callers 1

mainFunction · 0.85

Calls 1

searchMethod · 0.45

Tested by

no test coverage detected