本文整理汇总了Python中arduino.Arduino.get_is_door_open方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.get_is_door_open方法的具体用法?Python Arduino.get_is_door_open怎么用?Python Arduino.get_is_door_open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.get_is_door_open方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import get_is_door_open [as 别名]
def main():
network_clients_sh = path.join(path.dirname(__file__), 'networkClientsInNetwork.sh')
config_path = path.join(path.dirname(__file__), 'config.json')
print config_path
print network_clients_sh
with open(config_path) as config_fh:
config = json.load(config_fh)
args = get_args()
is_live_run = args["productive_system"]
base_url = config["URL"]
security_token = config["KEY"]
port = config["TTY"]
poster = Poster()
if is_live_run:
cprint("Live run!", color="magenta")
delay = 300
else:
cprint("Test run!", color="green")
delay = 3
arduino = Arduino(port=port)
arduino.start()
time.sleep(15)
network_clients_count = None
while True:
is_door_open = arduino.get_is_door_open()
temperature = arduino.get_temperature()
recieved = arduino.get_last_recieved()
nmap = subprocess.Popen(network_clients_sh, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
network_clients_count = int(nmap.stdout.readlines()[0])
poster.post_door_state(base_url, is_door_open, security_token)
poster.post_temperature(base_url, str(temperature), security_token)
poster.post_clients(base_url, str(network_clients_count), security_token)
cprint(str(datetime.datetime.now().strftime('%G-%b-%d-%H:%M:%S')), color="red")
cprint("Nmap " + str(network_clients_count), color="blue")
cprint("Tür offen: " + str(is_door_open), color="yellow")
cprint("Temperatur: " + str(temperature), color="cyan")
print recieved
print ("\n")
time.sleep(delay)