fix running instead of sleep for X
This commit is contained in:
@@ -505,8 +505,10 @@ def run_google_trends_automator():
|
|||||||
if not post_data:
|
if not post_data:
|
||||||
logging.info("No postable Google Trend found")
|
logging.info("No postable Google Trend found")
|
||||||
logging.info("Completed Google Trends run")
|
logging.info("Completed Google Trends run")
|
||||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
|
||||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||||
|
# Sleep while still marked as running
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
update_system_activity(SCRIPT_NAME, "stopped") # Record stop after sleep
|
||||||
return post_data, category, sleep_time
|
return post_data, category, sleep_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Fatal error in run_google_trends_automator: {e}", exc_info=True)
|
logging.error(f"Fatal error in run_google_trends_automator: {e}", exc_info=True)
|
||||||
@@ -523,4 +525,4 @@ def run_google_trends_automator():
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup_logging()
|
setup_logging()
|
||||||
post_data, category, sleep_time = run_google_trends_automator()
|
post_data, category, sleep_time = run_google_trends_automator()
|
||||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
# logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||||
@@ -544,8 +544,10 @@ def run_reddit_automator():
|
|||||||
if not post_data:
|
if not post_data:
|
||||||
logging.info("No postable Reddit article found")
|
logging.info("No postable Reddit article found")
|
||||||
logging.info("Completed Reddit run")
|
logging.info("Completed Reddit run")
|
||||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
|
||||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||||
|
# Sleep while still marked as running
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
update_system_activity(SCRIPT_NAME, "stopped") # Record stop after sleep
|
||||||
return post_data, category, sleep_time
|
return post_data, category, sleep_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Fatal error in run_reddit_automator: {e}", exc_info=True)
|
logging.error(f"Fatal error in run_reddit_automator: {e}", exc_info=True)
|
||||||
|
|||||||
@@ -458,8 +458,10 @@ def run_rss_automator():
|
|||||||
if not post_data:
|
if not post_data:
|
||||||
logging.info("No postable RSS article found")
|
logging.info("No postable RSS article found")
|
||||||
logging.info("Completed RSS run")
|
logging.info("Completed RSS run")
|
||||||
update_system_activity(SCRIPT_NAME, "stopped") # Record stop
|
|
||||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||||
|
# Sleep while still marked as running
|
||||||
|
time.sleep(sleep_time)
|
||||||
|
update_system_activity(SCRIPT_NAME, "stopped") # Record stop after sleep
|
||||||
return post_data, category, sleep_time
|
return post_data, category, sleep_time
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Fatal error in run_rss_automator: {e}", exc_info=True)
|
logging.error(f"Fatal error in run_rss_automator: {e}", exc_info=True)
|
||||||
@@ -475,4 +477,4 @@ def run_rss_automator():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
post_data, category, sleep_time = run_rss_automator()
|
post_data, category, sleep_time = run_rss_automator()
|
||||||
logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
# logging.info(f"Run completed, sleep_time: {sleep_time} seconds")
|
||||||
+2
-2
@@ -93,8 +93,8 @@ stop_scripts() {
|
|||||||
import json, os
|
import json, os
|
||||||
f = '/home/shane/foodie_automator/system_activity.json'
|
f = '/home/shane/foodie_automator/system_activity.json'
|
||||||
if os.path.exists(f):
|
if os.path.exists(f):
|
||||||
with open(f) as fh:
|
with open(f, 'r') as fh:
|
||||||
data = json.load(f)
|
data = json.load(fh)
|
||||||
changed = False
|
changed = False
|
||||||
for entry in data:
|
for entry in data:
|
||||||
if entry.get('status') == 'running':
|
if entry.get('status') == 'running':
|
||||||
|
|||||||
Reference in New Issue
Block a user