irrad_control/irrad_interpreter.py
def recv_cmd(self):
        """Method which is run in separate thread to receive some basic commands"""

        self.interpreter_rep = self.context.socket(zmq.REP)
        self.interpreter_rep.bind(self._tcp_addr(self.setup['port']['cmd']))

        while not self.stop_recv_cmd.is_set():

            # Check if were working on a command. We have to work sequentially
            if not self._busy_cmd:

                # Cmd must be dict with command as 'cmd' key and 'args', 'kwargs' keys
                cmd_dict = self.interpreter_rep.recv_json()

                # Set cmd to busy; other commands send will be queued and received later
                self._busy_cmd = True

                # Extract info from cmd_dict
                target = cmd_dict['target']
                cmd = cmd_dict['cmd']
                cmd_data = None if 'data' not in cmd_dict else cmd_dict['data']

                # Containers for errors
                error_reply = False

                # Command sanity checks
                if target not in self.commands:
                    msg = "Target '{}' unknown. Known targets are {}!".format(target, ', '.join(self.commands.keys()))
                    logging.error(msg)
                    error_reply = 'No interpreter target named {}'.format(target)

                elif cmd not in self.commands[target]:
                    msg = "Target command '{}' unknown. Known commands are {}!".format(cmd, ', '.join(self.commands[target]))
                    logging.error(msg)
                    error_reply = 'No target command named {}'.format(cmd)

                # Check for errors
                if error_reply:
                    self._send_reply(reply=error_reply, sender='interpreter', _type='ERROR', data=None)
                    self._busy_cmd = False
                else:
                    self.handle_cmd(target=target, cmd=cmd, cmd_data=cmd_data)
Method which is run in separate thread to receive some basic commands
Method which is run in separate thread to receive some basic commands
Method which is run in separate thread to receive some basic commands
def recv_cmd(self):
        self.interpreter_rep = self.context.socket(zmq.REP)
        self.interpreter_rep.bind(self._tcp_addr(self.setup['port']['cmd']))
        while not self.stop_recv_cmd.is_set():
            if not self._busy_cmd:
                cmd_dict = self.interpreter_rep.recv_json()
                self._busy_cmd = True
                target = cmd_dict['target']
                cmd = cmd_dict['cmd']
                cmd_data = None if 'data' not in cmd_dict else cmd_dict['data']
                error_reply = False
                if target not in self.commands:
                    msg = "Target '{}' unknown. Known targets are {}!".format(target, ', '.join(self.commands.keys()))
                    logging.error(msg)
                    error_reply = 'No interpreter target named {}'.format(target)
                elif cmd not in self.commands[target]:
                    msg = "Target command '{}' unknown. Known commands are {}!".format(cmd, ', '.join(self.commands[target]))
                    logging.error(msg)
                    error_reply = 'No target command named {}'.format(cmd)
                if error_reply:
                    self._send_reply(reply=error_reply, sender='interpreter', _type='ERROR', data=None)
                    self._busy_cmd = False
                else:
                    self.handle_cmd(target=target, cmd=cmd, cmd_data=cmd_data)
def recv_cmd ( self ) : self . interpreter_rep = self . context . socket ( zmq . REP ) self . interpreter_rep . bind ( self . _tcp_addr ( self . setup [ 'port' ] [ 'cmd' ] ) ) while not self . stop_recv_cmd . is_set ( ) : if not self . _busy_cmd : cmd_dict = self . interpreter_rep . recv_json ( ) self . _busy_cmd = True target = cmd_dict [ 'target' ] cmd = cmd_dict [ 'cmd' ] cmd_data = None if 'data' not in cmd_dict else cmd_dict [ 'data' ] error_reply = False if target not in self . commands : msg = "Target '{}' unknown. Known targets are {}!" . format ( target , ', ' . join ( self . commands . keys ( ) ) ) logging . error ( msg ) error_reply = 'No interpreter target named {}' . format ( target ) elif cmd not in self . commands [ target ] : msg = "Target command '{}' unknown. Known commands are {}!" . format ( cmd , ', ' . join ( self . commands [ target ] ) ) logging . error ( msg ) error_reply = 'No target command named {}' . format ( cmd ) if error_reply : self . _send_reply ( reply = error_reply , sender = 'interpreter' , _type = 'ERROR' , data = None ) self . _busy_cmd = False else : self . handle_cmd ( target = target , cmd = cmd , cmd_data = cmd_data )
Method which is run in separate thread to receive some basic commands
Method which is run in separate thread to receive some basic commands
"""Method which is run in separate thread to receive some basic commands""" # Check if were working on a command. We have to work sequentially # Cmd must be dict with command as 'cmd' key and 'args', 'kwargs' keys # Set cmd to busy; other commands send will be queued and received later # Extract info from cmd_dict # Containers for errors # Command sanity checks # Check for errors
self