datagutten / apc-smartconnect-py Goto Github PK
View Code? Open in Web Editor NEWA Python class to get info from APC SmartConnect
License: GNU General Public License v3.0
A Python class to get info from APC SmartConnect
License: GNU General Public License v3.0
Seems something is wrong:
Traceback (most recent call last):
File "/home/xxx/apc-smartconnect-py/sample.py", line 11, in <module>
smart.login(sys.argv[1], sys.argv[2])
File "/home/xxx/apc-smartconnect-py/apc_smartconnect/APCSmartConnect.py", line 85, in login
frontdoor = self.get_meta_redirect(response2.text)
File "/home/xxx/apc-smartconnect-py/apc_smartconnect/APCSmartConnect.py", line 50, in get_meta_redirect
url = matches.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
Any idea why? UPS is visible on APC portal...
Hi. How do i use this? I am trying your sample.py, but i keep getting an error:
/apc-smartconnect-py$ python3 sample.py 'myusername' 'mypassword
Traceback (most recent call last):
File "/home/sutadmin/apc-poller/apc-smartconnect-py/sample.py", line 8, in <module>
smart = APCSmartConnect('cookies.lwp')
TypeError: APCSmartConnect.__init__() takes 1 positional argument but 2 were given
Just a FYI, I had to modify sample.py to get it to call all the gateways correctly:
gateways_data = smart.gateways() # Fetch all gateways (UPSs)
for gateway in gateways_data["gateways"]:
pprint(smart.gateway_info(gateway["deviceId"]))
hi, we have integrated your script into our icinga and we monitor a smart ups.
we've got that error message when the website was in maintenance mode, can you catch that error and configure the output to be warning?
Traceback (most recent call last):File "/usr/lib/nagios/plugins/apc-smartconnect/apc-smartconnect-info.py", line 12, in smart.login(sys.argv[1], sys.argv[2]) File "/usr/lib/nagios/plugins/apc-smartconnect/apc_smartconnect/APCSmartConnect.py", line 70, in login response = self.session.get(response.headers['Location']) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 528, in request prep = self.prepare_request(req) File "/usr/lib/python3/dist-packages/requests/sessions.py", line 456, in prepare_request p.prepare( File "/usr/lib/python3/dist-packages/requests/models.py", line 316, in prepare self.prepare_url(url, params) File "/usr/lib/python3/dist-packages/requests/models.py", line 390, in prepare_url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL '/maintenance': No schema supplied. Perhaps you meant http:///maintenance?
thanks and have a great day!
cheers Ringo
Not sure if how to make use of this.
Installed with pip.
Just copied your script:
import os
import tempfile
from apc_smartconnect import APCSmartConnect
cookies_temp = tempfile.NamedTemporaryFile()
apc = APCSmartConnect()
apc.login(os.getenv('APC_USER'), os.getenv('APC_PASS'))
def test_gateways():
gateways = apc.gateways()
assert type(gateways) == list
assert type(gateways[0]) == str
I get the following error:
Exception ignored in: <function APCSmartConnect.del at 0x000001FB10D20AE0>
Traceback (most recent call last):
File "C:\Users\EyonB\AppData\Local\Programs\Python\Python312\Lib\site-packages\apc_smartconnect\APCSmartConnect.py", line 42, in del
self.cookies.save()
^^^^^^^^^^^^
AttributeError: 'APCSmartConnect' object has no attribute 'cookies'
Traceback (most recent call last):
File "F:\Programming\Python\APC\APC.py", line 7, in
apc = APCSmartConnect()
TypeError: APCSmartConnect.init() missing 1 required positional argument: 'cookie_file'
Not really sure how to get around this. Now I'm assuming I could add a file and path to apc = APCSmartConnect( file and path) but as to what type of file to create and link is a bit foreign to me.
Not a programmer per se but trying to make use of this for collecting some data metrics.
Any help would be greatly appreciated.
Eyon
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.