-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_parms.py
executable file
·84 lines (72 loc) · 2.11 KB
/
s_parms.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python3
##!env python3
import json
import os
import signal
import subprocess
spider_parmfile = "spiderparms.json"
#default values
spider_parms = {"ON": False, "VOLUME":10000, "MAX_INT":25} # 0 <= VOLUME <= 1000000?
#---------------------------------------------------------------
def get_spider_parms():
global spider_parms
try:
with open(spider_parmfile, "r") as f:
spider_parms = json.load(f)
except FileNotFoundError:
print(spider_parmfile + ": not found. Using defaults.")
# use defaults defind above
pass
#---------------------------------------------------------------
def put_spider_parms():
global spider_parms
with open(spider_parmfile, "w") as f:
json.dump(spider_parms, f)
#---------------------------------------------------------------
# Get spider parms
get_spider_parms()
changed = False
try:
while True:
value = input("Sound T/F [" + str(spider_parms["ON"]) + "]: ")
if len(value) == 0:
break
if value.lower() == "true"[:len(value)]:
spider_parms["ON"] = True
changed = True
break
if value.lower() == "false"[:len(value)]:
spider_parms["ON"] = False
changed = True
break
while True:
value = input("Volume (0-1000000) [" + str(spider_parms["VOLUME"])\
+ "]: ")
if len(value) == 0:
break
if value.isdigit():
value = int(value)
else:
continue
if 0 <= value <= 1000000:
spider_parms["VOLUME"] = value
changed = True
break
while True:
value = input("Eye Power (0-100) [" + str(spider_parms["MAX_INT"])\
+ "]: ")
if len(value) == 0:
break
if value.isdigit():
value = int(value)
else:
continue
if 0 <= value <= 100:
spider_parms["MAX_INT"] = value
changed = True
break
except KeyboardInterrupt:
print()
if changed:
put_spider_parms()
print("\n", spider_parms)