示例#1
0
class MessagingProducer(object):
    '''
    Base class for all integration class that will produce messages.

    All messaging awared integration app should inherit from this class.
    '''
    def __init__(self):
        self._producer = Producer()

    def send(self, msg, event_name, sync=True):
        ''' Begin to send message '''

        routing_key = '%s.%s' % (ROUTING_KEY_PREFIX, event_name)
        self._producer.send(msg, routing_key, sync)
示例#2
0
文件: base.py 项目: Aaln1986/Nitrate
class MessagingProducer(object):
    '''
    Base class for all integration class that will produce messages.

    All messaging awared integration app should inherit from this class.
    '''

    def __init__(self):
        self._producer = Producer()

    def send(self, msg, event_name, sync=True):
        ''' Begin to send message '''

        routing_key = '%s.%s' % (ROUTING_KEY_PREFIX, event_name)
        self._producer.send(msg, routing_key, sync)
示例#3
0
def qpid_run_progress(sender, *args, **kwargs):
    tcr = kwargs['instance']
    tr = tcr.run
    if not kwargs.get('created'):
        # testrun is progress
        run_info = {
            "plan_id": tr.plan_id,
            "run_id": tr.run_id,
            "errata_id": tr.errata_id,
            "when": datetime.datetime.now().strftime("%Y-%m-%d %X"),
        }

        if not tr.check_all_case_runs():
            # testrun is progress
            completed_percent = str(tr.completed_case_run_percent) + "%"
            run_info["completed_percent"] = completed_percent
            try:
                MessageBus().send(run_info, "testrun.progress", False)
            except:
                pass

        else:
            # testrun is finished
            try:
                Producer().send(run_info, "testrun.finished", False)
            except:
                pass
    else:
        # FIXME: log, plugin and other editing functions
        pass
示例#4
0
def qpid_run_created(sender, *args, **kwargs):
    tr = kwargs['instance']
    if kwargs.get('created'):
        run_create_info = {
            "plan_id": tr.plan_id,
            "run_id": tr.run_id,
            "errata_id": tr.errata_id,
            "when": datetime.datetime.now().strftime("%Y-%m-%d %X")
        }
        try:
            Producer().send(run_create_info, "testrun.created", False)
        except:
            pass

    else:
        # FIXME: Log, Plugin and other editing functions
        pass
示例#5
0
文件: base.py 项目: Aaln1986/Nitrate
 def __init__(self):
     self._producer = Producer()
示例#6
0
 def __init__(self):
     self._producer = Producer()