Commit bb2edc6e authored by 簡碩辰's avatar 簡碩辰

Update run.py

parent cf92d410
import json, os, socket, time, subprocess as SP
import json, os, socket, time, datetime, pytz, subprocess as SP
from paho.mqtt.client import Client as MQTT
def TryConnect(host, port):
now = datetime.datetime.now(tz=pytz.timezone('Asia/Taipei'))
now = now.strftime('%Y/%m/%d %H:%M:%S')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((host, int(port)))
s.shutdown(socket.SHUT_RDWR)
return True
except ConnectionRefusedError:
print("Connect to {0}:{1} is refused.".format(host, port))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment