国产探花免费观看_亚洲丰满少妇自慰呻吟_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)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 福贡县| 军事| 大兴区| 曲水县| 山西省| 潼南县| 宜春市| 凭祥市| 上思县| 托克托县| 四子王旗| 梁河县| 南投市| 嵊泗县| 莲花县| 琼中| 辉南县| 白银市| 涟水县| 林甸县| 磴口县| 永嘉县| 绥江县| 卫辉市| 郓城县| 积石山| 广丰县| 顺平县| 丽水市| 社旗县| 斗六市| 金平| 宁河县| 电白县| 韶山市| 台安县| 叶城县| 缙云县| 江都市| 勐海县| 珠海市|