Esempio n. 1
0
 def build_request(self, op_id, platform, arch, branding_variables, package_type, destination):
     self.response = None
     self.corr_id = op_id
     request_data_json = {
         'branding_variables': branding_variables,
         'platform': platform,
         'arch': arch,
         'package_type' : package_type,
         'destination' : destination
     }
     request_data_str = json.dumps(request_data_json)
     print ("build request body: %s" % request_data_str)
     self.channel.basic_publish(exchange = '',
                        routing_key = base.gen_routing_key(platform, str(arch)),
                        properties = pika.BasicProperties(reply_to = self.callback_queue, correlation_id = self.corr_id),
                        body = request_data_str)
     self.response = None
     while self.response is None:
         self.connection.process_data_events()
     return self.response
Esempio n. 2
0
 def build_request(self, op_id, platform, arch, branding_variables,
                   package_type, destination):
     self.response = None
     self.corr_id = op_id
     request_data_json = {
         'branding_variables': branding_variables,
         'platform': platform,
         'arch': arch,
         'package_type': package_type,
         'destination': destination
     }
     request_data_str = json.dumps(request_data_json)
     print("build request body: %s" % request_data_str)
     self.channel.basic_publish(
         exchange='',
         routing_key=base.gen_routing_key(platform, str(arch)),
         properties=pika.BasicProperties(reply_to=self.callback_queue,
                                         correlation_id=self.corr_id),
         body=request_data_str)
     self.response = None
     while self.response is None:
         self.connection.process_data_events()
     return self.response
Esempio n. 3
0
            print('build finished for: {0}, platform: {1}_{2}, exception: {3}'.
                  format(op_id, platform, arch, str(ex)))
            json_to_send = {'error': str(ex)}

        self.send_status(ch, props.reply_to, op_id, 100, 'Completed')

        ch.basic_publish(exchange='',
                         routing_key=props.reply_to,
                         properties=pika.BasicProperties(
                             content_type='application/json',
                             correlation_id=op_id,
                             headers={'type': 'responce'}),
                         body=json.dumps(json_to_send))
        ch.basic_ack(delivery_tag=method.delivery_tag)


if __name__ == "__main__":
    argc = len(sys.argv)

    if argc > 1:
        platform_str = sys.argv[1]
    else:
        platform_str = base.get_os()

    if argc > 2:
        arch_str = sys.argv[2]
    else:
        arch_str = base.get_arch()

    server = BuildRpcServer(base.gen_routing_key(platform_str, arch_str))
    server.start()
Esempio n. 4
0
        try:
            response = self.build_package(op_id, platform, arch, branding_variables, package_type, destination, ch, props.reply_to)
            print('build finished for: {0}, platform: {1}_{2}, responce: {3}'.format(op_id, platform, arch, response))
            json_to_send = {'body' :response}
        except Exception as ex:
            print('build finished for: {0}, platform: {1}_{2}, exception: {3}'.format(op_id, platform, arch, str(ex)))
            json_to_send = {'error': str(ex)}
        
        self.send_status(ch, props.reply_to, op_id, 100, 'Completed')

        ch.basic_publish(exchange = '',
                 routing_key = props.reply_to,
                 properties = pika.BasicProperties(content_type = 'application/json', correlation_id = op_id, headers = {'type' : 'responce'} ),                 
                 body = json.dumps(json_to_send))
        ch.basic_ack(delivery_tag = method.delivery_tag)

if __name__ == "__main__":
    argc = len(sys.argv)

    if argc > 1:
        platform_str = sys.argv[1]
    else:
        platform_str = base.get_os()

    if argc > 2:
        arch_str = sys.argv[2]
    else:
        arch_str = base.get_arch()
        
    server = BuildRpcServer(base.gen_routing_key(platform_str, arch_str))
    server.start()