Exemplo n.º 1
0
    def format_run_request(cls, args):
        new_args = args.copy()
        path = ''
        for key in sorted(
            [a for a in new_args.keys() if a.startswith('subassistant_')]):
            if new_args[key]:
                path += '/' + new_args[key]
            del new_args[key]

        for key in [
                a for a in new_args.keys()
                if a.startswith('__') and a.endswith('__')
        ]:
            del new_args[key]

        message = {
            'query': {
                'request': 'run',
                'options': {
                    'path': path,
                    'pwd': os.getcwd(),
                    'arguments': new_args
                }
            }
        }
        if args.get('__debug__'):
            message['query']['options']['loglevel'] = 'DEBUG'
        json_message = json.dumps(message)
        logger.debug('Query to server: {}'.format(json_message))
        return cls.format_message(json_message)
Exemplo n.º 2
0
 def format_answer(cls, run_id, value):
     json_message = json.dumps(
         {'answer': {
             'id': run_id,
             'value': str(value)
         }})
     logger.debug('Reply to server: {}'.format(json_message))
     return cls.format_message(json_message)
Exemplo n.º 3
0
    def format_run_request(cls, args):
        new_args = args.copy()
        path = ''
        for key in sorted([a for a in new_args.keys() if a.startswith('subassistant_')]):
            if new_args[key]:
                path += '/' + new_args[key]
            del new_args[key]

        for key in [a for a in new_args.keys() if a.startswith('__') and a.endswith('__')]:
            del new_args[key]

        message = {'query': {'request': 'run', 'options': {'path': path,
                                                           'pwd': os.getcwd(),
                                                           'arguments': new_args}}}
        if args.get('__debug__'):
            message['query']['options']['loglevel'] = 'DEBUG'
        json_message = json.dumps(message)
        logger.debug('Query to server: {}'.format(json_message))
        return cls.format_message(json_message)
Exemplo n.º 4
0
 def format_answer(cls, run_id, value):
     json_message = json.dumps({'answer': {'id': run_id, 'value': str(value)}})
     logger.debug('Reply to server: {}'.format(json_message))
     return cls.format_message(json_message)
Exemplo n.º 5
0
 def format_stop_request(cls):
     json_message = json.dumps({'query': {'request': 'shutdown'}})
     logger.debug('Query to server: {}'.format(json_message))
     return cls.format_message(json_message)
Exemplo n.º 6
0
 def format_stop_request(cls):
     json_message = json.dumps({'query': {'request': 'shutdown'}})
     logger.debug('Query to server: {}'.format(json_message))
     return cls.format_message(json_message)