国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

DIY個人智能家庭網關——python篇之推送手機上下線事件

2019-11-06 09:28:34
字體:
來源:轉載
供稿:網友
#!/usr/bin/env python# -*- coding: utf-8 -*- import timeimport subPRocessfrom time import sleepimport jsonmac = "a8:1b:5a:b7:e0:03"last_state = ""msg = ""def push_msg(msg):    content = {"platform":"all","audience":"all", "notification":{"alert":msg}}    print content    json_str = json.dumps(content)    print json_str    cmd = "curl -X POST  --cacert /etc/ssl/certs/ca-certificates.crt -v https://api.jpush.cn/v3/push/ -H /"Content-Type: application/json/" -u /"e5068f518ccb04cc92ac601f:9dd7a8d37bbfa2814648a6c5/""    curl_cmdline = '%s -d /'%s/''%(cmd,json_str)    print curl_cmdline    rc = subprocess.call(curl_cmdline, shell=True);     cmd = 'iw dev wlan0 station dump | grep Station'while True:  obj = subprocess.Popen(cmd,stdout=subprocess.PipE,stderr=subprocess.PIPE,shell=True)  obj.wait()  state = 'offline'  lines = obj.stdout.readlines()  for str in lines:										  	if str.find(mac) > 0:  		state = 'online'  		break  if last_state != state:    if state == 'online':      msg = "Welcome home!"    else:      msg = "Goodbye"    push_msg(msg)  last_state = state  time.sleep(2)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 赤城县| 桓台县| 垦利县| 多伦县| 阳城县| 尉犁县| 新民市| 蒙山县| 宿州市| 康平县| 安徽省| 犍为县| 桦川县| 汤阴县| 金湖县| 陵川县| 巫山县| 开封县| 内丘县| 黔江区| 五常市| 黄平县| 临邑县| 外汇| 根河市| 泌阳县| 鹿邑县| 莒南县| 鹤山市| 马关县| 武隆县| 江油市| 磐石市| 哈尔滨市| 古田县| 都江堰市| 建湖县| 金溪县| 长垣县| 巢湖市| 巢湖市|