@@ -112,14 +112,14 @@ def post(self):
112
112
113
113
if not req :
114
114
req = {}
115
+
115
116
if req .get ('mid' ) and str (req .get ('mid' )) in g .monitor_config :
116
117
mid = str (req .get ('mid' ))
117
118
g .logger .Debug (1 , 'Monitor ID {} provided & matching config found in mlapi, ignoring objectconfig.ini' .format (mid ))
118
119
config_copy = copy .copy (g .config )
119
120
poly_copy = copy .copy (g .polygons )
120
121
g .polygons = copy .copy (g .monitor_polygons [mid ])
121
122
122
-
123
123
for key in g .monitor_config [mid ]:
124
124
# This will also take care of copying over mid specific stream_options
125
125
g .logger .Debug (2 , 'Overriding global {} with {}...' .format (key , g .monitor_config [mid ][key ][:30 ]))
@@ -139,8 +139,6 @@ def post(self):
139
139
140
140
g .polygons [:] = [item for item in g .polygons if utils .findWholeWord (item ['name' ])(r )]
141
141
g .logger .Debug (2 , 'Final polygons being used: {}' .format (g .polygons ))
142
-
143
-
144
142
if g .config ['ml_sequence' ] and g .config ['use_sequence' ] == 'yes' :
145
143
g .log .Debug (2 ,'using ml_sequence' )
146
144
ml_options = g .config ['ml_sequence' ]
@@ -153,7 +151,7 @@ def post(self):
153
151
ml_options = utils .convert_config_to_ml_sequence ()
154
152
155
153
g .logger .Debug (2 , 'Overwriting ml_sequence of pre loaded model' )
156
- m .set_ml_options (ml_options )
154
+ m .set_ml_options (ml_options )
157
155
else :
158
156
g .logger .Debug (1 ,'Monitor ID not specified, or not found in mlapi config, using zm_detect overrides' )
159
157
ml_overrides = req .get ('ml_overrides' ,{})
@@ -167,20 +165,22 @@ def post(self):
167
165
else :
168
166
g .logger .Debug (2 ,'mapping legacy ml data from config' )
169
167
ml_options = utils .convert_config_to_ml_sequence ()
168
+ if 'polygons' in req .get ('stream_options' , {}):
169
+ g .logger .Debug (2 , "Set polygons from request" )
170
+ g .polygons = req .get ('stream_options' )['polygons' ]
171
+ poly_copy = copy .deepcopy (g .polygons )
170
172
171
- #print (ml_options)
172
-
173
173
if g .config .get ('stream_sequence' ):
174
174
g .logger .Debug (2 , 'Found stream_sequence in mlapi config, ignoring objectconfig.ini' )
175
175
stream_options = ast .literal_eval (g .config .get ('stream_sequence' ))
176
176
else :
177
177
stream_options = req .get ('stream_options' )
178
178
if not stream_options :
179
- if config_copy :
180
- g .log .Debug (2 , 'Restoring global config & ml_options' )
181
- g .config = config_copy
182
- g .polygons = poly_copy
183
- abort (400 , msg = 'No stream options found' )
179
+ if config_copy :
180
+ g .log .Debug (2 , 'Restoring global config & ml_options' )
181
+ g .config = config_copy
182
+ g .polygons = poly_copy
183
+ abort (400 , msg = 'No stream options found' )
184
184
stream_options ['api' ] = zmapi
185
185
stream_options ['polygons' ] = g .polygons
186
186
0 commit comments