-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOIShare.py
38 lines (32 loc) · 1.01 KB
/
OIShare.py
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
#!/usr/bin/env python
import urllib2
from time import sleep
def main():
opener = urllib2.build_opener()
connected = False
while not connected:
try:
response = opener.open( 'http://192.168.0.10/get_commandlist.cgi' ).read()
#response is xml file describing endpoints (urls.cgi) we can call:
if response.count('<version>2.50</version>') >0:
connected = True
except:
print "Trying to connect..."
sleep(3)
print "Connected!"
cmd = ''
while cmd != 'exit':
cmd = raw_input("Enter play/shutter/rec/off : ")
if cmd in ['play', 'shutter', 'rec']:
print opener.open( 'http://192.168.0.10/switch_cammode.cgi?mode=' + cmd ).read()
if cmd == 'shutter':
sleep(0.5)
print opener.open( 'http://192.168.0.10/exec_shutter.cgi?com=1st2ndpush' ).read();
sleep(0.5)
print opener.open( 'http://192.168.0.10/exec_shutter.cgi?com=2nd1strelease' ).read();
if cmd == 'off':
opener.open( 'http://192.168.0.10/exec_pwoff.cgi' ).read();
print 'bye'
return 0
if __name__ == '__main__':
main()