Example #1
0
def do_tests():
    job = dotdict()
    job.uuid = 'aeiou12345'

    while True:
        logger.info("Simulating postprocess_job")
        FakeJobCommand.postprocess_job(job, 'failed')
        time.sleep(0.5)
def do_tests():
    job = dotdict()
    job.uuid = 'aeiou12345'
    
    while True:
        logger.info("Simulating postprocess_job")
        FakeJobCommand.postprocess_job(job, 'failed')
        time.sleep(0.5)
 def build_arguments(self, **kwargs):
     for keyword in ('url', 'platefile', 'transaction_id'): # required keywords
         assert keyword in kwargs
     kwargs = dotdict(kwargs)
     arguments = [kwargs.url, kwargs.platefile]
     arguments += ['-t', str(kwargs.transaction_id)]
     if 'downsample' in kwargs and kwargs.downsample:
         arguments.append( "--downsample="+str(kwargs.downsample) )
     if 'normalize' in kwargs and kwargs.normalize:
         arguments.append('--normalize')
     return arguments
Example #4
0
 def build_arguments(self, **kwargs):
     for keyword in ('url', 'platefile',
                     'transaction_id'):  # required keywords
         assert keyword in kwargs
     kwargs = dotdict(kwargs)
     arguments = [kwargs.url, kwargs.platefile]
     arguments += ['-t', str(kwargs.transaction_id)]
     if 'downsample' in kwargs and kwargs.downsample:
         arguments.append("--downsample=" + str(kwargs.downsample))
     if 'normalize' in kwargs and kwargs.normalize:
         arguments.append('--normalize')
     return arguments
Example #5
0
def command_handler(msg):
    """ Unpack a message and process commands 
        Speaks the RpcRequest protocol.
    """
    global command_request_count
    command_request_count += 1
    mb.basic_ack(msg.delivery_tag)
    #cmd = protocols.unpack(protocols.Command, msg.body)
    request = protocols.unpack(protobuf.RpcRequestWrapper, msg.body)
    logger.debug("command_handler got a command: %s" % str(request.method))
    response = dotdict()
    response.sequence_number = request.sequence_number
    
    if request.method in command_map:
        t0 = datetime.now()
        try:
            response.payload = globals()[command_map[request.method]](request.payload)
            response.error = False
        except Exception as e:
            logger.error("Error in command '%s': %s %s" % (request.method, type(e),  str(e.args)))
            # TODO: send a stack trace.
            traceback.print_tb(sys.exc_info()[2]) # traceback
            response.payload = ''
            response.error = True
            response.error_string = str(e) or ''
        t1 = datetime.now()
        logger.info("COMMAND %s finished in %s." % (request.method, str(t1-t0)))
    else:
        logger.error("Invalid Command: %s" % request.method)
        response.payload = ''
        response.error = True
        response.error_string = "Invalid Command: %s" % request.method

    #mb.basic_ack(msg.delivery_tag)
    response_bytes = protocols.pack(protobuf.RpcResponseWrapper, response)
    mb.basic_publish(Message(response_bytes), routing_key=request.requestor)