Python script listening
来源:互联网 发布:幸运星seo 编辑:程序博客网 时间:2024/06/06 00:06
#!/usr/bin/python
import socket
import struct
import fcntl
importsubprocess
import sys
MCAST_GRP ='224.1.1.1'
MCAST_PORT =5007
sock =socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR, 1)
sock.bind(('',MCAST_PORT))
mreq =struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP, mreq)
defget_ip_address(ifname):
s =socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
returnsocket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, #SIOCGIFADDR
struct.pack('256s',ifname[:15])
)[20:24])
id =get_ip_address('eth0')
ip1, ip2, ip3,ip4 = id.split('.')
print 'ID: ' ip4'-'
optionfile =open('/server/options.cfg','r')
options =optionfile.readline()
optionfile.close()
print"optons: " options
while True:
data =sock.recv(10240)
data =data.strip()
if data =="reboot":
print"rebooting..."
cmd = 'sudoreboot'
pid = subprocess.call(cmd,shell=True)
elif data =="reload":
optionfile =open('/server/options.cfg','r')
options =optionfile.readline()
optionfile.close()
elif data =="restart":
cmd ='/server/reload.sh&'
pid =subprocess.call(cmd, shell=True)
else:
print "shooting" data
cmd ='raspistill -o /tmp/photo.jpg ' options
pid =subprocess.call(cmd, shell=True)
print"creating directory"
cmd = 'mkdir/server/3dscan/' data
pid =subprocess.call(cmd, shell=True)
print "copyimage"
cmd = 'cp/tmp/photo.jpg /server/3dscan/' data "/" data "_" ip4'.jpg'
pid =subprocess.call(cmd, shell=True)
print"photo uploaded"
- Python script listening
- apache dos python script
- python script传参数
- Python Flask script 使用
- json2xml python script
- deeplab script---python
- My first Python script
- Python Script文件结构
- Run Python Script File
- Listening - Listening Primer
- Listening Comprehension
- English listening
- python script----BMP 2 JPG
- how to debug python script
- debugging python script in ipython
- python flask feather flaskext.script
- [Python] modify *.c -> *.java script
- Notepadpp的Python Script插件
- 链表常见操作:有序链表合并去重
- python学习之python中使用tab自动补齐
- 雨巷 戴望舒
- 渐行渐远的老朋友们,谢谢你们曾经陪我走过
- 【LeetCode】word ladder I&& II
- Python script listening
- Eclipse配置GitHub代码库(以Windows7为例)
- Winsocket 二:多线程阻塞服务器程序(tcp)
- poj 3261 Milk Patterns(后缀数组)
- windows免安装版mysql5.6.14教程
- 汉语与英语读音
- 【Android进阶】Android面试题目整理与讲解
- 程序设计实习MOOC/第十三周编程作业/A:集合加法
- Eclipse中Velocity插件安装注意事项