Example #1
0
path = "/do/kana/www/"

"""
Get ip from database on Kana
@todo make it usable without kana
"""

# Get port
with open('/do/computers/python/port', 'r') as port_file:
    content = port_file.read()
    socket_port = int(content.strip())
Socket.Start(socket_port)
print "Socket Started"

ips, actions = State.getIP()
ip_states = Ping.all(ips, actions)

try:
    while True:
        time.sleep(sleep_between_ping)

        for i, ip_state in enumerate(ip_states):
            state, result = Ping.checkState(ip_state)
            ip_states[i] = state
            if(result):
                data = state["ip"]
                if state["state"]:
                    State.checkComputers(state["ip"], actions, 1)
                    state = "on"
                else:
                    State.checkComputers(state["ip"], actions, 0)