blob: a81f6d7f0ce36e63a152b7b24c91237fff28bb0f [file] [log] [blame]
Matt Hart76fb2542014-06-01 14:24:56 +01001#! /usr/bin/python
2
3# Copyright 2013 Linaro Limited
4# Author Matt Hart <matthew.hart@linaro.org>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19# MA 02110-1301, USA.
20
21import logging
22from apc7952 import apc7952
23
24class apc9218(apc7952):
25 handled_firmware = ["v3.0.3","v3.0.1"]
26
27 def _port_interaction(self, command, port_number):
28 print("Attempting command: %s port: %i" % (command, port_number))
29 ### make sure in main menu here
30 self._back_to_main()
31 self.connection.send("\r")
32 self.connection.expect("1- Device Manager")
33 self.connection.expect("> ")
34 logging.debug("Entering Device Manager")
35 self.connection.send("1\r")
36 self.connection.expect("------- Device Manager")
37 logging.debug("Got to Device Manager")
38 self._enter_outlet(port_number, False)
39 res = self.connection.expect(["1- Control Outlet", "1- Outlet Control/Configuration"])
40 self.connection.expect("> ")
41 self.connection.send("1\r")
42 res = self.connection.expect(["> ", "Press <ENTER> to continue..."])
43 if res == 1:
44 logging.debug("Stupid paging thingmy detected, pressing enter")
45 self.connection.send("\r")
46 self.connection.send("\r")
47 res = self.connection.expect(["Control Outlet %s" % port_number, "Control Outlet"])
48 self.connection.expect("3- Immediate Reboot")
49 self.connection.expect("> ")
50 if command == "on":
51 self.connection.send("1\r")
52 self.connection.expect("Immediate On")
53 self._do_it()
54 elif command == "off":
55 self.connection.send("2\r")
56 self.connection.expect("Immediate Off")
57 self._do_it()
58 else:
59 logging.debug("Unknown command!")
60
61 class Meta():
62 handled_firmware = ["v3.0.3","v3.0.1"]