import bottle
import waitress
import controller
import breathe
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = breathe.Breathe()
my_controller = controller.Controller(bottle_app, breather)


@scheduler.scheduled_job(trigger='cron', hour=17, minute=30)
def on_job():
    """Start at 7:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()


@scheduler.scheduled_job(trigger='cron', hour=19, minute=30)
def off_job():
    """End at 9:00pm PT"""
    print("STOPPING BREATHER")
    breather.stop()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

import bottle
from cso_parser import CsoParser
import waitress
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler
from breathe import Breathe
from controller import Controller

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = Breathe()
cso_parser = CsoParser()
my_controller = Controller(bottle_app, breather)


@scheduler.scheduled_job(trigger='cron', hour=17, minute=30)
def on_job():
    """Start at 7:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()


@scheduler.scheduled_job(trigger='cron', hour=19, minute=30)
def off_job():
    """End at 9:00pm PT"""
    print("STOPPING BREATHER")
    breather.stop()


@scheduler.scheduled_job(trigger='cron', hour=1, minute=30)
def cso_job():
    """Get CSO data at 1:30am and update the breather with the current status."""
    print("Fetch CSO status and update breather.")
    cso_parser.update()

    if cso_parser.now_count or cso_parser.recent_count:
        breather.erratic()
    else:
        breather.calm()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

Add scheduled cso_job method - Retrieves the CSO status and updates the breathe rate
Add scheduled cso_job method
  - Retrieves the CSO status and updates the breathe rate

  import bottle
+ from cso_parser import CsoParser
  import waitress
- import controller
- import breathe
  from pytz import timezone
  from apscheduler.schedulers.background import BackgroundScheduler
+ from breathe import Breathe
+ from controller import Controller
  
  bottle_app = bottle.app()
  scheduler = BackgroundScheduler()
  scheduler.configure(timezone=timezone('US/Pacific'))
- breather = breathe.Breathe()
+ breather = Breathe()
+ cso_parser = CsoParser()
- my_controller = controller.Controller(bottle_app, breather)
+ my_controller = Controller(bottle_app, breather)
  
  
  @scheduler.scheduled_job(trigger='cron', hour=17, minute=30)
  def on_job():
      """Start at 7:00pm PT"""
      print('STARTING BREATHER')
      breather.restart()
  
  
  @scheduler.scheduled_job(trigger='cron', hour=19, minute=30)
  def off_job():
      """End at 9:00pm PT"""
      print("STOPPING BREATHER")
      breather.stop()
  
+ 
+ @scheduler.scheduled_job(trigger='cron', hour=1, minute=30)
+ def cso_job():
+     """Get CSO data at 1:30am and update the breather with the current status."""
+     print("Fetch CSO status and update breather.")
+     cso_parser.update()
+ 
+     if cso_parser.now_count or cso_parser.recent_count:
+         breather.erratic()
+     else:
+         breather.calm()
+ 
  if __name__ == '__main__':
      scheduler.start()
      waitress.serve(bottle_app, host='0.0.0.0', port=7000)
  
Add scheduled cso_job method - Retrieves the CSO status and updates the breathe rate
## Code Before:
import bottle
import waitress
import controller
import breathe
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = breathe.Breathe()
my_controller = controller.Controller(bottle_app, breather)


@scheduler.scheduled_job(trigger='cron', hour=17, minute=30)
def on_job():
    """Start at 7:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()


@scheduler.scheduled_job(trigger='cron', hour=19, minute=30)
def off_job():
    """End at 9:00pm PT"""
    print("STOPPING BREATHER")
    breather.stop()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

## Instruction:
Add scheduled cso_job method - Retrieves the CSO status and updates the breathe rate
## Code After:
import bottle
from cso_parser import CsoParser
import waitress
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler
from breathe import Breathe
from controller import Controller

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = Breathe()
cso_parser = CsoParser()
my_controller = Controller(bottle_app, breather)


@scheduler.scheduled_job(trigger='cron', hour=17, minute=30)
def on_job():
    """Start at 7:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()


@scheduler.scheduled_job(trigger='cron', hour=19, minute=30)
def off_job():
    """End at 9:00pm PT"""
    print("STOPPING BREATHER")
    breather.stop()


@scheduler.scheduled_job(trigger='cron', hour=1, minute=30)
def cso_job():
    """Get CSO data at 1:30am and update the breather with the current status."""
    print("Fetch CSO status and update breather.")
    cso_parser.update()

    if cso_parser.now_count or cso_parser.recent_count:
        breather.erratic()
    else:
        breather.calm()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)
