-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLastVersionByAntennaName-2-RANX.py
216 lines (170 loc) · 10.6 KB
/
getLastVersionByAntennaName-2-RANX.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import sys
from xml.dom import minidom
from suds.client import Client
import logging
if __name__ == '__main__':
#save_path_file = "20072021_ANTENNA-LIST.RANX.xml"
logging.basicConfig(filename='getLastVersionByAntennaName.log',level=logging.INFO,format='%(asctime)s %(message)s')
logging.info('INFO: Script started')
arguments = sys.argv # get the list of arguments passed to the script.
save_path_file = arguments[2] # get file name from 3rd Argument from command.
antenna_List = arguments[1].split(',') # get the 2 argument (antenna list to export) into a list
all_Antennas_Suds = dict() # This dict will hold all the antenna suds objects returned from the API
user = 'ams2talend'
pw = 'ams2talend'
wsdl = 'http://demucvak35.viaginterkom.de:8090/antenna-manager-prod/ws/amsService?wsdl'
#wsdl = 'http://demucvak35.viaginterkom.de:9090/antenna-manager-test/ws/amsService?wsdl'
client = Client(url=wsdl, username=user, password=pw) # Create SOAP Client.
logging.info('INFO: ' + str(len(antenna_List)) + ' Antennas to be exported')
# This antenna list will hold all antennas that exists on AMS from the arguments
# It will be used for the Antenna Family Name as AntennaType is missing from AMS
antennaNames = list()
for i in range(len(antenna_List)):
antenna = client.service.getLastVersionByAntennaName(antenna_List[i])
if antenna == None:
logging.warning('WARNING: ' + antenna_List[i] + ' was not found on AMS')
all_Antennas_Suds[i] = antenna # Add the Antenna suds object to the dictionary
antennaNames.append(antenna_List[i])
next
else:
all_Antennas_Suds[i] = antenna # Add the Antenna suds object to the dictionary
antennaNames.append(antenna_List[i])
root = minidom.Document() # minidom constructor.
# Set up of the RadioAccessNetwork tag for the RANX XML file.
ran = root.createElement("RadioAccessNetwork")
ran.setAttribute("name", "null")
ran.setAttribute("version", "3")
ran.setAttribute("xmlns", "urn:schemas-actix-com:radio-access-network")
root.appendChild(ran)
# Put every antenna on a dict and later on the XML format
for j in range(len(all_Antennas_Suds)):
if all_Antennas_Suds[j] == None:
next
else:
fullAntenna_dict = Client.dict(all_Antennas_Suds[j])
# Commenting antennaType out to avoid AMS API Bug
#antennaType = client.dict(fullAntenna_dict.get("antennaType")) # Get the AntennyType attribute
manufacturer = client.dict(fullAntenna_dict.get("manufacturer")) # Get the manufacturer attribute
owner = client.dict(fullAntenna_dict.get("operator")) # Get the operator attribute
antennaConfigs = client.items(fullAntenna_dict.get("configurations")) # Get all antenna configurations (patterns)
config_List = list(antennaConfigs) # Put all patterns on a list
# Get every pattern to a dict
config_Dict = dict()
for x in range(len(config_List)):
a = client.dict(config_List[x])
config_Dict[x] = a
angles = str() # Create an string variable and fill it with the angles (0 to 360°).
for y in range(0, 360, 1):
angles = angles + str(y) + " "
# Add the Antenna Type to the XML
# Commenting antennaType out to avoid AMS API Bug
#at = antennaType["name"]
at = antennaNames[j]
antennaType = root.createElement("AntennaType")
antennaType.setAttribute("name", at)
ran.appendChild(antennaType)
# logging antennas info for troubleshotting #####
#logging.info('INFO: Antenna Type: ' + at + ', manufacturer:' + manufacturer["name"])
for z in range(len(config_Dict)):
a = config_Dict[z]
# Creating a lits of tags to avoid non ATOLL Patterns
tagsNames = list()
tagsList = list(a['tags'])
for o in range(len(tagsList)):
tagsdict = client.dict(tagsList[o])
tagsNames.append(tagsdict['name'])
if 'ATOLL' in tagsNames:
beamPattern = root.createElement("BeamPattern")
try:
bP = a["exportName"]
except: bP = ""
beamPattern.setAttribute("name", bP)
try:
et = str(a["elTilt"])
except: et = ""
beamPattern.setAttribute("electricalDownTilt", et)
try:
fl = str(a["frequLow"])
except: fl = ""
beamPattern.setAttribute("frequencyRangeMin", fl)
try:
fh = str(a["frequHigh"])
except: fh = ""
beamPattern.setAttribute("frequencyRangeMax", fh)
antennaType.appendChild(beamPattern)
attribute1 = root.createElement("Attribute")
attribute1.setAttribute("name", "AntennaGroup")
attribute1.setAttribute("scope", "Common")
attribute1.setAttribute("type", "STRING")
try:
manu = manufacturer["name"]
except: manu = ""
attribute1.setAttribute("value", manu)
beamPattern.appendChild(attribute1)
attribute2 = root.createElement("Attribute")
attribute2.setAttribute("name", "horizontalBeamwidth")
attribute2.setAttribute("scope", "Common")
attribute2.setAttribute("type", "FLOAT")
try:
bw = str(a["beamWidthHor"])
except: bw = ""
attribute2.setAttribute("value", bw)
beamPattern.appendChild(attribute2)
attribute3 = root.createElement("Attribute")
attribute3.setAttribute("name", "isotropicGain")
attribute3.setAttribute("scope", "Common")
attribute3.setAttribute("type", "FLOAT")
try:
isotropicGain = str(a["gain"])
except: isotropicGain = ""
attribute3.setAttribute("value", isotropicGain)
beamPattern.appendChild(attribute3)
attribute4 = root.createElement("Attribute")
attribute4.setAttribute("name", "horizontalPatternAngles")
attribute4.setAttribute("scope", "Common")
attribute4.setAttribute("type", "STRING")
attribute4.setAttribute("value", angles)
beamPattern.appendChild(attribute4)
attribute5 = root.createElement("Attribute")
attribute5.setAttribute("name", "horizontalPatternLosses")
attribute5.setAttribute("scope", "Common")
attribute5.setAttribute("type", "STRING")
horizontalPatternLosses = str()
try:
hpl = a["diagramH"].split(";")
except: hpl = ""
for f in range(0,360):
horizontalPatternLosses = horizontalPatternLosses + hpl[f] + " "
attribute5.setAttribute("value", horizontalPatternLosses)
beamPattern.appendChild(attribute5)
attribute6 = root.createElement("Attribute")
attribute6.setAttribute("name", "verticalPatternAngles")
attribute6.setAttribute("scope", "Common")
attribute6.setAttribute("type", "STRING")
attribute6.setAttribute("value", angles)
beamPattern.appendChild(attribute6)
attribute7 = root.createElement("Attribute")
attribute7.setAttribute("name", "verticalPatternLosses")
attribute7.setAttribute("scope", "Common")
attribute7.setAttribute("type", "STRING")
verticalPatternLosses = str()
try:
vpl = a["diagramV"].split(";")
except: vpl = ""
for g in range(0,360):
verticalPatternLosses = verticalPatternLosses + vpl[g] + " "
attribute7.setAttribute("value", verticalPatternLosses)
beamPattern.appendChild(attribute7)
# Logging antennas info for troubleshotting ####
#logging.info('INFO: Antenna export Name: ' + bP + ', E-Tilt:' + et + ', frequlow: ' +
#fl + ', frequhigh: '+ fh + ', beamWidthHor: ' + bw + ', isotropicGain: ' +
#isotropicGain )
#logging.info('INFO: horizontalPatternLosses: ' + horizontalPatternLosses)
#logging.info('INFO: verticalPatternLosses: ' + verticalPatternLosses)
else:
continue
xml_str = root.toprettyxml(indent="\t", newl = '\n', encoding='UTF-8')
logging.info('INFO: File ' + save_path_file + ' saved')
with open(save_path_file, 'wb') as f:
f.write(xml_str)
logging.info('INFO: Script finished')