44Notecard API commands.
55"""
66import notecard
7+ from .validators import validate_card_object
78
89
10+ @validate_card_object
911def attn (card , mode = None , files = None , seconds = None ):
1012 """Configure interrupt detection between a host and Notecard.
1113
@@ -17,9 +19,6 @@ def attn(card, mode=None, files=None, seconds=None):
1719 Returns:
1820 string: The result of the Notecard request.
1921 """
20- if not isinstance (card , notecard .Notecard ):
21- raise Exception ("Notecard object required" )
22-
2322 req = {"req" : "card.attn" }
2423 if mode :
2524 req ["mode" ] = mode
@@ -30,58 +29,51 @@ def attn(card, mode=None, files=None, seconds=None):
3029 return card .Transaction (req )
3130
3231
32+ @validate_card_object
3333def time (card ):
3434 """Retrieve the current time and date from the Notecard.
3535
3636 Returns:
3737 string: The result of the Notecard request.
3838 """
39- if not isinstance (card , notecard .Notecard ):
40- raise Exception ("Notecard object required" )
41-
4239 req = {"req" : "card.time" }
4340 return card .Transaction (req )
4441
4542
43+ @validate_card_object
4644def status (card ):
4745 """Retrieve the status of the Notecard.
4846
4947 Returns:
5048 string: The result of the Notecard request.
5149 """
52- if not isinstance (card , notecard .Notecard ):
53- raise Exception ("Notecard object required" )
54-
5550 req = {"req" : "card.status" }
5651 return card .Transaction (req )
5752
5853
54+ @validate_card_object
5955def temp (card ):
6056 """Retrieve the current temperature from the Notecard.
6157
6258 Returns:
6359 string: The result of the Notecard request.
6460 """
65- if not isinstance (card , notecard .Notecard ):
66- raise Exception ("Notecard object required" )
67-
6861 req = {"req" : "card.temp" }
6962 return card .Transaction (req )
7063
7164
65+ @validate_card_object
7266def version (card ):
7367 """Retrieve firmware version] information from the Notecard.
7468
7569 Returns:
7670 string: The result of the Notecard request.
7771 """
78- if not isinstance (card , notecard .Notecard ):
79- raise Exception ("Notecard object required" )
80-
8172 req = {"req" : "card.version" }
8273 return card .Transaction (req )
8374
8475
76+ @validate_card_object
8577def voltage (card , hours = None , offset = None , vmax = None , vmin = None ):
8678 """Retrive current and historical voltage info from the Notecard.
8779
@@ -94,9 +86,6 @@ def voltage(card, hours=None, offset=None, vmax=None, vmin=None):
9486 Returns:
9587 string: The result of the Notecard request.
9688 """
97- if not isinstance (card , notecard .Notecard ):
98- raise Exception ("Notecard object required" )
99-
10089 req = {"req" : "card.voltage" }
10190 if hours :
10291 req ["hours" ] = hours
@@ -109,6 +98,7 @@ def voltage(card, hours=None, offset=None, vmax=None, vmin=None):
10998 return card .Transaction (req )
11099
111100
101+ @validate_card_object
112102def wireless (card , mode = None ):
113103 """Retrive wireless modem info or customize modem behavior.
114104
@@ -118,9 +108,6 @@ def wireless(card, mode=None):
118108 Returns:
119109 string: The result of the Notecard request.
120110 """
121- if not isinstance (card , notecard .Notecard ):
122- raise Exception ("Notecard object required" )
123-
124111 req = {"req" : "card.wireless" }
125112 if mode :
126113 req ["mode" ] = mode
0 commit comments