Skip to content
This repository was archived by the owner on Feb 1, 2024. It is now read-only.

Commit ee59516

Browse files
committed
Merge pull request qca#1 from qca/master
Update to latest
2 parents a6b2c97 + 8352bc6 commit ee59516

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ The simplest tests consist of commands to type expected output. These tests use
99

1010
Test suites are located in `testsuites.cfg` and are simply lists of test names. Results of running a test suite are stored in a nicely formated html file that can be emailed to interested parties or sent to a database.
1111

12+
Getting involved
13+
--------------
14+
Have a question about BoardFarm? Want to know the best way to get involved? Found a bug? Here are the BoardFarm communication channels:
15+
16+
* Mailing List at [email protected] (sign up at http://lists.prplfoundation.org/cgi-bin/mailman/listinfo/boardfarm). Use this for general discussion or questions.
17+
* IRC at #boardfarm on Freenode. Use this for quick answers if someone is available (Sometimes no one is there)
18+
* Issue tracker at https://github.com/qca/boardfarm/issues. Use this for clear feature requests or bug reports. It's okay to also initially discuss a feature request on the mailing lists
19+
* Pull requests at https://github.com/qca/boardfarm. When you want to submit a change to Boardfarm!
20+
1221
Software Setup
1322
--------------
1423

devices/power.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
# This file is distributed under the Clear BSD license.
66
# The full text can be found in LICENSE in the root directory.
77

8+
try:
9+
from urllib.request import urlopen
10+
from urllib.error import HTTPError
11+
except:
12+
from urllib2 import urlopen, HTTPError
13+
814
import pexpect
915
import dlipower
1016

@@ -17,23 +23,18 @@ def get_power_device(ip_address, username=None, password=None, outlet=None):
1723
'''
1824
if ip_address is None:
1925
return HumanButtonPusher()
20-
p = pexpect.spawn('curl -L %s' % ip_address)
2126
try:
22-
t = p.expect_exact(['<title>Power Controller </title>',
23-
'Sentry Switched CDU',
24-
'<title>APC | Log On</title>'], timeout=90)
25-
except pexpect.EOF as e:
26-
if hasattr(p, "before"):
27-
print(p.before)
28-
raise Exception("Unable to connect to %s." % ip_address)
27+
data = urlopen("http://" + ip_address).read().decode()
28+
except HTTPError as e:
29+
data = e.read().decode()
2930
except Exception as e:
3031
print(e)
3132
raise Exception("\nError connecting to %s" % ip_address)
32-
if t == 0:
33+
if '<title>Power Controller' in data:
3334
return DLIPowerSwitch(ip_address, outlet=outlet, username=username, password=password)
34-
elif t == 1:
35+
if 'Sentry Switched CDU' in data:
3536
return SentrySwitchedCDU(ip_address, outlet=outlet)
36-
elif t == 2:
37+
if '<title>APC ' in data:
3738
return APCPower(ip_address, outlet=outlet)
3839
else:
3940
raise Exception("No code written to handle power device found at %s" % ip_address)

0 commit comments

Comments
 (0)