import time, os
from datetime import datetime
from alive_progress import alive_bar

## Schedule controller v.06-03-2022.
## NOTE Set terminal screen size.
os.system('mode con: cols=60 lines=16')

c = 1
while (c > 0):
    now = datetime.now()
    date_time = now.strftime('%H:%M')
    ## print('Time now: ' + date_time)
    ### os.system('cynthia.py')  # NOTE <=== The Python file script to run.

    ## NOTE Set a time for scheduler to auto-shutdown Windows PC.
    asdt = '19:00' ## example: 7.00pm.
    print('')
    print('  Windows set to shutdown after ' + str(asdt) + ' hours.')

    if date_time > asdt:
        print('> Shutdown sequence start in 10 secs...')
        time.sleep(10)
        os.system('shutdown /s /t 1')
    
    ## NOTE Run 'cynthia.py' every 60 mins. (3600 seconds).
    print('  Seconds remaining to next cycle:')
    with alive_bar(3600) as bar:
        for i in range(3600):
            time.sleep(1)
            bar()

## End