-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportWindow.py
More file actions
executable file
·42 lines (35 loc) · 1.2 KB
/
ImportWindow.py
File metadata and controls
executable file
·42 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
import time
import os
import os.path
import subprocess as sp
if __name__ == '__main__':
#windowname='Cheese'
windowname='"Take a Photo"'
failed=0
delay=1300
try:
while True:
if delay < 61:
imagename=os.environ['HOME']+'/andrea/O2test/'+time.strftime("%Y%b%d%H%M%S", time.localtime())+'.png'
else:
imagename=os.environ['HOME']+'/andrea/O2test/'+time.strftime("%Y%b%d%H%M", time.localtime())+'.png'
cmd='import -window '+windowname+' '+imagename
try:
sp.check_output(cmd, stderr=sp.STDOUT, shell=True)
except sp.CalledProcessError as e:
print cmd, 'FAILED:', e.output
failed=failed+1
if failed < 100:
continue
else:
break
if os.path.isfile(imagename):
print 'Image saved as ', imagename
else:
print 'Image NOT saved'
print 'press CTRL+C to stop'
# take a picture every 30 min
time.sleep(delay)
except KeyboardInterrupt:
print 'interrupted!'