Exemplo n.º 1
0
    def ll_report(self):
        '''
        1) Check if display options was selected.
        2) Test the environment and the script dependencies
           was selected.
        3) Process the MythTV recording
        return nothing
        '''
        if self.configuration['test']:
            self._display_variables(summary=True)
            sys.stdout.write(
_(u'''Congratulations! All script dependencies have been satisfied.
You are ready to create bugs or success reports for lossless_cut.py

'''))
            sys.exit(0)
        #
        # Check that at least one report type was selected
        if not self.configuration['bugtext'] and \
                not self.configuration['bugarchive'] and \
                not self.configuration['wiki']:
            sys.stdout.write(USAGE_TEXT)
            sys.stderr.write(
_(u'''You must specify at least one report type (-b, -B, -w) on the command line!\n'''))
            sys.exit(1)
        #
        # Get the xml track info using mediainfo
        self.configuration['trackinfo'] = get_mediainfo(
                        self.configuration['recordedfile'],
                        self.element_filter, self.tracks_filter,
                        etree, self.logger, sys)
        #
        ## Get this recordings metadata and other data from the MyhTV DB
        self.mythtvinterface.get_recorded_data()
        #
        self.subtitles = False
        self._display_variables()
        #
        if self.configuration['bugtext']:
            self.bug_report()
        #
        if self.configuration['bugarchive']:
            self.bug_archive()
        #
        if self.configuration['wiki']:
            self.wiki_table_row()
        #
        self._cleanup()
        #
        return
Exemplo n.º 2
0
    def adjust_frame_numbers(self):
        '''
        1) Check if display options was selected.
        2) Test the environment and the script dependencies
           was selected.
        3) Process the MythTV recording
        return nothing
        '''
        if self.configuration['summary']:
            self._display_variables(summary=True)
            sys.exit(int(self.jobstatus.UNKNOWN))
        #
        if self.configuration['test']:
            self._display_variables(summary=True)
            sys.stdout.write(
                _(u'''Congratulations! All script dependencies have been satisfied.
You are ready to adjust the skip and/or cut list frame numbers to keyframes
on a MythTV recordings.

'''))
            sys.exit(int(self.jobstatus.UNKNOWN))
        #
        self.logger.info(
            # TRANSLATORS: Please leave %s as it is,
            # because it is needed by the program.
            # Thank you for contributing to this project.
            _(u'''Start skip and/or cut list frame number adjustments for "%s" at: %s'''
              ) %
            (self.configuration['recordedfile'],
             self.processing_started.strftime(common.LL_START_END_FORMAT)))
        #
        self._display_variables()
        #
        # Get the xml track info using mediainfo
        self.configuration['trackinfo'] = get_mediainfo(
            self.configuration['recordedfile'], self.element_filter,
            self.tracks_filter, etree, self.logger, sys)
        #
        self.mythtvinterface.adjust_frame_numbers()
        #
        self._cleanup()
        #
        return
Exemplo n.º 3
0
    def bug_archive(self, ):
        ''' Create a bug report and display to the STDOUT and a
        text file. Create a 25Mg copy of the MythTV recording.
        Create an tar.gz file containing the bug test and 25Mg
        example video file. Delete the temporary files and display
        the tar.gz file name.
        return nothing
        '''
        self.bug_report(create_only=True)
        #
        if not self.configuration['all']:
            # Create the 25Mg sample video file
            self.configuration['bug_sample'] = \
u"%(recorded_name)s_LOSSLESS_BUG.%(recorded_ext)s" % self.configuration
            self.configuration['sample_startblock'] = 0
            if self.configuration['sample_starttime']:
                self.configuration['sample_startblock'] = \
                    self.mythtvinterface.calc_dd_blocks(
                                    self.configuration['sample_starttime'])
            arguments = common.VIDEO_SAMPLE_FILE_CMD % self.configuration
            verbage = _(
u'''Creating a 25Mg video sample file with the command below, please wait ...
dd %s
'''  % arguments)
            self.logger.info(verbage)
            sys.stdout.write(verbage + u'\n')
            #
            result = commandline_call(u'dd', arguments)
            if not result[0]:
                if result[1].find('25 MB') == -1:
                    # TRANSLATORS: Please leave %s as it is,
                    # because it is needed by the program.
                    # Thank you for contributing to this project.
                    verbage = \
        _(u'''dd could not make the sample video file, aborting script.
Error: %s''') % (result[1])
                    self.logger.critical(verbage)
                    sys.stderr.write(verbage + u'\n')
                    exit(1)
        #
        # Get the relevant database records
        verbage = _(
u'''Getting the relevant database records for this recording, please wait ...
''')
        self.logger.info(verbage)
        sys.stdout.write(verbage + u'\n')
        pickle_filename = \
                u"%(recorded_name)s_LOSSLESS_BUG.pickle" % self.configuration
        records = self.mythtvinterface.get_all_recording_data()
        # Add the exact filename and path to the archive
        if self.configuration['all']:
            records['video_filename'] = self.configuration['recordedfile']
        else:
            records['video_filename'] = self.configuration['bug_sample']
        #
        # Get the xml track info using mediainfo
        trackinfo = get_mediainfo(
                    records['video_filename'],
                    self.element_filter, self.tracks_filter,
                    etree, self.logger, sys)
        # Add sample starttime information
        records['sample_starttime'] = 0
        records['sample_startblock'] = 0
        if self.configuration['sample_starttime']:
            records['sample_starttime'] = \
                        self.configuration['sample_starttime']
            records['sample_startblock'] = \
                        self.configuration['sample_startblock']
        records['video_duration'] = trackinfo['video_duration']
        dump(records, open(pickle_filename, "wb" ))
        #
        # Create the tar.gz file containing the bug sample video,
        # text report and database records pickle file
        verbage = _(
u'''Creating the bug report archive file, please wait ...
''')
        self.logger.info(verbage)
        sys.stdout.write(verbage + u'\n')
        files_to_tar = glob(u'%(recorded_name)s_LOSSLESS_BUG.*' %
                        self.configuration)
        #
        # If there is a log file then include it in the archive
        logfile = os.path.join(self.configuration['logpath'],
                            self.configuration['recorded_name'] + u'.log')
        if os.path.isfile(logfile):
            files_to_tar.append(logfile)
        else:
            sys.stderr.write('''There is no associated log file "%s"
to add to the bug report archive.''' % logfile + u'\n\n')
        #
        # If the -A option was selcted then copy the whole
        # recorded video file to the archive.
        if self.configuration['all']:
            files_to_tar.append(self.configuration['recordedfile'])
            sys.stderr.write(_(
u'''The whole recorded video file will be add to the bug report archive:
"%s"
This will take several minutes, please wait ...''') %
            self.configuration['recordedfile'] + u'\n\n')
        #
        tar_filename = u'%(recorded_name)s_LOSSLESS_BUG.tar.bz2' % \
                        self.configuration
        tar = tarfile.open(tar_filename, 'w:bz2')
        for filename in files_to_tar:
            dummy, base_filename = os.path.split(filename)
            tar.add(filename, arcname=base_filename)
        tar.close()
        #
        # Remove the bug sample video, db pickle and text report
        os.remove(self.filename)
        os.remove(pickle_filename)
        if not self.configuration['all']:
            os.remove(self.configuration['bug_sample'])
        #
        sys.stdout.write((_(
u'''Bug report file "%s" created.
You can upload archive file to a file site such as mediafire.com, then post
the download URL on the MythTV mailing list with an explanation of the issues.
''') % tar_filename)
            + u'\n')
        #
        return