1. import schedule
  2. import time
  3. import datetime
  4. def run_dev_env():
  5. """Executes the development environment script."""
  6. try:
  7. print(f"Running development environment at {datetime.datetime.now()}")
  8. # Add your development environment execution commands here.
  9. # Example:
  10. # import subprocess
  11. # subprocess.run(["python", "your_dev_script.py"])
  12. except Exception as e:
  13. print(f"Error running development environment: {e}")
  14. def main():
  15. """Schedules the development environment execution."""
  16. # Schedule the job to run every day at 10:00 AM.
  17. schedule.every().day.at("10:00").do(run_dev_env)
  18. # Basic input validation for scheduling time.
  19. while True:
  20. try:
  21. schedule_time_str = input("Enter the time to run the development environment (HH:MM - 24hr format, or 'exit'): ")
  22. if schedule_time_str.lower() == 'exit':
  23. break
  24. datetime.datetime.strptime(schedule_time_str, '%H:%M') # Validate format
  25. break # Exit loop if valid time entered
  26. except ValueError:
  27. print("Invalid time format. Please use HH:MM (24hr).")
  28. print("Scheduling development environment...")
  29. while True:
  30. schedule.run_pending()
  31. time.sleep(1)
  32. if __name__ == "__main__":
  33. main()

Add your comment