s-celles / APC

APC power switch automation
MIT License
30 stars 9 forks source link

Status fails on AP7902 and AP7930 PDUs #13

Open fresnoboy opened 4 years ago

fresnoboy commented 4 years ago

This is a great utility. I use it on 3 types of PDUs, the AP7901, AP7902, and AP7930.

Control works fine on all units - I can turn outlets on and off just fine. However the status command errors on all but the AP7901.

On the 7902, I get this error:

Acquiring lock /tmp/apc.lock Connecting to APC @ 10.1.80.181 Logged in as user apc, version 3.9.2 DISCONNECTED from 10.1.80.181 Traceback (most recent call last): File "/usr/local/bin/apc", line 10, in sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/apc/cli_apc.py", line 69, in main print(apc.status()) File "/usr/local/lib/python2.7/dist-packages/apc/utility.py", line 343, in status ol_collection = Outlets(lst_outlets) File "/usr/local/lib/python2.7/dist-packages/apc/outlet.py", line 95, in init raise OutletsException("Outlet %d ever exists in this collection" % outlet.id) apc.outlet.OutletsException: Outlet 1 ever exists in this collection

On the AP7930s, I get this:

Acquiring lock /tmp/apc.lock Connecting to APC @ 10.1.1.222 Logged in as user apc, version 3.9.2 DISCONNECTED from 10.1.1.222 APC failed! Pexpect result: Timeout exceeded. <pexpect.pty_spawn.spawn object at 0x766b4970> command: /usr/bin/telnet args: ['/usr/bin/telnet', '10.1.1.222'] buffer (last 100 chars): 'let 21 ON\r\n 22- Outlet 22 ON\r\n\r Press to continue...' before (last 100 chars): 'let 21 ON\r\n 22- Outlet 22 ON\r\n\r Press to continue...' after: <class 'pexpect.exceptions.TIMEOUT'> match: None match_index: None exitstatus: None flag_eof: False pid: 24668 child_fd: 5 closed: False timeout: 10 delimiter: <class 'pexpect.exceptions.EOF'> logfile: None logfile_read: None logfile_send: None maxread: 2000 ignorecase: False searchwindowsize: None delaybeforesend: 0.05 delayafterclose: 0.1 delayafterterminate: 0.1 searcher: searcher_re: 0: re.compile('')

apc is running on a raspberry pi, but this error doesn't seem related to that.

Elegond commented 4 years ago

i get the same error with my ap7922 as you get with your ap7902

It helped me to adjust the APC_OUTLET_ROW_PATTERN and APC_OUTLET_ROW_PATTERN2 in outlet.py

APC_OUTLET_ROW_PATTERN = re.compile(r'Outlet (\d{,2}) (.*) (OFF\*?|ON\*?)')
APC_OUTLET_ROW_PATTERN2 = re.compile(r'(\d{,2})- (.*) (OFF\*?|ON\*?)')