-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathtest_nutclient.py
More file actions
47 lines (36 loc) · 1.36 KB
/
test_nutclient.py
File metadata and controls
47 lines (36 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This source code is provided for testing/debuging purpose ;)
import logging
import sys
import nut2
from nut2 import PyNUTClient
if __name__ == "__main__" :
nut2.logger.setLevel(logging.DEBUG)
print( "PyNUTClient test..." )
nut = PyNUTClient()
#nut = PyNUTClient( login="upsadmin", password="upsadmin" )
print( 80*"-" + "\nTesting 'GetUPSList' :")
result = nut.GetUPSList( )
print( "\033[01;33m%s\033[0m\n" % result )
print( 80*"-" + "\nTesting 'GetUPSVars' :")
result = nut.GetUPSVars( "dummy" )
print( "\033[01;33m%s\033[0m\n" % result )
print( 80*"-" + "\nTesting 'GetUPSCommands' :")
result = nut.GetUPSCommands( "dummy" )
print( "\033[01;33m%s\033[0m\n" % result )
print( 80*"-" + "\nTesting 'GetRWVars' :")
result = nut.GetRWVars( "dummy" )
print( "\033[01;33m%s\033[0m\n" % result )
print( 80*"-" + "\nTesting 'RunUPSCommand' (Test front panel) :")
try :
result = nut.RunUPSCommand( "UPS1", "test.panel.start" )
except :
result = sys.exc_info()[1]
print( "\033[01;33m%s\033[0m\n" % result )
print( 80*"-" + "\nTesting 'SetUPSVar' (set ups.id to test):")
try :
result = nut.SetRWVar( "UPS1", "ups.id", "test" )
except :
result = sys.exc_info()[1]
print( "\033[01;33m%s\033[0m\n" % result )