-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetState.py
More file actions
30 lines (22 loc) · 758 Bytes
/
getState.py
File metadata and controls
30 lines (22 loc) · 758 Bytes
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
#!/usr/bin/python
import os
import sys
import json
from pySwitcher import pySwitcher
def main(argv):
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
settingsPath = os.path.join(__location__, 'settings.json')
with open(settingsPath) as settings_file:
settings = json.load(settings_file)
assert(settings['username'] != ''), 'missing Username in settings.json'
assert(settings['password'] != ''), 'missing Password in settings.json'
switch = pySwitcher()
switch.login(settings['username'], settings['password'])
state = switch.getState()
print state
if(state == 'on'):
sys.exit(0)
else:
sys.exit(1)
if __name__ == "__main__":
main(sys.argv[1:])