A Python program which parses the data in the coblob database and transforms into a format which the co-data project can use. One of the main goals of this project is to reduce the load on the CPU in the co-data project. https://www.craigoates.net/Software/project/17
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

47 lines
1.8 KiB

import requests
from services import art_services, data_services, logging_services
def update_data(arguments):
directory = arguments.target
v_setting = arguments.verbose
v_out = logging_services.log # Partial function -- for brevity.
save = data_services.store_json # (P.F.) For easier reading.
v_out(v_setting, "Beginning to update Art data...")
try:
raw_art_data = data_services.get_json(
"https://api.craigoates.net/api/1.0/Artwork")
v_out(v_setting, "Data from API retrived.")
save(art_services.get_creation_date_totals(raw_art_data),
f"{directory}/art_creation_dates.json")
v_out(v_setting, "Art creation dates processed.")
save(art_services.get_db_column_totals(raw_art_data, "category"),
f"{directory}/art_category.json")
v_out(v_setting, "Art categories processed.")
save(art_services.get_db_column_totals(raw_art_data, "medium"),
f"{directory}/art_medium.json")
v_out(v_setting, "Art medium(s) totals processed.")
save(art_services.get_dimension_totals
(raw_art_data, "dimensions", "width"),
f"{directory}/art_width.json")
v_out(v_setting, "Art width totals processed.")
save(art_services.get_dimension_totals
(raw_art_data, "dimensions", "height"),
f"{directory}/art_height.json")
v_out(v_setting, "Art height totals processed.")
save(art_services.get_dimension_totals
(raw_art_data, "dimensions", "depth"),
f"{directory}/art_depth.json")
v_out(v_setting, "Art depth totals processed.")
v_out(v_setting, "Completed updating Art data.")
except Exception:
print("ERROR: [art_coordinator] Unable to update Art data.")