forked from Allow2/Allow2python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pair.py
executable file
·35 lines (29 loc) · 814 Bytes
/
pair.py
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
#!/usr/bin/python
import allow2, sys, getopt
def usage():
print 'pair.py -u <username> -p <password> <deviceToken> <deviceName>'
sys.exit(2)
def main(argv):
inputfile = ''
outputfile = ''
usr = None
pwd = None
try:
opts, args = getopt.getopt(argv,"hu:p:",["ifile=","ofile="])
except getopt.GetoptError:
usage()
for opt, arg in opts:
if opt == '-h':
usage()
elif opt in ("-u", "--username"):
usr = arg
elif opt in ("-p", "--password"):
pwd = arg
if (len(args) != 2) or (usr is None) or (pwd is None):
usage()
userId, pairId, children = allow2.pair(usr, pwd, args[0], args[1])
print 'userId: ', userId
print 'pairId: ', pairId
print 'children: ', children
if __name__ == "__main__":
main(sys.argv[1:])