Advertisement
Guest User

Untitled

a guest
Jul 29th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/usr/bin/python
  2. from fc_lib import *
  3. import signal
  4. import os
  5. import opc
  6. import sys
  7. import time
  8. #import cv2
  9.  
  10. pid = str(os.getpid())
  11. pidfile = "/var/run/mario.pid"
  12.  
  13. if os.path.isfile(pidfile):
  14. print "%s already exists, exiting" % pidfile
  15. sys.exit()
  16. else:
  17. file(pidfile, 'w').write(pid)
  18.  
  19. def set_exit_handler(func):
  20. signal.signal(signal.SIGTERM, func)
  21. def on_exit(sig, func=None):
  22. print "exit handler triggered"
  23. sys.exit(1)
  24.  
  25.  
  26. if __name__ == '__main__':
  27. set_exit_handler(on_exit)
  28. client = opc.Client('localhost:7890')
  29.  
  30. paths = ['/home/pi/fadecandy_shenanigans/mario_images/mario2.jpg',
  31. '/home/pi/fadecandy_shenanigans/mario_images/mario3.jpg',
  32. '/home/pi/fadecandy_shenanigans/mario_images/mario1.jpg']
  33. images = [read_image_to_array(path) for path in paths]
  34. images = images
  35. while True:
  36. for image in images:
  37. client.put_pixels(image)
  38. client.put_pixels(image)
  39. time.sleep(0.11)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement