mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-13 18:16:52 -07:00
fix test for server running
This commit is contained in:
parent
0b4b1dd5cd
commit
892c0837a6
1 changed files with 4 additions and 6 deletions
|
@ -237,11 +237,9 @@ def WakeOnLan(ethernet_address):
|
||||||
|
|
||||||
|
|
||||||
#Test Connection function
|
#Test Connection function
|
||||||
def TestCon(host,port):
|
def TestCon(host, port):
|
||||||
(family, socktype, proto, garbage, address) = socket.getaddrinfo(host, port)[0]
|
|
||||||
s = socket.socket(family, socktype, proto)
|
|
||||||
try:
|
try:
|
||||||
s.connect(address)
|
socket.create_connection((host, port))
|
||||||
return "Up"
|
return "Up"
|
||||||
except:
|
except:
|
||||||
return "Down"
|
return "Down"
|
||||||
|
@ -262,11 +260,11 @@ def WakeUp():
|
||||||
Logger.info("Loading WakeOnLan config from %s", configFilename)
|
Logger.info("Loading WakeOnLan config from %s", configFilename)
|
||||||
config.get("WakeOnLan", "host")
|
config.get("WakeOnLan", "host")
|
||||||
host = config.get("WakeOnLan", "host")
|
host = config.get("WakeOnLan", "host")
|
||||||
port = config.get("WakeOnLan", "port")
|
port = int(config.get("WakeOnLan", "port"))
|
||||||
mac = config.get("WakeOnLan", "mac")
|
mac = config.get("WakeOnLan", "mac")
|
||||||
|
|
||||||
i=1
|
i=1
|
||||||
while TestCon(host,port) == "Down" and i < 4:
|
while TestCon(host, port) == "Down" and i < 4:
|
||||||
Logger.info("Sending WakeOnLan Magic Packet for mac: %s", mac)
|
Logger.info("Sending WakeOnLan Magic Packet for mac: %s", mac)
|
||||||
WakeOnLan(mac)
|
WakeOnLan(mac)
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue