def perform_command(self):
        """
        Perform command and return the appropriate exit code.

        :rtype: int
        """
        if len(self.actual_arguments) < 2:
            return self.print_help()
        input_file_path = self.actual_arguments[0]
        output_file_path = self.actual_arguments[1]

        if not self.check_input_file(input_file_path):
            return self.ERROR_EXIT_CODE
        if not self.check_output_file(output_file_path):
            return self.ERROR_EXIT_CODE

        fast = self.has_option("--fast")
        fragment_text = self.has_option("--text")
        h_zoom = gf.safe_int(self.has_option_with_value("--hzoom"), 5)
        label = self.has_option_with_value("--label")
        time_step = gf.safe_int(self.has_option_with_value("--time-step"), 0)
        v_zoom = gf.safe_int(self.has_option_with_value("--vzoom"), 30)

        labels = not self.has_option("--no-labels")
        begin_times = not self.has_option("--no-begin-times")
        end_times = not self.has_option("--no-end-times")
        begin_guides = not self.has_option("--no-begin-guides")
        end_guides = not self.has_option("--no-end-guides")

        try:
            # import or ImportError
            from aeneas.plotter import PlotLabelset
            from aeneas.plotter import PlotTimeScale
            from aeneas.plotter import PlotWaveform
            from aeneas.plotter import Plotter

            # create plotter object
            self.print_info(u"Plotting to file...")
            plotter = Plotter(rconf=self.rconf, logger=self.logger)

            # add waveform
            afm = AudioFile(input_file_path, rconf=self.rconf, logger=self.logger)
            afm.read_samples_from_file()
            plotter.add_waveform(PlotWaveform(afm, label=label, fast=fast, rconf=self.rconf, logger=self.logger))

            # add time scale, if requested
            if time_step > 0:
                plotter.add_timescale(PlotTimeScale(afm.audio_length, time_step=time_step, rconf=self.rconf, logger=self.logger))

            # add labelsets, if any
            for i in range(len(self.actual_arguments)):
                if (self.actual_arguments[i] == "-i") and (i + 1 < len(self.actual_arguments)):
                    label_file_path = self.actual_arguments[i + 1]
                    extension = gf.file_extension(label_file_path)
                    if extension == "vad":
                        labelset = self._read_syncmap_file(label_file_path, SyncMapFormat.TSV, False)
                        ls = PlotLabelset(labelset, parameters=None, rconf=self.rconf, logger=self.logger)
                        ls.parameters["labels"] = False
                        ls.parameters["begin_time"] = begin_times
                        ls.parameters["end_time"] = end_times
                        ls.parameters["begin_guide"] = begin_guides
                        ls.parameters["end_guide"] = end_guides
                        plotter.add_labelset(ls)
                    if extension in SyncMapFormat.ALLOWED_VALUES:
                        labelset = self._read_syncmap_file(label_file_path, extension, fragment_text)
                        ls = PlotLabelset(labelset, parameters=None, rconf=self.rconf, logger=self.logger)
                        ls.parameters["labels"] = labels
                        ls.parameters["begin_time"] = begin_times
                        ls.parameters["end_time"] = end_times
                        ls.parameters["begin_guide"] = begin_guides
                        ls.parameters["end_guide"] = end_guides
                        plotter.add_labelset(ls)

            # output to file
            plotter.draw_png(output_file_path, h_zoom=h_zoom, v_zoom=v_zoom)
            self.print_info(u"Plotting to file... done")
            self.print_success(u"Created file '%s'" % output_file_path)
            return self.NO_ERROR_EXIT_CODE
        except ImportError:
            self.print_error(u"You need to install Python module Pillow to output image to file. Run:")
            self.print_error(u"$ pip install Pillow")
            self.print_error(u"or, to install for all users:")
            self.print_error(u"$ sudo pip install Pillow")
        except Exception as exc:
            self.print_error(u"An unexpected error occurred while generating the image file:")
            self.print_error(u"%s" % exc)

        return self.ERROR_EXIT_CODE
def perform_command ( self ) : if len ( self . actual_arguments ) < 2 : return self . print_help ( ) input_file_path = self . actual_arguments [ 0 ] output_file_path = self . actual_arguments [ 1 ] if not self . check_input_file ( input_file_path ) : return self . ERROR_EXIT_CODE if not self . check_output_file ( output_file_path ) : return self . ERROR_EXIT_CODE fast = self . has_option ( "--fast" ) fragment_text = self . has_option ( "--text" ) h_zoom = gf . safe_int ( self . has_option_with_value ( "--hzoom" ) , 5 ) label = self . has_option_with_value ( "--label" ) time_step = gf . safe_int ( self . has_option_with_value ( "--time-step" ) , 0 ) v_zoom = gf . safe_int ( self . has_option_with_value ( "--vzoom" ) , 30 ) labels = not self . has_option ( "--no-labels" ) begin_times = not self . has_option ( "--no-begin-times" ) end_times = not self . has_option ( "--no-end-times" ) begin_guides = not self . has_option ( "--no-begin-guides" ) end_guides = not self . has_option ( "--no-end-guides" ) try : from aeneas . plotter import PlotLabelset from aeneas . plotter import PlotTimeScale from aeneas . plotter import PlotWaveform from aeneas . plotter import Plotter self . print_info ( u"Plotting to file..." ) plotter = Plotter ( rconf = self . rconf , logger = self . logger ) afm = AudioFile ( input_file_path , rconf = self . rconf , logger = self . logger ) afm . read_samples_from_file ( ) plotter . add_waveform ( PlotWaveform ( afm , label = label , fast = fast , rconf = self . rconf , logger = self . logger ) ) if time_step > 0 : plotter . add_timescale ( PlotTimeScale ( afm . audio_length , time_step = time_step , rconf = self . rconf , logger = self . logger ) ) for i in range ( len ( self . actual_arguments ) ) : if ( self . actual_arguments [ i ] == "-i" ) and ( i + 1 < len ( self . actual_arguments ) ) : label_file_path = self . actual_arguments [ i + 1 ] extension = gf . file_extension ( label_file_path ) if extension == "vad" : labelset = self . _read_syncmap_file ( label_file_path , SyncMapFormat . TSV , False ) ls = PlotLabelset ( labelset , parameters = None , rconf = self . rconf , logger = self . logger ) ls . parameters [ "labels" ] = False ls . parameters [ "begin_time" ] = begin_times ls . parameters [ "end_time" ] = end_times ls . parameters [ "begin_guide" ] = begin_guides ls . parameters [ "end_guide" ] = end_guides plotter . add_labelset ( ls ) if extension in SyncMapFormat . ALLOWED_VALUES : labelset = self . _read_syncmap_file ( label_file_path , extension , fragment_text ) ls = PlotLabelset ( labelset , parameters = None , rconf = self . rconf , logger = self . logger ) ls . parameters [ "labels" ] = labels ls . parameters [ "begin_time" ] = begin_times ls . parameters [ "end_time" ] = end_times ls . parameters [ "begin_guide" ] = begin_guides ls . parameters [ "end_guide" ] = end_guides plotter . add_labelset ( ls ) plotter . draw_png ( output_file_path , h_zoom = h_zoom , v_zoom = v_zoom ) self . print_info ( u"Plotting to file... done" ) self . print_success ( u"Created file '%s'" % output_file_path ) return self . NO_ERROR_EXIT_CODE except ImportError : self . print_error ( u"You need to install Python module Pillow to output image to file. Run:" ) self . print_error ( u"$ pip install Pillow" ) self . print_error ( u"or, to install for all users:" ) self . print_error ( u"$ sudo pip install Pillow" ) except Exception as exc : self . print_error ( u"An unexpected error occurred while generating the image file:" ) self . print_error ( u"%s" % exc ) return self . ERROR_EXIT_CODE
Perform command and return the appropriate exit code.

        :rtype: int