示例#1
0
    def dump_report(self):
        """ Dump check report. """
        valid_str = 'Success' if self.get_valid() else 'Fail'

        pretty_status = {
            'ERROR': 'Error(s)',
            'WARNING': 'Warning(s)',
            'INFO': 'Info(s)',
            'SILENT': 'Supressed(s)',
        }
        status_list = []

        for status, label in six.iteritems(pretty_status):
            checks = [
                "\t{} - {}".format(name, msg)
                for name, msg in self.check_report[status]
            ]
            if len(checks) > 0:
                checks_str = '\n'.join(checks)
                status_list.append("{} :\n{}".format(label, checks_str))

        bypass_list = self.check_profile['bypass']
        if len(bypass_list) > 0:
            bypass_list = ['\t' + b for b in bypass_list]
            checks_str = '\n'.join(bypass_list)
            status_list.append("Bypass(s) :\n{}".format(checks_str))

        self.check_log.info("DCP : {}".format(self.dcp.path))
        self.check_log.info("Size : {}".format(human_size(self.dcp.size)))
        [self.check_log.info(msg) for msg in status_list]
        self.check_log.info("Total check : {}".format(self.total_check))
        self.check_log.info("Total time : {:.2f} sec".format(self.total_time))
        self.check_log.info("Validation : {}\n".format(valid_str))
示例#2
0
    def check_subtitle_cpl_font_size(self, playlist, asset, folder):
        """ Subtitle maximum font size. """
        st_dict = self.get_subtitle_xml(asset, folder)
        if not st_dict:
            return
        path, uri = self.get_font_path(st_dict, folder)
        if not path:
            return

        font_size = os.path.getsize(path)
        font_max_size = DCP_SETTINGS['subtitle']['font_max_size']

        if font_size > font_max_size:
            raise CheckException(
                "Subtitle font maximum size is {}, got {}".format(
                    human_size(font_max_size), human_size(font_size)))
示例#3
0
    def check_subtitle_cpl_font_size(self, playlist, asset, folder):
        """ Subtitle maximum font size.

            References:
                TI Subtitle Specification for DLP Cinema (v1.1) 2.7
                https://web.archive.org/web/20140924175755/http://dlp.com/downloads/pdf_dlp_cinema_CineCanvas_Rev_C.pdf
        """
        st_dict = self.st_util.get_subtitle_xml(asset, folder)
        if not st_dict:
            return
        path, uri = self.st_util.get_font_path(st_dict, folder)
        if not path:
            return
        if not os.path.exists(path):
            return

        font_size = os.path.getsize(path)
        font_max_size = DCP_SETTINGS['subtitle']['font_max_size']

        if font_size > font_max_size:
            self.error("Subtitle font maximum size is {}, got {}".format(
                human_size(font_max_size), human_size(font_size)))
示例#4
0
文件: report.py 项目: remia/ClairMeta
    def pretty_str(self):
        """ Format the report in a human friendly way. """
        report = ""
        report += "Status : {}\n".format(
            'Success' if self.is_valid() else 'Fail')
        report += "Path : {}\n".format(self.dcp.path)
        report += "Size : {}\n".format(human_size(self.dcp.size))
        report += "Total check : {}\n".format(self.checks_count())
        report += "Total time : {:.2f} sec\n".format(self.duration)
        report += "\n"

        nested_dict = lambda: defaultdict(nested_dict)
        status_map = nested_dict()

        # Accumulate all failed check and stack them by asset
        for check in self.checks_failed():
            lines = [". {}".format(check.short_desc())]

            for error in check.errors:
                asset = status_map[str(error.criticality)]

                for filename in check.asset_stack:
                    asset = asset[filename]

                desc = error.short_desc()
                desc = ". {}\n".format(desc) if desc else ""
                lines.append("{}{}".format(desc, error.message))

            asset['msg'] = asset.get('msg', []) + ["\n".join(lines)]

        # Ignore silenced checks
        status_map.pop('SILENT', None)

        for status, vals in six.iteritems(status_map):
            out_stack = []
            for k, v in six.iteritems(vals):
                out_stack += [self._dump_stack("", k, v, indent_level=0)]
            if out_stack:
                report += "{}\n{}\n".format(self.pretty_status[status] + ':',
                                            "\n".join(out_stack))

        bypassed = "\n".join(
            set(['  . ' + c.short_desc() for c in self.checks_bypassed()]))
        if bypassed:
            report += "{}\n{}\n".format(self.pretty_status['BYPASS'] + ':',
                                        bypassed)

        return report
示例#5
0
    def parse(self, probe=True):
        """ Parse the DCP and Probe its assets. """
        if self._parsed:
            return self.probe_dict

        start = time.time()
        self.log.info("Probing DCP : {}".format(self.path))

        # Find and parse package components
        self.init_package_files()
        self.init_assetmap()
        self.init_volindex()
        self.init_pkl()
        self.init_cpl()

        if probe:
            self.cpl_probe_assets()
            self._probeb = True

        self.cpl_parse_metadata()

        seconds_elapsed = time.time() - start
        self.log.info("Total time : {:.2f} seconds".format(seconds_elapsed))

        self.probe_dict = {
            'asset_list': self._list_asset,
            'volindex_list': self._list_vol,
            'assetmap_list': self._list_am,
            'cpl_list': self._list_cpl,
            'pkl_list': self._list_pkl,
            'package_type': self.package_type,
            'path': self.path,
            'size': human_size(self.size),
            'count_file': len(self._list_asset),
            'schema': self.schema,
            'type': 'DCP'
        }

        # Remove namespace and attributes key from final result
        self.probe_dict = remove_key_dict(self.probe_dict,
                                          ['__xmlns__', '@xmlns'])
        self._parsed = True
        return self.probe_dict
示例#6
0
    def metadata(self):
        """ All extracted package metadata Dictionnary. """
        self.probe_dict = {
            'asset_list': self._list_asset,
            'volindex_list': self._list_vol,
            'assetmap_list': self._list_am,
            'cpl_list': self._list_cpl,
            'pkl_list': self._list_pkl,
            'kdm_list': self._list_kdm,
            'package_type': self.package_type,
            'path': self.path,
            'size': human_size(self.size),
            'count_file': len(self._list_asset),
            'schema': self.schema,
            'type': 'DCP'
        }

        # Remove namespace and attributes key
        self.probe_dict = remove_key_dict(self.probe_dict,
                                          ['__xmlns__', '@xmlns'])

        return self.probe_dict
示例#7
0
    def pretty_str(self):
        """ Format the report in a human friendly way. """
        report = ""
        report += "Status : {}\n".format('Success' if self.valid() else 'Fail')
        report += "Path : {}\n".format(self.dcp.path)
        report += "Size : {}\n".format(human_size(self.dcp.size))
        report += "Total check : {}\n".format(self.checks_count())
        report += "Total time : {:.2f} sec\n".format(self.duration)
        report += "\n"

        nested_dict = lambda: defaultdict(nested_dict)
        status_map = nested_dict()

        # Accumulate all failed check and stack them by asset
        for c in self.checks_failed():
            asset = status_map[c.criticality]
            for filename in c.asset_stack:
                asset = asset[filename]

            asset['msg'] = (asset.get('msg', []) +
                            ['. ' + c.short_desc() + '\n' + c.message])

        for status, vals in six.iteritems(status_map):
            out_stack = []
            for k, v in six.iteritems(vals):
                out_stack += [self._dump_stack("", k, v, indent_level=0)]
            if out_stack:
                report += "{}\n{}\n".format(self.pretty_status[status] + ':',
                                            "\n".join(out_stack))

        bypassed = "\n".join(
            set(['  . ' + c.short_desc() for c in self.checks_bypassed()]))
        if bypassed:
            report += "{}\n{}\n".format(self.pretty_status['BYPASS'] + ':',
                                        bypassed)

        return report