Beispiel #1
0
    def setUp(self):
        self.xmlParser = SimpleXMLParser()
        self.configFileParser = ConfigFileParser.ConfigFileParser()

        self.xmlParser.link((self.xmlParser, 'outbox'),
                            (self.configFileParser, 'inbox'))
        self.xmlParser.link((self.xmlParser, 'signal'),
                            (self.configFileParser, 'control'))

        self.initializeSystem(self.xmlParser, self.configFileParser)
Beispiel #2
0
def DetermineMaxFrameNumber(edlfile):
    """\
    Prefab.
    
    "outbox" sends out the highest frame number referenced in the EDL xml file.
    Then terminates immediately and sends out a producerFinished() message from
    the "signal" outbox.
    
    Arguments:
    
    - edlfile  -- full filepathname of the EDL xml file
    
    Inboxes:
    
    - "inbox"    -- NOT USED
    - "control"  -- Shutdown signalling
    
    Outboxes:
    
    - "outbox"  -- sends out the highest frame number referenced in the EDL file
    - "signal"  -- Shutdown signalling
    """
    return Pipeline(
        RateControlledFileReader(edlfile,readmode="lines",rate=1000000),
        SimpleXMLParser(),
        EDLParser(),
        SimpleDetupler("end"),
        Collate(),
        Max(),
        )
 def setUp(self):
     self.xmlParser        = SimpleXMLParser()
     self.configFileParser = ConfigFileParser.ConfigFileParser()
     
     self.xmlParser.link((self.xmlParser, 'outbox'), (self.configFileParser, 'inbox'))
     self.xmlParser.link((self.xmlParser, 'signal'), (self.configFileParser, 'control'))
     
     self.initializeSystem(self.xmlParser,  self.configFileParser)
Beispiel #4
0
def FilterForWantedFrameNumbers(edlfile):
    """\
    Prefab.
    
    Send messages of the form (framenum, data) to the "inbox" inbox. Items with
    a frame number that isn't in the edit decision list are dropped. Other items
    with frame numbers that are in the edit decision list are passed through out
    of the "outbox" outbox.
    
    Arguments:
    
    - edlfile  -- full filepathname of the EDL xml file
    
    Inboxes:
    
    - "inbox"    -- (framenum, data) items to be filtered
    - "control"  -- Shutdown signalling
    
    Outboxes:
    
    - "outbox"  -- items not filtered out
    - "signal"  -- Shutdown signalling
    """
    class ExtractRanges(object):
        def filter(self, edit):
            try:
                return (edit['start'],edit['end'])
            except:
                return None
    
    return Graphline(
        RANGESRC = Pipeline(
                       RateControlledFileReader(edlfile,readmode="lines",rate=1000000),
                       SimpleXMLParser(),
                       EDLParser(),
                       Filter(filter = ExtractRanges()),
                       Collate(),
                   ),
        FILTER   = Carousel(lambda ranges : RangeFilter(ranges)),
        linkages = {
            ("RANGESRC","outbox") : ("FILTER","next"),
            
            ("","inbox") : ("FILTER","inbox"),
            ("FILTER","outbox") : ("","outbox"),
            
            ("","control") : ("FILTER","control"),
            ("FILTER","signal") :("","signal"),
        },
        )
Beispiel #5
0
def EditDecisionSource(edlfile):
    """\
    Prefab.
    
    Reads in the edit decisions from the edit decision list file; then sends
    then out, one at a time, out of the "outbox" outbox whenever a message is
    sent to the "inbox" inbox. The message sent to the inbox does not matter.
    
    Edit decisions are of the form::
    
        { "start"  : start frame number for this edit decision
          "end"    : end frame number for this edit decision
          "left"   : left edge to crop to (in pixels)
          "top"    : top edge to crop to (in pixels)
          "right"  : right edge to crop to (in pixels)
          "bottom" : bottom edge to crop to (in pixels)
        }
    
    Arguments:
    
    - edlfile      -- full filepathname of the EDL xml file
    
    Inboxes:
    
    - "inbox"    -- Messages to trigger sending out of edit decisions
    - "control"  -- Shutdown signalling
    
    Outboxes:
    
    - "outbox"  -- Individual edit decisions
    - "signal"  -- Shutdown signalling
    """
    return Graphline( \
        PARSING = Pipeline( RateControlledFileReader(edlfile,readmode="lines",rate=1000000),
                            SimpleXMLParser(),
                            EDLParser(),
                          ),
        GATE = PromptedTurnstile(),
        linkages = {
            ("", "inbox") : ("GATE", "next"),

            ("PARSING", "outbox") : ("GATE", "inbox"),
            ("GATE",    "outbox") : ("",     "outbox"),
            
            ("PARSING", "signal") : ("GATE", "control"),
            ("GATE",    "signal") : ("", "signal"),

        } )
class ConfigFileParserTestCase(KamTestCase.KamTestCase):
    SAMPLE_CONFIG1 = """<?xml version="1.0" encoding="UTF-8"?>
            <kamplanetconfig>
                <general>
                    <name>Kamaelia Planet</name>
                    <link>http://somewhere/</link>
                    <rssTemplateName>rss20.xml.tmpl</rssTemplateName>
                    <htmlTemplateName>index.html.tmpl</htmlTemplateName>
                    <rssFileName>output/rss20.xml</rssFileName>

                    <htmlFileName>output/index.html</htmlFileName>
                    <maxPostNumber>30</maxPostNumber>
                </general>
                <feeds>
                    <feed url="http://localhost/blog1">
                        <name>blog1</name>
                    </feed>
                    <feed url="http://localhost/blog2">
                        <name>blog2</name>
                        <face>imgs/blog2.png</face>
                        <faceHeight>12345</faceHeight>
                        <faceWidth>54321</faceWidth>
                    </feed>
                </feeds>
            </kamplanetconfig>
        """
    
    def setUp(self):
        self.xmlParser        = SimpleXMLParser()
        self.configFileParser = ConfigFileParser.ConfigFileParser()
        
        self.xmlParser.link((self.xmlParser, 'outbox'), (self.configFileParser, 'inbox'))
        self.xmlParser.link((self.xmlParser, 'signal'), (self.configFileParser, 'control'))
        
        self.initializeSystem(self.xmlParser,  self.configFileParser)
    
    def runWithSampleConfig(self, sampleConfig):
        self.put(sampleConfig, 'inbox')
        self.put(producerFinished(), "control")
        
    def testSampleConfigNotStopping(self):
        self.put(self.SAMPLE_CONFIG1, 'inbox')
        # I actively say that I don't care which threads are still running
        self.assertNotFinished()
        
    def testSignal(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)
        
        signalMsg      = self.get('signal')
        self.assertTrue(
            isinstance(
                       signalMsg, 
                       producerFinished
            )
        )
        self.assertTrue(
            self.configFileParser, 
            signalMsg.caller
        )
        self.assertOutboxEmpty('signal')
    
    def testGeneralConfig(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)
        configMsg = self.get('config-outbox')
        self.assertEquals('Kamaelia Planet', configMsg.name)
        self.assertOutboxEmpty('config-outbox')
        
    def testFeedsOutbox(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)
        firstFeedMessage = self.get('feeds-outbox')
        self.assertEquals("http://localhost/blog1", firstFeedMessage.url )
        self.assertEquals("blog1",                  firstFeedMessage.name )
        self.assertEquals(
                    ConfigFileParser.DEFAULT_FACE_HEIGHT,
                    firstFeedMessage.faceHeight
                )
        self.assertEquals(
                    ConfigFileParser.DEFAULT_FACE_WIDTH,
                    firstFeedMessage.faceWidth 
                )
        self.assertEquals(
                    ConfigFileParser.DEFAULT_FACE,
                    firstFeedMessage.face
                )
        
        secondFeedMessage = self.get('feeds-outbox')
        self.assertEquals("http://localhost/blog2", secondFeedMessage.url )
        self.assertEquals("blog2",                  secondFeedMessage.name )
        self.assertEquals(
                    '12345',
                    secondFeedMessage.faceHeight
                )
        self.assertEquals(
                    '54321',
                    secondFeedMessage.faceWidth 
                )
        self.assertEquals(
                    'imgs/blog2.png',
                    secondFeedMessage.face
                )
        self.assertOutboxEmpty('feeds-outbox')
Beispiel #7
0
class ConfigFileParserTestCase(KamTestCase.KamTestCase):
    SAMPLE_CONFIG1 = """<?xml version="1.0" encoding="UTF-8"?>
            <kamplanetconfig>
                <general>
                    <name>Kamaelia Planet</name>
                    <link>http://somewhere/</link>
                    <rssTemplateName>rss20.xml.tmpl</rssTemplateName>
                    <htmlTemplateName>index.html.tmpl</htmlTemplateName>
                    <rssFileName>output/rss20.xml</rssFileName>

                    <htmlFileName>output/index.html</htmlFileName>
                    <maxPostNumber>30</maxPostNumber>
                </general>
                <feeds>
                    <feed url="http://localhost/blog1">
                        <name>blog1</name>
                    </feed>
                    <feed url="http://localhost/blog2">
                        <name>blog2</name>
                        <face>imgs/blog2.png</face>
                        <faceHeight>12345</faceHeight>
                        <faceWidth>54321</faceWidth>
                    </feed>
                </feeds>
            </kamplanetconfig>
        """

    def setUp(self):
        self.xmlParser = SimpleXMLParser()
        self.configFileParser = ConfigFileParser.ConfigFileParser()

        self.xmlParser.link((self.xmlParser, 'outbox'),
                            (self.configFileParser, 'inbox'))
        self.xmlParser.link((self.xmlParser, 'signal'),
                            (self.configFileParser, 'control'))

        self.initializeSystem(self.xmlParser, self.configFileParser)

    def runWithSampleConfig(self, sampleConfig):
        self.put(sampleConfig, 'inbox')
        self.put(producerFinished(), "control")

    def testSampleConfigNotStopping(self):
        self.put(self.SAMPLE_CONFIG1, 'inbox')
        # I actively say that I don't care which threads are still running
        self.assertNotFinished()

    def testSignal(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)

        signalMsg = self.get('signal')
        self.assertTrue(isinstance(signalMsg, producerFinished))
        self.assertTrue(self.configFileParser, signalMsg.caller)
        self.assertOutboxEmpty('signal')

    def testGeneralConfig(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)
        configMsg = self.get('config-outbox')
        self.assertEquals('Kamaelia Planet', configMsg.name)
        self.assertOutboxEmpty('config-outbox')

    def testFeedsOutbox(self):
        self.runWithSampleConfig(self.SAMPLE_CONFIG1)
        firstFeedMessage = self.get('feeds-outbox')
        self.assertEquals("http://localhost/blog1", firstFeedMessage.url)
        self.assertEquals("blog1", firstFeedMessage.name)
        self.assertEquals(ConfigFileParser.DEFAULT_FACE_HEIGHT,
                          firstFeedMessage.faceHeight)
        self.assertEquals(ConfigFileParser.DEFAULT_FACE_WIDTH,
                          firstFeedMessage.faceWidth)
        self.assertEquals(ConfigFileParser.DEFAULT_FACE, firstFeedMessage.face)

        secondFeedMessage = self.get('feeds-outbox')
        self.assertEquals("http://localhost/blog2", secondFeedMessage.url)
        self.assertEquals("blog2", secondFeedMessage.name)
        self.assertEquals('12345', secondFeedMessage.faceHeight)
        self.assertEquals('54321', secondFeedMessage.faceWidth)
        self.assertEquals('imgs/blog2.png', secondFeedMessage.face)
        self.assertOutboxEmpty('feeds-outbox')
Beispiel #8
0
 def create_xml_parser(self):
     return Pipeline(RateControlledFileReader(self._fileName),
                     SimpleXMLParser())