kopia lustrzana https://github.com/espressif/esp-idf
Tools: bugfix wrong format of idf-env.json, KeyError: 'idfSelectedId'
Closes https://github.com/espressif/esp-idf/issues/9837pull/9884/head^2
rodzic
d1113747e7
commit
640f1c844b
|
@ -1077,7 +1077,10 @@ def get_idf_env(): # type: () -> Any
|
||||||
try:
|
try:
|
||||||
idf_env_file_path = os.path.join(global_idf_tools_path, IDF_ENV_FILE) # type: ignore
|
idf_env_file_path = os.path.join(global_idf_tools_path, IDF_ENV_FILE) # type: ignore
|
||||||
with open(idf_env_file_path, 'r') as idf_env_file:
|
with open(idf_env_file_path, 'r') as idf_env_file:
|
||||||
return json.load(idf_env_file)
|
idf_env_json = json.load(idf_env_file)
|
||||||
|
if 'sha' not in idf_env_json['idfInstalled']:
|
||||||
|
idf_env_json['idfInstalled']['sha'] = {'targets': []}
|
||||||
|
return idf_env_json
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
if not os.path.exists(idf_env_file_path):
|
if not os.path.exists(idf_env_file_path):
|
||||||
warn('File {} was not found. '.format(idf_env_file_path))
|
warn('File {} was not found. '.format(idf_env_file_path))
|
||||||
|
@ -1087,17 +1090,14 @@ def get_idf_env(): # type: () -> Any
|
||||||
os.rename(idf_env_file_path, os.path.join(os.path.dirname(idf_env_file_path), (filename + '_failed' + ending)))
|
os.rename(idf_env_file_path, os.path.join(os.path.dirname(idf_env_file_path), (filename + '_failed' + ending)))
|
||||||
|
|
||||||
info('Creating {}' .format(idf_env_file_path))
|
info('Creating {}' .format(idf_env_file_path))
|
||||||
return {'idfSelectedId': 'sha', 'idfInstalled': {'sha': {'targets': {}}}}
|
return {'idfInstalled': {'sha': {'targets': []}}}
|
||||||
|
|
||||||
|
|
||||||
def export_targets_to_idf_env_json(targets): # type: (list[str]) -> None
|
def export_targets_to_idf_env_json(targets): # type: (list[str]) -> None
|
||||||
idf_env_json = get_idf_env()
|
idf_env_json = get_idf_env()
|
||||||
targets = list(set(targets + get_user_defined_targets()))
|
targets = list(set(targets + get_user_defined_targets()))
|
||||||
|
|
||||||
for env in idf_env_json['idfInstalled']:
|
idf_env_json['idfInstalled']['sha']['targets'] = targets
|
||||||
if env == idf_env_json['idfSelectedId']:
|
|
||||||
idf_env_json['idfInstalled'][env]['targets'] = targets
|
|
||||||
break
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if global_idf_tools_path: # mypy fix for Optional[str] in the next call
|
if global_idf_tools_path: # mypy fix for Optional[str] in the next call
|
||||||
|
@ -1132,16 +1132,13 @@ def get_user_defined_targets(): # type: () -> list[str]
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(global_idf_tools_path, IDF_ENV_FILE), 'r') as idf_env_file: # type: ignore
|
with open(os.path.join(global_idf_tools_path, IDF_ENV_FILE), 'r') as idf_env_file: # type: ignore
|
||||||
idf_env_json = json.load(idf_env_file)
|
idf_env_json = json.load(idf_env_file)
|
||||||
|
if 'sha' not in idf_env_json['idfInstalled']:
|
||||||
|
idf_env_json['idfInstalled']['sha'] = {'targets': []}
|
||||||
except OSError:
|
except OSError:
|
||||||
# warn('File {} was not found. Installing tools for all esp targets.'.format(os.path.join(global_idf_tools_path, IDF_ENV_FILE))) # type: ignore
|
# warn('File {} was not found. Installing tools for all esp targets.'.format(os.path.join(global_idf_tools_path, IDF_ENV_FILE))) # type: ignore
|
||||||
return []
|
return []
|
||||||
|
|
||||||
targets = []
|
return idf_env_json['idfInstalled']['sha']['targets'] # type: ignore
|
||||||
for env in idf_env_json['idfInstalled']:
|
|
||||||
if env == idf_env_json['idfSelectedId']:
|
|
||||||
targets = idf_env_json['idfInstalled'][env]['targets']
|
|
||||||
break
|
|
||||||
return targets
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_targets_from_tools_json(): # type: () -> list[str]
|
def get_all_targets_from_tools_json(): # type: () -> list[str]
|
||||||
|
|
Ładowanie…
Reference in New Issue