Skip to content

Commit 949f3bd

Browse files
authored
Merge pull request #146 from creativecommons/small-fixes-upkeep
Small fixes/upkeep
2 parents a8c6b7e + e56a27a commit 949f3bd

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

dev/create_gcs_query_plan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,5 +252,5 @@ def main():
252252
),
253253
" ",
254254
)
255-
LOGGER.exception(f"(1) Unhandled exception:\n{traceback_formatted}")
255+
LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}")
256256
sys.exit(1)

dev/prioritize_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,5 @@ def main():
147147
),
148148
" ",
149149
)
150-
LOGGER.exception(f"(1) Unhandled exception:\n{traceback_formatted}")
150+
LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}")
151151
sys.exit(1)

scripts/1-fetch/gcs_fetch.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@
3636

3737
# Constants
3838
BASE_URL = "https://www.googleapis.com/customsearch/v1"
39-
FILE1_COUNT = os.path.join(PATHS["data_phase"], "gcs_1_count.csv")
40-
FILE2_LANGUAGE = os.path.join(
39+
FILE1_COUNT = shared.path_join(PATHS["data_phase"], "gcs_1_count.csv")
40+
FILE2_LANGUAGE = shared.path_join(
4141
PATHS["data_phase"], "gcs_2_count_by_language.csv"
4242
)
43-
FILE3_COUNTRY = os.path.join(PATHS["data_phase"], "gcs_3_count_by_country.csv")
43+
FILE3_COUNTRY = shared.path_join(
44+
PATHS["data_phase"], "gcs_3_count_by_country.csv"
45+
)
4446
GCS_CX = os.getenv("GCS_CX")
4547
GCS_DEVELOPER_KEY = os.getenv("GCS_DEVELOPER_KEY")
4648
HEADER1_COUNT = ["PLAN_INDEX", "TOOL_IDENTIFIER", "COUNT"]
4749
HEADER2_LANGUAGE = ["PLAN_INDEX", "TOOL_IDENTIFIER", "LANGUAGE", "COUNT"]
4850
HEADER3_COUNTRY = ["PLAN_INDEX", "TOOL_IDENTIFIER", "COUNTRY", "COUNT"]
51+
PLAN_COMPLETED_INDEX = 2868
4952
QUARTER = os.path.basename(PATHS["data_quarter"])
5053

5154
# Log the start of the script execution
@@ -139,11 +142,11 @@ def get_last_completed_plan_index():
139142

140143

141144
def load_plan():
142-
path = []
145+
plan = []
143146
file_path = os.path.join(PATHS["data"], "gcs_query_plan.csv")
144147
with open(file_path, "r", newline="") as file_obj:
145-
path = list(csv.DictReader(file_obj, dialect="unix"))
146-
return path
148+
plan = list(csv.DictReader(file_obj, dialect="unix"))
149+
return plan
147150

148151

149152
def append_data(args, plan_row, index, count):
@@ -259,9 +262,10 @@ def main():
259262
args = parse_arguments()
260263
shared.log_paths(LOGGER, PATHS)
261264
service = get_search_service()
265+
shared.git_fetch_and_merge(args, PATHS["repo"])
262266
initialize_all_data_files(args)
263267
last_completed_plan_index = get_last_completed_plan_index()
264-
if last_completed_plan_index == 2868:
268+
if last_completed_plan_index == PLAN_COMPLETED_INDEX:
265269
LOGGER.info(f"Data fetch completed for {QUARTER}")
266270
return
267271
plan = load_plan()
@@ -299,5 +303,5 @@ def main():
299303
),
300304
" ",
301305
)
302-
LOGGER.exception(f"(1) Unhandled exception:\n{traceback_formatted}")
306+
LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}")
303307
sys.exit(1)

scripts/1-fetch/github_fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,5 @@ def main():
204204
),
205205
" ",
206206
)
207-
LOGGER.exception(f"(1) Unhandled exception:\n{traceback_formatted}")
207+
LOGGER.critical(f"(1) Unhandled exception:\n{traceback_formatted}")
208208
sys.exit(1)

scripts/shared.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ def git_push_changes(args, repo_path):
127127
raise QuantifyingException(f"Error during push changes: {e}", 1)
128128

129129

130+
def path_join(*paths):
131+
return os.path.abspath(os.path.realpath(os.path.join(*paths)))
132+
133+
130134
def update_readme(
131135
paths, image_path, data_source, description, section_title, args
132136
):

0 commit comments

Comments
 (0)