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. " )