Auto-update: Thu Jul 11 14:34:36 PDT 2024

This commit is contained in:
sanj 2024-07-11 14:34:36 -07:00
parent 39a9375649
commit a808aa73f4
6 changed files with 23 additions and 23 deletions

View file

@ -186,7 +186,7 @@ async def process_account_archival(account: EmailAccount):
await save_processed_uid(summarized_log, account.name, uid_str) await save_processed_uid(summarized_log, account.name, uid_str)
logger.info(f"Summarized email: {uid_str}") logger.info(f"Summarized email: {uid_str}")
else: else:
logger.warn(f"Failed to summarize {this_email.subject}") logger.warning(f"Failed to summarize {this_email.subject}")
else: else:
logger.debug(f"Skipping {uid_str} because it was already processed.") logger.debug(f"Skipping {uid_str} because it was already processed.")
except Exception as e: except Exception as e:
@ -311,12 +311,12 @@ async def autorespond_single_email(message, uid_str: str, account: EmailAccount,
jpg_path = await img.workflow(profile.image_prompt, earlyout=False, downscale_to_fit=True) if profile.image_prompt else None jpg_path = await img.workflow(profile.image_prompt, earlyout=False, downscale_to_fit=True) if profile.image_prompt else None
success = await send_response(this_email.sender, subject, response_body, profile, jpg_path) success = await send_response(this_email.sender, subject, response_body, profile, jpg_path)
if success: if success:
logger.warn(f"Auto-responded to email: {this_email.subject}") logger.warning(f"Auto-responded to email: {this_email.subject}")
await save_processed_uid(log_file, account.name, uid_str) await save_processed_uid(log_file, account.name, uid_str)
else: else:
logger.warn(f"Failed to send auto-response to {this_email.subject}") logger.warning(f"Failed to send auto-response to {this_email.subject}")
else: else:
logger.warn(f"Unable to generate auto-response for {this_email.subject}") logger.warning(f"Unable to generate auto-response for {this_email.subject}")
async def generate_response(this_email: IncomingEmail, profile: AutoResponder, account: EmailAccount) -> Optional[str]: async def generate_response(this_email: IncomingEmail, profile: AutoResponder, account: EmailAccount) -> Optional[str]:
logger.info(f"Generating auto-response to {this_email.subject} with profile: {profile.name}") logger.info(f"Generating auto-response to {this_email.subject} with profile: {profile.name}")

View file

@ -359,14 +359,14 @@ async def post_locate_endpoint(locations: Union[Location, List[Location]]):
if location_entry: if location_entry:
responses.append({"location_data": location_entry}) responses.append({"location_data": location_entry})
else: else:
logger.warn(f"Posting location to database appears to have failed.") logger.warning(f"Posting location to database appears to have failed.")
else: else:
logger.debug(f"Final location to be submitted to database: {geocoded_locations}") logger.debug(f"Final location to be submitted to database: {geocoded_locations}")
location_entry = await post_location(geocoded_locations) location_entry = await post_location(geocoded_locations)
if location_entry: if location_entry:
responses.append({"location_data": location_entry}) responses.append({"location_data": location_entry})
else: else:
logger.warn(f"Posting location to database appears to have failed.") logger.warning(f"Posting location to database appears to have failed.")
return {"message": "Locations and weather updated", "results": responses} return {"message": "Locations and weather updated", "results": responses}

View file

@ -128,7 +128,7 @@ tags:
obsidian_link = f"![[{audio_path.name}]]" obsidian_link = f"![[{audio_path.name}]]"
body += f"{obsidian_link}\n\n" body += f"{obsidian_link}\n\n"
else: else:
logger.warn(f"Unexpected audio_path type: {type(audio_path)}. Value: {audio_path}") logger.warning(f"Unexpected audio_path type: {type(audio_path)}. Value: {audio_path}")
except Exception as e: except Exception as e:
logger.error(f"Failed to generate TTS for {audio_filename}. Error: {str(e)}") logger.error(f"Failed to generate TTS for {audio_filename}. Error: {str(e)}")
logger.error(f"TTS error details - voice: {voice}, model: eleven_turbo_v2, podcast: True") logger.error(f"TTS error details - voice: {voice}, model: eleven_turbo_v2, podcast: True")
@ -246,7 +246,7 @@ async def clip_get(
async def note_add_endpoint(file: Optional[UploadFile] = File(None), text: Optional[str] = Form(None), source: Optional[str] = Form(None), bg_tasks: BackgroundTasks = None): async def note_add_endpoint(file: Optional[UploadFile] = File(None), text: Optional[str] = Form(None), source: Optional[str] = Form(None), bg_tasks: BackgroundTasks = None):
logger.debug(f"Received request on /note/add...") logger.debug(f"Received request on /note/add...")
if not file and not text: if not file and not text:
logger.warn(f"... without any file or text!") logger.warning(f"... without any file or text!")
raise HTTPException(status_code=400, detail="Either text or a file must be provided") raise HTTPException(status_code=400, detail="Either text or a file must be provided")
else: else:
result = await process_for_daily_note(file, text, source, bg_tasks) result = await process_for_daily_note(file, text, source, bg_tasks)
@ -688,7 +688,7 @@ async def process_archive(
logger.debug(f"Successfully saved to {markdown_path}") logger.debug(f"Successfully saved to {markdown_path}")
return markdown_path return markdown_path
except Exception as e: except Exception as e:
logger.warn(f"Failed to write markdown file: {str(e)}") logger.warning(f"Failed to write markdown file: {str(e)}")
return None return None
def download_file(url, folder): def download_file(url, folder):

View file

@ -91,7 +91,7 @@ async def build_daily_note_endpoint(
else: else:
raise ValueError("Location is not provided or invalid.") raise ValueError("Location is not provided or invalid.")
except (ValueError, AttributeError, TypeError) as e: except (ValueError, AttributeError, TypeError) as e:
logger.warn(f"Falling back to localized datetime due to error: {e}") logger.warning(f"Falling back to localized datetime due to error: {e}")
try: try:
date_time = await loc.dt(date_str) date_time = await loc.dt(date_str)
places = await loc.fetch_locations(date_time) places = await loc.fetch_locations(date_time)
@ -111,7 +111,7 @@ async def build_daily_note(date_time: dt_datetime, lat: float = None, lon: float
Obsidian helper. Takes a datetime and creates a new daily note. Note: it uses the sijapi configuration file to place the daily note and does NOT presently interface with Obsidian's daily note or periodic notes extensions. It is your responsibility to ensure they match. Obsidian helper. Takes a datetime and creates a new daily note. Note: it uses the sijapi configuration file to place the daily note and does NOT presently interface with Obsidian's daily note or periodic notes extensions. It is your responsibility to ensure they match.
''' '''
absolute_path, _ = assemble_journal_path(date_time) absolute_path, _ = assemble_journal_path(date_time)
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in build_daily_note.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in build_daily_note.")
formatted_day = date_time.strftime("%A %B %d, %Y") # Monday May 27, 2024 formatting formatted_day = date_time.strftime("%A %B %d, %Y") # Monday May 27, 2024 formatting
day_before = (date_time - timedelta(days=1)).strftime("%Y-%m-%d %A") # 2024-05-26 Sunday formatting day_before = (date_time - timedelta(days=1)).strftime("%Y-%m-%d %A") # 2024-05-26 Sunday formatting
day_after = (date_time + timedelta(days=1)).strftime("%Y-%m-%d %A") # 2024-05-28 Tuesday formatting day_after = (date_time + timedelta(days=1)).strftime("%Y-%m-%d %A") # 2024-05-28 Tuesday formatting
@ -302,7 +302,7 @@ async def generate_context(date_time, location: Location, forecast: str, mood: s
if geocoded_location.display_name or geocoded_location.city or geocoded_location.country: if geocoded_location.display_name or geocoded_location.city or geocoded_location.country:
return await generate_context(date_time, geocoded_location, forecast, mood, other_context) return await generate_context(date_time, geocoded_location, forecast, mood, other_context)
else: else:
logger.warn(f"Failed to get a useable location for purposes of generating a banner, but we'll generate one anyway.") logger.warning(f"Failed to get a useable location for purposes of generating a banner, but we'll generate one anyway.")
elif location and isinstance(location, str): elif location and isinstance(location, str):
display_name = f"Location: {location}\n" display_name = f"Location: {location}\n"
else: else:
@ -370,7 +370,7 @@ async def note_weather_get(
force_refresh_weather = refresh == "True" force_refresh_weather = refresh == "True"
try: try:
date_time = dt_datetime.now() if date == "0" else await loc.dt(date) date_time = dt_datetime.now() if date == "0" else await loc.dt(date)
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our dt_datetime in note_weather_get.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our dt_datetime in note_weather_get.")
logger.debug(f"date: {date} .. date_time: {date_time}") logger.debug(f"date: {date} .. date_time: {date_time}")
content = await update_dn_weather(date_time, force_refresh_weather) #, lat, lon) content = await update_dn_weather(date_time, force_refresh_weather) #, lat, lon)
return JSONResponse(content={"forecast": content}, status_code=200) return JSONResponse(content={"forecast": content}, status_code=200)
@ -386,7 +386,7 @@ async def note_weather_get(
@note.post("/update/note/{date}") @note.post("/update/note/{date}")
async def post_update_daily_weather_and_calendar_and_timeslips(date: str, refresh: str="False") -> PlainTextResponse: async def post_update_daily_weather_and_calendar_and_timeslips(date: str, refresh: str="False") -> PlainTextResponse:
date_time = await loc.dt(date) date_time = await loc.dt(date)
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our dt_datetime in post_update_daily_weather_and_calendar_and_timeslips.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our dt_datetime in post_update_daily_weather_and_calendar_and_timeslips.")
force_refresh_weather = refresh == "True" force_refresh_weather = refresh == "True"
await update_dn_weather(date_time, force_refresh_weather) await update_dn_weather(date_time, force_refresh_weather)
await update_daily_note_events(date_time) await update_daily_note_events(date_time)
@ -394,7 +394,7 @@ async def post_update_daily_weather_and_calendar_and_timeslips(date: str, refres
return f"[Refresh]({API.URL}/update/note/{date_time.strftime('%Y-%m-%d')}" return f"[Refresh]({API.URL}/update/note/{date_time.strftime('%Y-%m-%d')}"
async def update_dn_weather(date_time: dt_datetime, force_refresh: bool = False, lat: float = None, lon: float = None): async def update_dn_weather(date_time: dt_datetime, force_refresh: bool = False, lat: float = None, lon: float = None):
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in update_dn_weather.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in update_dn_weather.")
try: try:
if lat and lon: if lat and lon:
place = await GEO.code((lat, lon)) place = await GEO.code((lat, lon))

View file

@ -79,7 +79,7 @@ async def get_file_endpoint(file_path: str):
absolute_path = Path(absolute_path.with_suffix(".md")) absolute_path = Path(absolute_path.with_suffix(".md"))
if not absolute_path.is_file(): if not absolute_path.is_file():
logger.warn(f"{absolute_path} is not a valid file it seems.") logger.warning(f"{absolute_path} is not a valid file it seems.")
elif absolute_path.suffix == '.md': elif absolute_path.suffix == '.md':
try: try:
with open(absolute_path, 'r', encoding='utf-8') as file: with open(absolute_path, 'r', encoding='utf-8') as file:

View file

@ -49,7 +49,7 @@ async def get_refreshed_weather(
async def get_weather(date_time: dt_datetime, latitude: float, longitude: float, force_refresh: bool = False): async def get_weather(date_time: dt_datetime, latitude: float, longitude: float, force_refresh: bool = False):
logger.debug(f"Called get_weather with lat: {latitude}, lon: {longitude}, date_time: {date_time}") logger.debug(f"Called get_weather with lat: {latitude}, lon: {longitude}, date_time: {date_time}")
logger.warn(f"Using {date_time} as our datetime in get_weather.") logger.warning(f"Using {date_time} as our datetime in get_weather.")
fetch_new_data = True fetch_new_data = True
if force_refresh == False: if force_refresh == False:
daily_weather_data = await get_weather_from_db(date_time, latitude, longitude) daily_weather_data = await get_weather_from_db(date_time, latitude, longitude)
@ -83,7 +83,7 @@ async def get_weather(date_time: dt_datetime, latitude: float, longitude: float,
if fetch_new_data: if fetch_new_data:
logger.debug(f"We require new data!") logger.debug(f"We require new data!")
request_date_str = date_time.strftime("%Y-%m-%d") request_date_str = date_time.strftime("%Y-%m-%d")
logger.warn(f"Using {date_time.strftime('%Y-%m-%d')} as our datetime for fetching new data.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d')} as our datetime for fetching new data.")
url = f"https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{latitude},{longitude}/{request_date_str}/{request_date_str}?unitGroup=us&key={VISUALCROSSING_API_KEY}" url = f"https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/{latitude},{longitude}/{request_date_str}/{request_date_str}?unitGroup=us&key={VISUALCROSSING_API_KEY}"
try: try:
async with AsyncClient() as client: async with AsyncClient() as client:
@ -116,7 +116,7 @@ async def get_weather(date_time: dt_datetime, latitude: float, longitude: float,
async def store_weather_to_db(date_time: dt_datetime, weather_data: dict): async def store_weather_to_db(date_time: dt_datetime, weather_data: dict):
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in store_weather_to_db") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in store_weather_to_db")
async with DB.get_connection() as conn: async with DB.get_connection() as conn:
try: try:
day_data = weather_data.get('days')[0] day_data = weather_data.get('days')[0]
@ -126,7 +126,7 @@ async def store_weather_to_db(date_time: dt_datetime, weather_data: dict):
stations_array = day_data.get('stations', []) or [] stations_array = day_data.get('stations', []) or []
date_str = date_time.strftime("%Y-%m-%d") date_str = date_time.strftime("%Y-%m-%d")
logger.warn(f"Using {date_str} in our query in store_weather_to_db.") logger.warning(f"Using {date_str} in our query in store_weather_to_db.")
# Get location details from weather data if available # Get location details from weather data if available
longitude = weather_data.get('longitude') longitude = weather_data.get('longitude')
@ -135,11 +135,11 @@ async def store_weather_to_db(date_time: dt_datetime, weather_data: dict):
elevation = await GEO.elevation(latitude, longitude) elevation = await GEO.elevation(latitude, longitude)
location_point = f"POINTZ({longitude} {latitude} {elevation})" if longitude and latitude and elevation else None location_point = f"POINTZ({longitude} {latitude} {elevation})" if longitude and latitude and elevation else None
logger.warn(f"Uncorrected datetimes in store_weather_to_db: {day_data['datetime']}, sunrise: {day_data['sunrise']}, sunset: {day_data['sunset']}") logger.warning(f"Uncorrected datetimes in store_weather_to_db: {day_data['datetime']}, sunrise: {day_data['sunrise']}, sunset: {day_data['sunset']}")
day_data['datetime'] = await loc.dt(day_data.get('datetimeEpoch')) day_data['datetime'] = await loc.dt(day_data.get('datetimeEpoch'))
day_data['sunrise'] = await loc.dt(day_data.get('sunriseEpoch')) day_data['sunrise'] = await loc.dt(day_data.get('sunriseEpoch'))
day_data['sunset'] = await loc.dt(day_data.get('sunsetEpoch')) day_data['sunset'] = await loc.dt(day_data.get('sunsetEpoch'))
logger.warn(f"Corrected datetimes in store_weather_to_db: {day_data['datetime']}, sunrise: {day_data['sunrise']}, sunset: {day_data['sunset']}") logger.warning(f"Corrected datetimes in store_weather_to_db: {day_data['datetime']}, sunrise: {day_data['sunrise']}, sunset: {day_data['sunset']}")
daily_weather_params = ( daily_weather_params = (
day_data.get('sunrise'), day_data.get('sunriseEpoch'), day_data.get('sunrise'), day_data.get('sunriseEpoch'),
@ -244,7 +244,7 @@ async def store_weather_to_db(date_time: dt_datetime, weather_data: dict):
async def get_weather_from_db(date_time: dt_datetime, latitude: float, longitude: float): async def get_weather_from_db(date_time: dt_datetime, latitude: float, longitude: float):
logger.warn(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in get_weather_from_db.") logger.warning(f"Using {date_time.strftime('%Y-%m-%d %H:%M:%S')} as our datetime in get_weather_from_db.")
async with DB.get_connection() as conn: async with DB.get_connection() as conn:
query_date = date_time.date() query_date = date_time.date()
try: try: