only formatting hopefully
This commit is contained in:
parent
025c87216d
commit
8ad5f1964e
9 changed files with 241 additions and 198 deletions
16
main.py
16
main.py
|
|
@ -9,8 +9,9 @@ from utils.helpers import get_future_datetime
|
|||
import pytz
|
||||
from config.constants import RESOURCE_ID, TIMEZONE, SSO_PROVIDER, BOOKING_TIMES
|
||||
|
||||
|
||||
def main():
|
||||
load_dotenv('.env', override=True)
|
||||
load_dotenv(".env", override=True)
|
||||
username = os.getenv("USERNAME")
|
||||
password = os.getenv("PASSWORD")
|
||||
|
||||
|
|
@ -30,20 +31,22 @@ def main():
|
|||
|
||||
# Only wait for midnight if within 10 minutes, otherwise execute immediately
|
||||
now = datetime.datetime.now(tz)
|
||||
midnight = (now + datetime.timedelta(days=1)).replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
midnight = (now + datetime.timedelta(days=1)).replace(
|
||||
hour=0, minute=0, second=0, microsecond=0
|
||||
)
|
||||
seconds_until_midnight = (midnight - now).total_seconds()
|
||||
max_wait_seconds = 10 * 60 # 10 minutes
|
||||
|
||||
if 0 < seconds_until_midnight <= max_wait_seconds:
|
||||
print(f"⏳ Waiting {seconds_until_midnight:.0f} seconds until midnight...")
|
||||
print("⏳ Waiting {seconds_until_midnight:.0f} seconds until midnight...")
|
||||
time.sleep(seconds_until_midnight)
|
||||
elif seconds_until_midnight > max_wait_seconds:
|
||||
print(f"⚡ More than 10 min until midnight, executing immediately...")
|
||||
print("⚡ More than 10 min until midnight, executing immediately...")
|
||||
|
||||
for time_ in BOOKING_TIMES:
|
||||
try:
|
||||
start = get_future_datetime(hour=time_['start'])
|
||||
end = get_future_datetime(hour=time_['end'])
|
||||
start = get_future_datetime(hour=time_["start"])
|
||||
end = get_future_datetime(hour=time_["end"])
|
||||
|
||||
if RESOURCE_ID:
|
||||
resource_id = RESOURCE_ID
|
||||
|
|
@ -57,5 +60,6 @@ def main():
|
|||
except Exception as e:
|
||||
print(f"❌ Error booking slot {time_['start']}-{time_['end']}: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue