convert to sydney time
This commit is contained in:
+13
-13
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import logging
|
||||
import pytz
|
||||
|
||||
logging.basicConfig(
|
||||
filename='/home/shane/foodie_automator/logs/check_x_capacity.log',
|
||||
@@ -99,27 +100,26 @@ def display_author_status(author):
|
||||
"""Display detailed status for a single author."""
|
||||
username = author['username']
|
||||
can_post, remaining, reset = check_author_rate_limit(author)
|
||||
reset_time = datetime.fromtimestamp(reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
# Only check API if no scripts are running
|
||||
if not is_any_script_running():
|
||||
api_remaining, api_reset = get_x_rate_limit_status(author)
|
||||
if api_remaining is not None:
|
||||
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||
# Use API values as primary display
|
||||
remaining = api_remaining
|
||||
reset_time = api_reset_time
|
||||
can_post = remaining > 0
|
||||
reset_time_utc = datetime.fromtimestamp(reset, tz=timezone.utc)
|
||||
reset_time_str = reset_time_utc.strftime('%Y-%m-%d %H:%M:%S UTC')
|
||||
# Convert to Sydney time
|
||||
try:
|
||||
sydney_tz = pytz.timezone('Australia/Sydney')
|
||||
reset_time_sydney = reset_time_utc.astimezone(sydney_tz)
|
||||
reset_time_sydney_str = reset_time_sydney.strftime('%Y-%m-%d %H:%M:%S %Z')
|
||||
except Exception as e:
|
||||
reset_time_sydney_str = 'N/A'
|
||||
|
||||
status = "✅" if can_post else "❌"
|
||||
print(f"\n{status} {username}:")
|
||||
print(f" • Remaining tweets: {remaining}/17")
|
||||
print(f" • Reset time: {reset_time}")
|
||||
print(f" • Reset time (UTC): {reset_time_str}")
|
||||
print(f" • Reset time (Sydney): {reset_time_sydney_str}")
|
||||
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
||||
|
||||
# Send alert if capacity is full
|
||||
if remaining == 0:
|
||||
send_capacity_alert(username, remaining, reset_time)
|
||||
send_capacity_alert(username, remaining, reset_time_str)
|
||||
|
||||
# Show API status for verification
|
||||
if not is_any_script_running():
|
||||
|
||||
Reference in New Issue
Block a user