def setup(app): if try_theme == 'bootstrap': app.add_stylesheet("restyle.css") from autopilot import prefs prefs.add('AUDIOSERVER', 'docs') prefs.add('AGENT', 'docs') #app.connect('build-finished', fix_html_links)
def setup(app): # if try_theme == 'bootstrap': app.add_css_file("restyle.css") # app.add_node(RoadmapNode, html=(visit_roadmap_node, depart_roadmap_node)) # app.add_directive('roadmap', RoadmapDirective) # app.add_directive('uml', UMLGenerateDirective) # app.add_role('cssclass', css_class_role) # app.add_node(RoadmapNode, html=(visit_roadmap_node, depart_roadmap_node)) # app.add_directive('roadmap', RoadmapDirective) from autopilot import prefs prefs.add('AUDIOSERVER', 'docs') prefs.add('AGENT', 'docs')
def l_start(self, value): """ Start running a task. Get the task object by using `value['task_type']` to select from :data:`.tasks.TASK_LIST` , then feed the rest of `value` as kwargs into the task object. Calls :meth:`.autopilot.run_task` in a new thread Args: value (dict): A dictionary of task parameters """ # TODO: If any of the sounds are 'file,' make sure we have them. If not, request them. # Value should be a dict of protocol params # The networking object should have already checked that we have all the files we need if self.state == "RUNNING" or self.running.is_set(): self.logger.warning("Asked to a run a task when already running") return self.state = 'RUNNING' self.running.set() try: # Get the task object by its type if 'child' in value.keys(): task_class = tasks.CHILDREN_LIST[value['task_type']] else: task_class = tasks.TASK_LIST[value['task_type']] # Instantiate the task self.stage_block.clear() # Make a group for this subject if we don't already have one self.subject = value['subject'] prefs.add('SUBJECT', self.subject) # Run the task and tell the terminal we have # self.running.set() threading.Thread(target=self.run_task, args=(task_class, value)).start() self.update_state() except Exception as e: self.state = "IDLE" self.logger.exception("couldn't start task: {}".format(e))
def setup(app): # if try_theme == 'bootstrap': app.add_css_file("restyle.css") # app.connect('autodoc-process-docstring', catch_signature) # app.add_node(RoadmapNode, html=(visit_roadmap_node, depart_roadmap_node)) # app.add_directive('roadmap', RoadmapDirective) # app.add_directive('uml', UMLGenerateDirective) # app.add_role('cssclass', css_class_role) # app.add_node(RoadmapNode, html=(visit_roadmap_node, depart_roadmap_node)) # app.add_directive('roadmap', RoadmapDirective) from autopilot import prefs prefs.add('AUDIOSERVER', 'docs') prefs.add('AGENT', 'docs') #app.connect('build-finished', fix_html_links)
def dlc_dir(self) -> str: """ ``{prefs.BASE_DIR}/dlc`` Returns: str """ if 'DLCDIR' in prefs.prefdict.keys(): dlc_dir = prefs.DLCDIR else: dlc_dir = os.path.join(prefs.BASEDIR, 'dlc') if not os.path.exists(dlc_dir): try: os.mkdir(dlc_dir) except OSError as e: raise OSError( f'No DLC dir found and one could not be created!\n{e}') prefs.add('DLC_DIR', dlc_dir) return dlc_dir
def __init__(self): # type: () -> None super(Terminal, self).__init__() # networking self.node = None self.networking = None self.heartbeat_dur = 10 # check every n seconds whether our pis are around still # data self.subjects = {} # Dict of our open subject objects self.pilots = None # gui self.layout = None self.widget = None self.file_menu = None self.tool_menu = None self.control_panel = None self.data_panel = None self.logo = None # logging self.logger = None self.log_handler = None self.log_formatter = None # Load pilots db as ordered dictionary with open(prefs.PILOT_DB) as pilot_file: self.pilots = json.load(pilot_file, object_pairs_hook=odict) # Start Logging self.init_logging() # Listen dictionary - which methods to call for different messages # Methods are spawned in new threads using handle_message self.listens = { 'STATE': self.l_state, # A Pi has changed state 'PING': self.l_ping, # Someone wants to know if we're alive 'DATA': self.l_data, 'HANDSHAKE': self.l_handshake # a pi is making first contact, telling us its IP } # Make invoker object to send GUI events back to the main thread self.invoker = Invoker() prefs.add('INVOKER', self.invoker) self.initUI() # Start Networking # Networking is in two parts, # "internal" networking for messages sent to and from the Terminal object itself # "external" networking for messages to and from all the other components, # The split is so the external networking can run in another process, do potentially time-consuming tasks # like resending & confirming message delivery without blocking or missing messages self.node = Net_Node(id="_T", upstream='T', port=prefs.MSGPORT, listens=self.listens) self.logger.info("Net Node Initialized") # Start external communications in own process # Has to be after init_network so it makes a new context self.networking = Terminal_Station(self.pilots) self.networking.start() self.logger.info("Station object Initialized") # send an initial ping looking for our pilots self.node.send('T', 'INIT') # start beating ur heart self.heartbeat_timer = threading.Timer(self.heartbeat_dur, self.heartbeat) self.heartbeat_timer.daemon = True self.heartbeat_timer.start()