Skip to content

Commit b4a929a

Browse files
committed
add log when script is run without argument
1 parent 110cc4d commit b4a929a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

mapswipe_workers/python_scripts/change_tms_api_key_for_projects.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,26 @@ def add_api_key_to_projects(project_id_list, api_key):
5656

5757
if __name__ == "__main__":
5858
"""change_tms_api_key_for_projects.py maxar_premium"""
59-
tms_name = sys.argv[1]
60-
6159
logger.info(
6260
"This script currently supports only the following project types:"
63-
"build_area, footprint, completeness\n"
61+
"build_area, footprint, completeness. "
6462
"The new api key will be obtained from the .env file. "
6563
"Make sure to update this file first."
6664
)
6765

68-
if tms_name in IMAGE_API_KEYS.keys():
69-
new_api_key = IMAGE_API_KEYS[tms_name]
70-
project_id_list = get_all_projects_by_tms(tms_name)
71-
add_api_key_to_projects(project_id_list, new_api_key)
72-
else:
66+
try:
67+
tms_name = sys.argv[1]
68+
if tms_name in IMAGE_API_KEYS.keys():
69+
new_api_key = IMAGE_API_KEYS[tms_name]
70+
project_id_list = get_all_projects_by_tms(tms_name)
71+
add_api_key_to_projects(project_id_list, new_api_key)
72+
else:
73+
logger.info(
74+
f"'{tms_name}' is not a valid TMS provider name. "
75+
f"Valid options are: {list(IMAGE_API_KEYS.keys())}"
76+
)
77+
except IndexError:
7378
logger.info(
74-
f"'{tms_name}' is not a valid TMS provider name. "
79+
"Provide a valid TMS provider name as an argument to this script. "
7580
f"Valid options are: {list(IMAGE_API_KEYS.keys())}"
7681
)

0 commit comments

Comments
 (0)