-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.py
executable file
·190 lines (170 loc) · 6.33 KB
/
config.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#!/usr/bin/python3
#-------------------------------------
# OGN-SWS Spain interface --- Settings
#-------------------------------------
#
#-------------------------------------
# Setting values
#-------------------------------------
#
import socket
import os
from configparser import ConfigParser
from parserfuncs import getinfoairport # the ogn/ham parser function
configdir=os.getenv('CONFIGDIR')
if configdir == None:
configdir='/etc/local/'
configfile=configdir+'SWSconfig.ini'
hostname = socket.gethostname()
processid = str(os.getpid())
if os.path.isfile(configfile):
cfg=ConfigParser() # get the configuration parameters
cfg.read(configfile) # reading it for the configuration file
else:
print ("Config file: ", configfile, " not found \n")
exit(-1)
APRS_SERVER_HOST = cfg.get ('APRS', 'APRS_SERVER_HOST').strip("'").strip('"')
APRS_SERVER_PORT = int(cfg.get('APRS', 'APRS_SERVER_PORT'))
APRS_USER = cfg.get ('APRS', 'APRS_USER').strip("'").strip('"')
APRS_PASSCODE = int(cfg.get('APRS', 'APRS_PASSCODE')) # See http://www.george-smart.co.uk/wiki/APRS_Callpass
APRS_FILTER_DETAILS = cfg.get ('APRS', 'APRS_FILTER_DETAILS').strip("'").strip('"')
APRS_FILTER_DETAILS = APRS_FILTER_DETAILS + '\n '
try:
location_name = cfg.get('location', 'location_name').strip("'").strip('"')
except:
location_name = ' '
if getinfoairport (location_name) != None:
#print(getinfoairport (config.location_name))
location_latitude = getinfoairport (location_name)['lat']
location_longitude = getinfoairport (location_name)['lon']
FLOGGER_LATITUDE = location_latitude
FLOGGER_LONGITUDE = location_longitude
else:
location_latitude = cfg.get(
'location', 'location_latitude').strip("'").strip('"')
location_longitude = cfg.get(
'location', 'location_longitud').strip("'").strip('"')
FLOGGER_LATITUDE = cfg.get(
'location', 'location_latitude').strip("'").strip('"')
FLOGGER_LONGITUDE = cfg.get(
'location', 'location_longitud').strip("'").strip('"')
try:
FILTER_LATI1 = float(cfg.get('filter', 'FILTER_LATI1'))
FILTER_LATI2 = float(cfg.get('filter', 'FILTER_LATI2'))
except:
FILTER_LATI1 = 0.0
FILTER_LATI2 = 0.0
try:
FILTER_LATI3 = float(cfg.get('filter', 'FILTER_LATI3'))
FILTER_LATI4 = float(cfg.get('filter', 'FILTER_LATI4'))
except:
FILTER_LATI3 = 0.0
FILTER_LATI4 = 0.0
# --------------------------------------#
try:
prttext = cfg.get('server', 'prt').strip("'")
if (prttext == 'False'):
prt = False
else:
prt = True
except:
prt = True
try:
cucFileLocation = cfg.get('server', 'cucFileLocation').strip("'").strip('"')
except:
cucFileLocation = "/var/www/html/cuc/"
try:
PIDfile = cfg.get('server', 'pid').strip("'").strip('"')
except:
PIDfile='/tmp/SWS.pid'
try:
DELAY = cfg.get('server', 'DELAY').strip("'").strip('"')
except:
DELAY = 0
#
# --------------------------------------#
try:
SPOTtext = cfg.get('location', 'SPOT').strip("'").strip('"')
except:
SPOTtext='False'
try:
LT24text = cfg.get('location', 'LT24').strip("'").strip('"')
LT24username = cfg.get('location', 'LT24username').strip("'").strip('"')
LT24password = cfg.get('location', 'LT24password').strip("'").strip('"')
except:
LT24text='False'
try:
SPIDERtext = cfg.get('location', 'SPIDER').strip("'").strip('"')
SPIuser = cfg.get('location', 'SPIuser').strip("'").strip('"')
SPIpassword = cfg.get('location', 'SPIpassword').strip("'").strip('"')
SPISYSid = cfg.get('location', 'SPISYSid').strip("'").strip('"')
except:
SPIDERtext='False'
try:
SKYLINEtext = cfg.get('location', 'SKYLINE').strip("'").strip('"')
except:
SKYLINEtext='False'
try:
OGNTtext = cfg.get('location', 'OGNT').strip("'").strip('"')
except:
OGNTtext='False'
try:
DDBhost = cfg.get('server', 'DDBhost').strip("'")
except:
DDBhost = 'ddb.acasado.name'
try:
DDBport = cfg.get('server', 'DDBport').strip("'")
except:
DDBport = '60082'
try:
DDBurl1 = cfg.get('server', 'DDBurl1').strip("'")
except:
DDBurl1 = 'http://ddb.acasado.name:60082/download/?j=2'
try:
DDBurl2 = cfg.get('server', 'DDBurl2').strip("'")
except:
DDBurl2 = 'http://DDB.glidernet.org/download/?j=2'
DBpath = cfg.get('server', 'DBpath').strip("'").strip('"')
MySQLtext = cfg.get('server', 'MySQL').strip("'").strip('"')
DBhost = cfg.get('server', 'DBhost').strip("'").strip('"')
DBuser = cfg.get('server', 'DBuser').strip("'").strip('"')
DBpasswd = cfg.get('server', 'DBpasswd').strip("'").strip('"')
DBuserread = cfg.get('server', 'DBuserread').strip("'").strip('"')
DBpasswdread = cfg.get('server', 'DBpasswdread').strip("'").strip('"')
DBname = cfg.get('server', 'DBname').strip("'").strip('"')
# -------------------------------------------------------------------------------#
APP='SWS'
if (MySQLtext == 'True'):
MySQL = True
else:
MySQL = False
if (SPIDERtext == 'True'):
SPIDER = True
else:
SPIDER = False
if (SPOTtext == 'True'):
SPOT = True
else:
SPOT = False
if (LT24text == 'True'):
LT24 = True
else:
LT24 = False
if (SKYLINEtext == 'True'):
SKYLINE = True
else:
SKYLINE = False
if (OGNTtext == 'True'):
OGNT = True
else:
OGNT = False
# --------------------------------------#
assert len(APRS_USER) > 3 and len(str(APRS_PASSCODE)) > 0, 'Please set APRS_USER and APRS_PASSCODE in settings.py.'
# --------------------------------------#
# report the configuration paramenters
print("\n\n")
print("Config file used: ", configfile, hostname, processid)
print("Config server values:", "MySQL =", MySQL, DBhost, DBuser, DBname, DBpath, cucFileLocation)
print("Config APRS values: ", APRS_SERVER_HOST, APRS_SERVER_PORT, APRS_USER, APRS_PASSCODE, APRS_FILTER_DETAILS)
print("Config location : ", location_name, location_latitude, location_longitude, "SPIDER=", SPIDER, "SPOT=", SPOT, "LT24=", LT24, "SKYLINE=", SKYLINE, "OGNtracker=", OGNT, "DELAY=", DELAY)
# --------------------------------------#