1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-05-11 04:01:30 +03:00

Wrap get.py's "if __name__ == '__main__':" into a function so it can be externally called (#4475)

Adding the Arduino repo as a git submodule can be very useful for version control. However, `git submodule update` is not enough, as the tools need to be downloaded through `get.py`. Wrapping the main code in that script into its own function allows an external Python script to import the module and execute its functionality without relying on the unsafe `execfile` (or `Popen`). The main advantage would be easy flow control in case of error (eg: issue #4464).
This commit is contained in:
Carlos Ruiz 2019-02-07 08:31:37 -08:00 committed by Earle F. Philhower, III
parent d2a8e8acc2
commit 82be4d02dc

View File

@ -108,9 +108,12 @@ def identify_platform():
sys_name = 'Windows' sys_name = 'Windows'
return arduino_platform_names[sys_name][bits] return arduino_platform_names[sys_name][bits]
if __name__ == '__main__': def main():
print('Platform: {0}'.format(identify_platform())) print('Platform: {0}'.format(identify_platform()))
tools_to_download = load_tools_list('../package/package_esp8266com_index.template.json', identify_platform()) tools_to_download = load_tools_list('../package/package_esp8266com_index.template.json', identify_platform())
mkdir_p(dist_dir) mkdir_p(dist_dir)
for tool in tools_to_download: for tool in tools_to_download:
get_tool(tool) get_tool(tool)
if __name__ == '__main__':
main()