2 from pcucontrol.reboot import *
3 ### rebooting x10toggle based systems addressed by port
4 # Marc E. Fiuczynski - May 31 2005
5 # tested on 4-ports models known as PSE505-FR
6 # uses ssh and password to login to an account
7 # that will cause the system to be powercycled.
10 def telnet_answer(telnet, expected, buffer):
13 output = telnet.read_until(expected, TELNET_TIMEOUT)
15 # logger.debug(output)
16 if output.find(expected) == -1:
17 raise ExceptionNotFound, "'%s' not found" % expected
19 telnet.write(buffer + "\r\n")
21 def x10toggle_reboot(ip, username, password, port, dryrun):
26 ssh = pyssh.Ssh(username, ip)
30 telnet_answer(ssh, "password:", password)
34 telnet_answer(ssh, "x10toggle>", "A%d" % port)
42 except Exception, err:
49 return errno.ETIMEDOUT