raspberry pi zero based drum machine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sShutdown.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import FSM
  2. import utils as u
  3. import menus as m
  4. import os
  5. import pygame
  6. import sys
  7. #====================================
  8. State = type("State", (object,), {})
  9. #====================================
  10. class State(object):
  11. def __init__(self, FSM):
  12. self.FSM = FSM
  13. def Enter(self):
  14. pass
  15. def Execute(self):
  16. pass
  17. def Exit(self):
  18. pass
  19. class Shutdown(State):
  20. def __init__(self,FSM):
  21. super(Shutdown, self).__init__(FSM)
  22. def Enter(self):
  23. o = self.FSM.owner
  24. o.draw.rectangle((0, 0, o.width, o.height), outline=0, fill=o.blue)
  25. o.center_block("shutting down", o.h2, [0, 0, o.width,o.height - 20], o.light_grey)
  26. o.center_block("(unplug in 20s)", o.h2, [0, 10, o.width,o.height+10], o.light_grey)
  27. o.center_block("thank you for playing", o.h2, [0, 30, o.width,o.height+30], o.light_grey)
  28. o.update_display(0)
  29. command = 'bash -c "sleep 5; sudo shutdown -h now"&'
  30. os.system(command)
  31. pygame.quit()
  32. sys.exit()
  33. super(Shutdown, self).Enter()
  34. def Execute(self):
  35. pass
  36. #self.FSM.stateLife += 1
  37. #os.system('sudo shutdown -r now')
  38. def Exit(self):
  39. pass