@@ -0,0 +1,2423 @@
+# This file is part of fedmsg.%0A# Copyright (C) 2012 - 2014 Red Hat, Inc.%0A#%0A# fedmsg is free software; you can redistribute it and/or%0A# modify it under the terms of the GNU Lesser General Public%0A# License as published by the Free Software Foundation; either%0A# version 2.1 of the License, or (at your option) any later version.%0A#%0A# fedmsg is distributed in the hope that it will be useful,%0A# but WITHOUT ANY WARRANTY; without even the implied warranty of%0A# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU%0A# Lesser General Public License for more details.%0A#%0A# You should have received a copy of the GNU Lesser General Public%0A# License along with fedmsg; if not, write to the Free Software%0A# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA%0A#%0A# Authors:  Ralph Bean %3Crbean@redhat.com%3E%0Afrom __future__ import print_function%0A%0Aimport requests%0Aimport sys%0A%0Aimport fedmsg%0Afrom fedmsg.commands import BaseCommand%0A%0A%0Aclass ReplayCommand(BaseCommand):%0A    %22%22%22 Replay a message from the datagrepper history on your local bus. %22%22%22%0A%0A    name = %22fedmsg-dg-replay%22%0A    extra_args = %5B%0A        (%5B'--msg-id'%5D, %7B%0A            'dest': 'msg_id',%0A            'help': 'The msg_id of the message you want to replay.',%0A            'default': None,%0A        %7D),%0A        (%5B'--datagrepper-url'%5D, %7B%0A            'dest': 'datagrepper_url',%0A            'help': 'The URL of a datagrepper instance to query for history.',%0A            'default': 'https://apps.fedoraproject.org/datagrepper',%0A        %7D),%0A    %5D%0A%0A    def run(self):%0A        self.config%5B'active'%5D = True%0A        self.config%5B'name'%5D = 'relay_inbound'%0A        fedmsg.init(**self.config)%0A%0A        idx = self.config.get('msg_id')%0A        if not idx:%0A            print(%22--msg-id is required%22)%0A            sys.exit(1)%0A%0A        print(%22Retrieving %25r%22 %25 idx)%0A        url = self.config%5B'datagrepper_url'%5D + %22/id%22%0A        resp = requests.get(url, params=%7B'id': idx%7D)%0A%0A        code = resp.status_code%0A        if code != 200:%0A            print(%22datagrepper request of %25r failed. Status: %25r%22 %25 (idx, code))%0A            sys.exit(2)%0A%0A        msg = resp.json()%0A        tokens = msg%5B'topic'%5D.split('.')%0A        modname = tokens%5B4%5D%0A        topic = '.'.join(tokens%5B5:%5D)%0A%0A        print(%22Broadcasting %25r%22 %25 idx)%0A        fedmsg.publish(modname=modname, topic=topic, msg=msg%5B'msg'%5D)%0A        print(%22OK.%22)%0A%0A%0Adef replay():%0A    command = ReplayCommand()%0A    return command.execute()%0A

Add the actual code for the "replay" command.