Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def batch(self, fname):
''' Run a batch of scenarios. '''
# The contents of the scenario file are meant as a batch list:
# send to server and clear stack
self.reset()
try:
scentime, scencmd = zip(*[tc for tc in bs.stack.readscn(fname)])
bs.net.send_event(b'BATCH', (scentime, scencmd))
except FileNotFoundError:
return False, f'BATCH: File not found: {fname}'
return True
absolute = True
lat, lon = args
sender = stack.sender()
if sender:
if absolute:
self.client_pan[sender] = (lat, lon)
else:
ll = self.client_pan.get(sender) or self.def_pan
self.client_pan[sender] = (lat + ll[0], lon + ll[1])
else:
self.def_pan = (lat,lon) if absolute else (lat + self.def_pan[0],
lon + self.def_pan[1])
self.client_pan.clear()
bs.net.send_event(b'PANZOOM', dict(pan=(lat,lon), absolute=absolute))
elif eventname == b'BATCH':
# We are in a batch simulation, and received an entire scenario. Assign it to the stack.
self.reset()
bs.stack.set_scendata(eventdata['scentime'], eventdata['scencmd'])
self.op()
event_processed = True
elif eventname == b'GETSIMSTATE':
# Send list of stack functions available in this sim to gui at start
stackdict = {cmd : val[0][len(cmd) + 1:] for cmd, val in bs.stack.cmddict.items()}
shapes = [shape.raw for shape in areafilter.areas.values()]
simstate = dict(pan=bs.scr.def_pan, zoom=bs.scr.def_zoom,
stackcmds=stackdict, stacksyn=bs.stack.cmdsynon, shapes=shapes,
custacclr=bs.scr.custacclr, custgrclr=bs.scr.custgrclr,
settings=bs.settings._settings_hierarchy, plugins=list(plugin.plugin_descriptions.keys()))
bs.net.send_event(b'SIMSTATE', simstate, target=sender_rte)
else:
# This is either an unknown event or a gui event.
event_processed = bs.scr.event(eventname, eventdata, sender_rte)
return event_processed
def symbol(self):
bs.net.send_event(b'DISPLAYFLAG', dict(flag='SYM'))
actdata.show_apt += 1
else:
actdata.show_apt = 0
elif self.sender() == self.showwpt:
if actdata.show_wpt < 2:
actdata.show_wpt += 1
else:
actdata.show_wpt = 0
elif self.sender() == self.showlabels:
actdata.show_lbl -= 1
if actdata.show_lbl < 0:
actdata.show_lbl = 2
elif self.sender() == self.showmap:
actdata.show_map = not actdata.show_map
elif self.sender() == self.action_Save:
bs.net.send_event(b'STACKCMD', 'SAVEIC')
elif hasattr(self.sender(), 'host_id'):
bs.net.send_event(b'ADDNODES', 1)
def show_cmd_doc(self, cmd=''):
bs.net.send_event(b'SHOWDIALOG', dict(dialog='DOC', args=cmd))
def show_file_dialog(self):
bs.net.send_event(b'SHOWDIALOG', dict(dialog='OPENFILE'))
return ''
def closeEvent(self, event=None):
# Send quit to server if we own the host
if self.mode != 'client':
bs.net.send_event(b'QUIT')
app.instance().closeAllWindows()
# return True
elif self.sender() == self.panleft:
self.radarwidget.panzoom(pan=( 0.0, -0.5))
elif self.sender() == self.panright:
self.radarwidget.panzoom(pan=( 0.0, 0.5))
elif self.sender() == self.ic:
self.show_file_dialog()
elif self.sender() == self.sameic:
bs.net.send_event(b'STACKCMD', 'IC IC')
elif self.sender() == self.hold:
bs.net.send_event(b'STACKCMD', 'HOLD')
elif self.sender() == self.op:
bs.net.send_event(b'STACKCMD', 'OP')
elif self.sender() == self.fast:
bs.net.send_event(b'STACKCMD', 'FF')
elif self.sender() == self.fast10:
bs.net.send_event(b'STACKCMD', 'FF 0:0:10')
elif self.sender() == self.showac:
actdata.show_traf = not actdata.show_traf
elif self.sender() == self.showpz:
actdata.show_pz = not actdata.show_pz
elif self.sender() == self.showapt:
if actdata.show_apt < 3:
actdata.show_apt += 1
else:
actdata.show_apt = 0
elif self.sender() == self.showwpt:
if actdata.show_wpt < 2:
actdata.show_wpt += 1
else:
actdata.show_wpt = 0
elif self.sender() == self.showlabels:
actdata.show_lbl -= 1
def cmdline(self, text):
bs.net.send_event(b'CMDLINE', text)