18 lines
703 B
Python
18 lines
703 B
Python
import os, sys
|
|
import requests
|
|
from subprocess import Popen, PIPE
|
|
|
|
process = Popen(['wget','-O','/tmp/shot'+'foscam'+'.jpg','http://cam.home/media/?action=snapshot&user=admin&pwd=setaou'], stdout=PIPE)
|
|
(output, err) = process.communicate()
|
|
exit_code = process.wait()
|
|
process = Popen(["convert /tmp/shot"+'foscam'+".jpg -colorspace hsb -resize 1x1 txt: | grep \",*%)\" | cut -f 6 -d ',' | awk -F% '{print $1}'"], stdout=PIPE, shell=True)
|
|
(output, err) = process.communicate()
|
|
exit_code = process.wait()
|
|
print process
|
|
value = str(output).replace('\n','')
|
|
print value
|
|
url = 'http://localhost:81/json.htm?type=command¶m=udevice&idx=653&nvalue=0&svalue=' + value
|
|
r = requests.get(url)
|
|
print url
|
|
print r
|