Spaces:
Sleeping
Sleeping
hf-actions
commited on
Commit
·
e8bb202
1
Parent(s):
be4feb4
chore: skip scheduled run when token validation fails; import time
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import logging
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import asyncio
|
| 5 |
import atexit
|
|
|
|
| 6 |
import gradio as gr
|
| 7 |
import threading
|
| 8 |
import requests
|
|
@@ -202,16 +203,23 @@ if __name__ == "__main__":
|
|
| 202 |
while True:
|
| 203 |
try:
|
| 204 |
logger.info("Starting scheduled daily generate_and_post run")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
# reuse existing generate_and_post helper: generate image (using provider order) and post
|
| 206 |
prompt = os.getenv("DAILY_PROMPT")
|
| 207 |
if not prompt:
|
| 208 |
prompt = '''Create a photorealistic, serene Buddhist scene at sunrise. A calm Buddha statue in side profile, seated in meditation on a stone platform. Soft golden morning light with gentle rim lighting. Misty mountains and ancient Buddhist temple stupas fading into the background, creating depth and a peaceful spiritual atmosphere. Subtle haze, warm earth tones, cinematic lighting, natural stone textures, shallow depth of field. A tranquil lotus flower near still reflective water in the foreground.
|
| 209 |
|
| 210 |
-
Generate a short, original Buddhist-style quote about mindfulness, impermanence, inner peace, or awareness. The quote must be calm, timeless, and simple (no modern language, no slang). Keep it under 18 words.
|
| 211 |
|
| 212 |
-
Overlay the generated quote text in the center of the image using an elegant serif or handwritten-style font. The text should be softly glowing, perfectly legible, minimal, and harmonious with the scene. Avoid bold, modern, or decorative typography.
|
| 213 |
|
| 214 |
-
Ultra-realistic photography style, fine-art cinematic composition, calming mood, high detail, balanced contrast, 4K quality.'''
|
| 215 |
try:
|
| 216 |
res = generate_and_post(prompt, caption=None, post=True, use_wisdom_as_prompt=True, caption_template=None, use_wisdom_as_caption=True)
|
| 217 |
logger.info("Scheduled run result: %s", res)
|
|
|
|
| 3 |
from dotenv import load_dotenv
|
| 4 |
import asyncio
|
| 5 |
import atexit
|
| 6 |
+
import time
|
| 7 |
import gradio as gr
|
| 8 |
import threading
|
| 9 |
import requests
|
|
|
|
| 203 |
while True:
|
| 204 |
try:
|
| 205 |
logger.info("Starting scheduled daily generate_and_post run")
|
| 206 |
+
# validate tokens for each scheduled run; skip this run if validation fails
|
| 207 |
+
if not validate_tokens():
|
| 208 |
+
logger.error("Scheduled run skipped due to token validation failure")
|
| 209 |
+
logger.info("Sleeping for %s hours before next scheduled run", interval_hours)
|
| 210 |
+
time.sleep(interval_hours * 3600)
|
| 211 |
+
continue
|
| 212 |
+
|
| 213 |
# reuse existing generate_and_post helper: generate image (using provider order) and post
|
| 214 |
prompt = os.getenv("DAILY_PROMPT")
|
| 215 |
if not prompt:
|
| 216 |
prompt = '''Create a photorealistic, serene Buddhist scene at sunrise. A calm Buddha statue in side profile, seated in meditation on a stone platform. Soft golden morning light with gentle rim lighting. Misty mountains and ancient Buddhist temple stupas fading into the background, creating depth and a peaceful spiritual atmosphere. Subtle haze, warm earth tones, cinematic lighting, natural stone textures, shallow depth of field. A tranquil lotus flower near still reflective water in the foreground.
|
| 217 |
|
| 218 |
+
Generate a short, original Buddhist-style quote about mindfulness, impermanence, inner peace, or awareness. The quote must be calm, timeless, and simple (no modern language, no slang). Keep it under 18 words.
|
| 219 |
|
| 220 |
+
Overlay the generated quote text in the center of the image using an elegant serif or handwritten-style font. The text should be softly glowing, perfectly legible, minimal, and harmonious with the scene. Avoid bold, modern, or decorative typography.
|
| 221 |
|
| 222 |
+
Ultra-realistic photography style, fine-art cinematic composition, calming mood, high detail, balanced contrast, 4K quality.'''
|
| 223 |
try:
|
| 224 |
res = generate_and_post(prompt, caption=None, post=True, use_wisdom_as_prompt=True, caption_template=None, use_wisdom_as_caption=True)
|
| 225 |
logger.info("Scheduled run result: %s", res)
|