How to use the tockloader.helpers.menu function in tockloader

To help you get started, we’ve selected a few tockloader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tock / tockloader / tockloader / tockloader.py View on Github external
Set a flag in the TBF header.
		'''
		# Enter bootloader mode to get things started
		with self._start_communication_with_board():

			# Get a list of installed apps
			apps = self._extract_all_app_headers()

			if len(apps) == 0:
				raise TockLoaderException('No apps are installed on the board')

			# User did not specify apps. Pick from list.
			if len(app_names) == 0:
				options = ['** All']
				options.extend([app.get_name() for app in apps])
				name = helpers.menu(options,
						return_type='value',
						prompt='Select app to configure ',
						title='Which apps to configure?')
				if name == '** All':
					app_names = [app.get_name() for app in apps]
				else:
					app_names = [name]

			# Configure all selected apps
			changed = False
			for app in apps:
				if app.get_name() in app_names:
					app.get_header().set_flag(flag_name, flag_value)
					changed = True

			if changed:
github tock / tockloader / tockloader / main.py View on Github external
def command_inspect_tab (args):
	tabs = collect_tabs(args)

	if len(tabs) == 0:
		raise TockLoaderException('No TABs found to inspect')

	logging.status('Inspecting TABs...')
	for tab in tabs:
		# Print the basic information that is true about the TAB and all
		# contained TBF binaries.
		print(tab)

		# Ask the user if they want to see more detail about a certain TBF.
		tbf_names = tab.get_tbf_names()
		index = helpers.menu(tbf_names+['None'],
		                     return_type='index',
		                     title='Which TBF to inspect further?')
		if index < len(tbf_names):
			print('')
			print('{}:'.format(tbf_names[index]))
			app = tab.extract_tbf(tbf_names[index])
			print(textwrap.indent(str(app.get_header()), '  '))

			# If the user asked for the crt0 header, display that for the
			# architecture
			if args.crt0_header:
				print('  crt0 header')
				print(textwrap.indent(app.get_crt0_header_str() , '    '))

		print('')