cwisbg

timeLapsSetup_v1

Dec 14th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. # Time laps Setup
  2. # Run (though terminal)
  3. # python timeLapsSetup.py
  4. # cwisbg.com
  5. import socket
  6. import os
  7. import time
  8. start = time.clock()
  9. global fileCheck
  10. #open sockets
  11. maya = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12. maya.connect(('localhost', 6000))
  13. def checkFile():
  14.     global fileCheck
  15.     # Check for tracker file
  16.     filePath = (os.path.expanduser("~/Documents/maya/timeLapsTracker.txt"))
  17.     try:
  18.         fileCheck = open(filePath, "r")
  19.     except:
  20.         fileCheck = 0
  21. # Set up
  22. importStuff  = "import timeLaps\n"+"reload(timeLaps)\n"
  23. # Track Loop
  24. picTrack = 0
  25. i = 0
  26. xx = 1
  27. catcher = 0
  28. fileCheck = 0
  29. checkFile()
  30. while fileCheck:
  31.     checkFile()
  32.     takePictureCmd = "timeLaps.takePicture('{0}')\n".format(picTrack)
  33.     sendCofirm = "print 'Confirm Send'\n"
  34.     sendCmd = importStuff + takePictureCmd
  35.     elapsed = (time.clock() - start)
  36.     if elapsed > 1:# Timer
  37.         print (sendCmd)
  38.         maya.send(bytes(sendCmd))
  39.         start = time.clock()
  40.         picTrack += 1
  41.     catcher += 1
  42.     i += 1
  43. else:
  44.     print ("no timeLaps file")
  45. maya.close()
Advertisement
Add Comment
Please, Sign In to add comment