Esempio n. 1
0
 def __str__(self):
     block = self.blocks[-1]
     s = "User-thrown exception while calling %s() in block %r." % (self.method, block.name)
     for b in self.blocks[::-1]:
         s += "\n- %s %s" % (b, id(b))
     s += "\n" + indent(self.user_exception, "> ")
     return s
Esempio n. 2
0
 def __str__(self):
     block = self.blocks[-1]
     s = ('User-thrown exception while calling %s() in block %r.' 
          % (self.method, block.name))
     for b in self.blocks[::-1]:
         s += '\n- %s %s' % (b, id(b))
     s += '\n' + indent(str(self.user_exception).strip(), '> ')
     return s
Esempio n. 3
0
    def write_value(self, timestamp, image):
        if self.image_shape is None:
            self.image_shape = image.shape

        if self.image_shape != image.shape:
            msg = ('The image has changed shape, from %s to %s.' %
                   (self.image_shape, image.shape))
            raise Exception(msg)  # TODO: badinput

        # very important! make sure we are using a reasonable array
        if not image.flags['C_CONTIGUOUS']:
            image = numpy.ascontiguousarray(image)  # @UndefinedVariable

        try:
            if False:
                with timeout(5):
                    self.process.stdin.write(image.data)
                    self.process.stdin.flush()
            else:
                self.process.stdin.write(image.data)
                self.process.stdin.flush()
        except (Exception, KeyboardInterrupt) as e:
            # IOError = broken pipe
            msg = 'Could not write data to mencoder: %s.' % e

            #            self.error(msg)
            #            msg += '\n' + indent(self.process.stdout.read(), 'stdout> ')
            #            msg += '\n' + indent(self.process.stderr.read(), 'stderr> ')

            def read_all(f):
                os.lseek(f.fileno(), 0, 0)
                return f.read()

            stderr = read_all(self.tmp_stderr)
            stdout = read_all(self.tmp_stdout)

            msg += indent('stdout>', stderr)
            msg += indent('stderr>', stdout)

            raise Exception(msg)

        if self.config.timestamps:
            self.timestamps_file.write('%.4f\n' % timestamp)
            self.timestamps_file.flush()
Esempio n. 4
0
    def write_value(self, timestamp, image):
        if self.image_shape is None:
            self.image_shape = image.shape

        if self.image_shape != image.shape:
            msg = ('The image has changed shape, from %s to %s.' % 
                   (self.image_shape, image.shape))
            raise Exception(msg)  # TODO: badinput

        # very important! make sure we are using a reasonable array
        if not image.flags['C_CONTIGUOUS']:
            image = numpy.ascontiguousarray(image)  # @UndefinedVariable

        try:
            if False:
                with timeout(5):
                    self.process.stdin.write(image.data)
                    self.process.stdin.flush()
            else:
                self.process.stdin.write(image.data)
                self.process.stdin.flush()
        except (Exception, KeyboardInterrupt) as e:
        # IOError = broken pipe
            msg = 'Could not write data to mencoder: %s.' % e
#            self.error(msg)
#            msg += '\n' + indent(self.process.stdout.read(), 'stdout> ')
#            msg += '\n' + indent(self.process.stderr.read(), 'stderr> ')

            def read_all(f):
                os.lseek(f.fileno(), 0, 0)
                return f.read()

            stderr = read_all(self.tmp_stderr)
            stdout = read_all(self.tmp_stdout)

            msg += indent('stdout>', stderr)
            msg += indent('stderr>', stdout)

            raise Exception(msg)

        if self.config.timestamps:
            self.timestamps_file.write('%.4f\n' % timestamp)
            self.timestamps_file.flush()
Esempio n. 5
0
def fcpx_get_xml_asset(video):
    id_format = video['id_format']
    xml_format = fcpx_get_xml_format(id_format, video)
    xml_metadata = fcpx_get_xml_metadata(video['metadata'])
    xml_asset = \
"""
<asset id="{id_video}" src="{src}">
{metadata}
</asset>
""".format(metadata=indent(xml_metadata, ' ' * 4),
           id_video=video['id_video'], src=video['filename'])
           
    return xml_format + '\n' + xml_asset
Esempio n. 6
0
def fcpx_get_xml_event(videos, project_name): 
    videos = list(videos)
    assets = fcpx_get_xml_assets(videos)
    clips = fcpx_get_xml_clips(videos)

    template = """
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.2">
<project name="{name}">
  <resources>
{assets}
  </resources>        
{clips}
</project>
</fcpxml>
    """
    assets = indent(assets, ' ' * 12)
    clips = indent(clips, ' ' * 8)
    s = template.format(name=project_name,
                        assets=assets,
                        clips=clips)
    return s