Shane 7 months ago
parent 941fe12ec5
commit e972714ada
  1. 51
      foodie_automator_google.py
  2. 2
      foodie_automator_reddit.py
  3. 2
      foodie_automator_rss.py
  4. 2
      foodie_engagement_tweet.py
  5. 2
      foodie_weekly_thread.py

@ -28,7 +28,7 @@ from foodie_utils import (
is_interesting, generate_title_from_summary, summarize_with_gpt4o, is_interesting, generate_title_from_summary, summarize_with_gpt4o,
generate_category_from_summary, post_to_wp, prepare_post_data, generate_category_from_summary, post_to_wp, prepare_post_data,
select_best_author, smart_image_and_filter, get_flickr_image, select_best_author, smart_image_and_filter, get_flickr_image,
get_next_author_round_robin, check_author_rate_limit get_next_author_round_robin, check_author_rate_limit, update_system_activity
) )
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt from foodie_hooks import get_dynamic_hook, get_viral_share_prompt
from dotenv import load_dotenv from dotenv import load_dotenv
@ -452,6 +452,55 @@ def curate_from_google_trends(posted_titles_data, posted_titles, used_images_dat
logging.error(f"Unexpected error in curate_from_google_trends: {e}", exc_info=True) logging.error(f"Unexpected error in curate_from_google_trends: {e}", exc_info=True)
return None, None, False return None, None, False
# System Activity Tracking
def update_system_activity(script_name, status, pid=None):
"""Update the system activity JSON file with the script's status."""
activity_file = "/home/shane/foodie_automator/system_activity.json"
activity_data = []
# Load existing data
if os.path.exists(activity_file):
try:
with open(activity_file, 'r') as f:
activity_data = json.load(f)
except json.JSONDecodeError:
logging.error("Corrupted system_activity.json, resetting to empty list")
# Find or create entry for the script
script_entry = next((entry for entry in activity_data if entry["script_name"] == script_name), None)
if not script_entry:
script_entry = {
"script_name": script_name,
"pid": None,
"start_time": None,
"stop_time": None,
"status": "stopped"
}
activity_data.append(script_entry)
# Update the entry
if status == "running":
script_entry.update({
"pid": pid,
"start_time": datetime.now(timezone.utc).isoformat(),
"stop_time": None,
"status": "running"
})
elif status == "stopped":
script_entry.update({
"pid": None,
"stop_time": datetime.now(timezone.utc).isoformat(),
"status": "stopped"
})
# Save updated data
try:
with open(activity_file, 'w') as f:
json.dump(activity_data, f, indent=2)
logging.info(f"Updated system activity: {script_name} is {status}")
except Exception as e:
logging.error(f"Failed to update system_activity.json: {e}")
def run_google_trends_automator(): def run_google_trends_automator():
lock_fd = None lock_fd = None
try: try:

@ -28,7 +28,7 @@ from foodie_utils import (
is_interesting, generate_title_from_summary, summarize_with_gpt4o, is_interesting, generate_title_from_summary, summarize_with_gpt4o,
generate_category_from_summary, post_to_wp, prepare_post_data, generate_category_from_summary, post_to_wp, prepare_post_data,
select_best_author, smart_image_and_filter, get_flickr_image, select_best_author, smart_image_and_filter, get_flickr_image,
get_next_author_round_robin, check_author_rate_limit get_next_author_round_robin, check_author_rate_limit, update_system_activity
) )
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt from foodie_hooks import get_dynamic_hook, get_viral_share_prompt
import fcntl import fcntl

@ -28,7 +28,7 @@ from foodie_utils import (
is_interesting, generate_title_from_summary, summarize_with_gpt4o, is_interesting, generate_title_from_summary, summarize_with_gpt4o,
generate_category_from_summary, post_to_wp, prepare_post_data, generate_category_from_summary, post_to_wp, prepare_post_data,
select_best_author, smart_image_and_filter, get_flickr_image, select_best_author, smart_image_and_filter, get_flickr_image,
get_next_author_round_robin, check_author_rate_limit get_next_author_round_robin, check_author_rate_limit, update_system_activity
) )
from foodie_hooks import get_dynamic_hook, get_viral_share_prompt from foodie_hooks import get_dynamic_hook, get_viral_share_prompt
from dotenv import load_dotenv from dotenv import load_dotenv

@ -8,7 +8,7 @@ import fcntl
import os import os
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from openai import OpenAI from openai import OpenAI
from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, check_author_rate_limit, load_json_file from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, check_author_rate_limit, load_json_file, update_system_activity
from foodie_config import X_API_CREDENTIALS, AUTHOR_BACKGROUNDS_FILE from foodie_config import X_API_CREDENTIALS, AUTHOR_BACKGROUNDS_FILE
from dotenv import load_dotenv from dotenv import load_dotenv

@ -10,7 +10,7 @@ import time
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
import tweepy import tweepy
from openai import OpenAI from openai import OpenAI
from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, load_json_file, check_author_rate_limit from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, load_json_file, check_author_rate_limit, update_system_activity
from foodie_config import X_API_CREDENTIALS, RECENT_POSTS_FILE from foodie_config import X_API_CREDENTIALS, RECENT_POSTS_FILE
from dotenv import load_dotenv from dotenv import load_dotenv

Loading…
Cancel
Save